Skip to content

Commit 558e053

Browse files
committed
[x86][Windows] Fix chromium build break
Windows does not support float C89 math functions like: - acosf - asinf - atanf - coshf - sinhf - tanhf These 6 libfuncs need to be type promoted. This PR fixes the bug introduced by llvm#98949
1 parent d5498c3 commit 558e053

File tree

2 files changed

+115
-2
lines changed

2 files changed

+115
-2
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2475,16 +2475,22 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
24752475
(Subtarget.isTargetWindowsMSVC() || Subtarget.isTargetWindowsItanium()))
24762476
// clang-format off
24772477
for (ISD::NodeType Op :
2478-
{ISD::FCEIL, ISD::STRICT_FCEIL,
2478+
{ISD::FACOS, ISD::STRICT_FACOS,
2479+
ISD::FASIN, ISD::STRICT_FASIN,
2480+
ISD::FATAN, ISD::STRICT_FATAN,
2481+
ISD::FCEIL, ISD::STRICT_FCEIL,
24792482
ISD::FCOS, ISD::STRICT_FCOS,
2483+
ISD::FCOSH, ISD::STRICT_FCOSH,
24802484
ISD::FEXP, ISD::STRICT_FEXP,
24812485
ISD::FFLOOR, ISD::STRICT_FFLOOR,
24822486
ISD::FREM, ISD::STRICT_FREM,
24832487
ISD::FLOG, ISD::STRICT_FLOG,
24842488
ISD::FLOG10, ISD::STRICT_FLOG10,
24852489
ISD::FPOW, ISD::STRICT_FPOW,
24862490
ISD::FSIN, ISD::STRICT_FSIN,
2487-
ISD::FTAN, ISD::STRICT_FTAN})
2491+
ISD::FSINH, ISD::STRICT_FSINH,
2492+
ISD::FTAN, ISD::STRICT_FTAN,
2493+
ISD::FTANH, ISD::STRICT_FTANH})
24882494
if (isOperationExpand(Op, MVT::f32))
24892495
setOperationAction(Op, MVT::f32, Promote);
24902496
// clang-format on

llvm/test/CodeGen/X86/fp-strict-libcalls-msvc32.ll

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,107 @@ define float @tan(float %x) #0 {
177177
ret float %result
178178
}
179179

180+
define float @acos(float %x) #0 {
181+
; CHECK-LABEL: acos:
182+
; CHECK: # %bb.0:
183+
; CHECK-NEXT: subl $12, %esp
184+
; CHECK-NEXT: flds {{[0-9]+}}(%esp)
185+
; CHECK-NEXT: fstpl (%esp)
186+
; CHECK-NEXT: wait
187+
; CHECK-NEXT: calll _acos
188+
; CHECK-NEXT: fstps {{[0-9]+}}(%esp)
189+
; CHECK-NEXT: flds {{[0-9]+}}(%esp)
190+
; CHECK-NEXT: wait
191+
; CHECK-NEXT: addl $12, %esp
192+
; CHECK-NEXT: retl
193+
%result = call float @llvm.experimental.constrained.acos.f32(float %x, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
194+
ret float %result
195+
}
196+
197+
define float @asin(float %x) #0 {
198+
; CHECK-LABEL: asin:
199+
; CHECK: # %bb.0:
200+
; CHECK-NEXT: subl $12, %esp
201+
; CHECK-NEXT: flds {{[0-9]+}}(%esp)
202+
; CHECK-NEXT: fstpl (%esp)
203+
; CHECK-NEXT: wait
204+
; CHECK-NEXT: calll _asin
205+
; CHECK-NEXT: fstps {{[0-9]+}}(%esp)
206+
; CHECK-NEXT: flds {{[0-9]+}}(%esp)
207+
; CHECK-NEXT: wait
208+
; CHECK-NEXT: addl $12, %esp
209+
; CHECK-NEXT: retl
210+
%result = call float @llvm.experimental.constrained.asin.f32(float %x, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
211+
ret float %result
212+
}
213+
214+
define float @atan(float %x) #0 {
215+
; CHECK-LABEL: atan:
216+
; CHECK: # %bb.0:
217+
; CHECK-NEXT: subl $12, %esp
218+
; CHECK-NEXT: flds {{[0-9]+}}(%esp)
219+
; CHECK-NEXT: fstpl (%esp)
220+
; CHECK-NEXT: wait
221+
; CHECK-NEXT: calll _atan
222+
; CHECK-NEXT: fstps {{[0-9]+}}(%esp)
223+
; CHECK-NEXT: flds {{[0-9]+}}(%esp)
224+
; CHECK-NEXT: wait
225+
; CHECK-NEXT: addl $12, %esp
226+
; CHECK-NEXT: retl
227+
%result = call float @llvm.experimental.constrained.atan.f32(float %x, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
228+
ret float %result
229+
}
230+
231+
define float @cosh(float %x) #0 {
232+
; CHECK-LABEL: cosh:
233+
; CHECK: # %bb.0:
234+
; CHECK-NEXT: subl $12, %esp
235+
; CHECK-NEXT: flds {{[0-9]+}}(%esp)
236+
; CHECK-NEXT: fstpl (%esp)
237+
; CHECK-NEXT: wait
238+
; CHECK-NEXT: calll _cosh
239+
; CHECK-NEXT: fstps {{[0-9]+}}(%esp)
240+
; CHECK-NEXT: flds {{[0-9]+}}(%esp)
241+
; CHECK-NEXT: wait
242+
; CHECK-NEXT: addl $12, %esp
243+
; CHECK-NEXT: retl
244+
%result = call float @llvm.experimental.constrained.cosh.f32(float %x, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
245+
ret float %result
246+
}
247+
248+
define float @sinh(float %x) #0 {
249+
; CHECK-LABEL: sinh:
250+
; CHECK: # %bb.0:
251+
; CHECK-NEXT: subl $12, %esp
252+
; CHECK-NEXT: flds {{[0-9]+}}(%esp)
253+
; CHECK-NEXT: fstpl (%esp)
254+
; CHECK-NEXT: wait
255+
; CHECK-NEXT: calll _sinh
256+
; CHECK-NEXT: fstps {{[0-9]+}}(%esp)
257+
; CHECK-NEXT: flds {{[0-9]+}}(%esp)
258+
; CHECK-NEXT: wait
259+
; CHECK-NEXT: addl $12, %esp
260+
; CHECK-NEXT: retl
261+
%result = call float @llvm.experimental.constrained.sinh.f32(float %x, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
262+
ret float %result
263+
}
264+
265+
define float @tanh(float %x) #0 {
266+
; CHECK: # %bb.0:
267+
; CHECK-NEXT: subl $12, %esp
268+
; CHECK-NEXT: flds {{[0-9]+}}(%esp)
269+
; CHECK-NEXT: fstpl (%esp)
270+
; CHECK-NEXT: wait
271+
; CHECK-NEXT: calll _tanh
272+
; CHECK-NEXT: fstps {{[0-9]+}}(%esp)
273+
; CHECK-NEXT: flds {{[0-9]+}}(%esp)
274+
; CHECK-NEXT: wait
275+
; CHECK-NEXT: addl $12, %esp
276+
; CHECK-NEXT: retl
277+
%result = call float @llvm.experimental.constrained.tanh.f32(float %x, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
278+
ret float %result
279+
}
280+
180281
attributes #0 = { strictfp }
181282

182283
declare float @llvm.experimental.constrained.ceil.f32(float, metadata)
@@ -189,3 +290,9 @@ declare float @llvm.experimental.constrained.log10.f32(float, metadata, metadata
189290
declare float @llvm.experimental.constrained.pow.f32(float, float, metadata, metadata)
190291
declare float @llvm.experimental.constrained.sin.f32(float, metadata, metadata)
191292
declare float @llvm.experimental.constrained.tan.f32(float, metadata, metadata)
293+
declare float @llvm.experimental.constrained.acos.f32(float, metadata, metadata)
294+
declare float @llvm.experimental.constrained.asin.f32(float, metadata, metadata)
295+
declare float @llvm.experimental.constrained.atan.f32(float, metadata, metadata)
296+
declare float @llvm.experimental.constrained.cosh.f32(float, metadata, metadata)
297+
declare float @llvm.experimental.constrained.sinh.f32(float, metadata, metadata)
298+
declare float @llvm.experimental.constrained.tanh.f32(float, metadata, metadata)

0 commit comments

Comments
 (0)