[PATCH] D28405: SimplifyLibCalls: Replace fabs libcalls with intrinsics

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 16 13:49:00 PST 2017

efriedma added inline comments.

Comment at: test/Transforms/InstCombine/fabs.ll:16
 ; CHECK-NEXT: %mul = fmul float %x, %x
-; CHECK-NEXT: %fabsf = tail call float @fabsf(float %mul)
+; CHECK-NEXT: %fabsf = call float @llvm.fabs.f32(float %mul)
 ; CHECK-NEXT: ret float %fabsf
arsenm wrote:
> efriedma wrote:
> > arsenm wrote:
> > > arsenm wrote:
> > > > efriedma wrote:
> > > > > efriedma wrote:
> > > > > > This is probably going to fail on Windows... maybe change the test to call llvm.fabs rather than fabs?
> > > > > Still probably going to fail on Windows, where fabsf() doesn't exist.
> > > > Do you mean the intrinsic won't work? I would expect codegen to promote it
> > > It looks like a fabs instruction is emitted for the intrinsic
> > No... I mean we call `TLI.setUnavailable(LibFunc::fabsf);` on Windows, so it isn't a library call, so we'll never call optimizeFabs.
> I thought the intent there was to not recognize fabsf as a special builtin function since it isn't available, i.e. fabsf could be a user function
Yes, that's working as intended; the only problem is that you didn't specify a triple for this test, so it will inherit the triple from the host, therefore on a Windows host the CHECK line won't match.


More information about the llvm-commits mailing list