[PATCH] D28479: [SimplifyLibCalls] pow(x, -0.5) -> 1.0 / sqrt(x)

Davide Italiano via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 9 13:52:14 PST 2017


davide added a subscriber: hfinkel.
davide added inline comments.


================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:1084-1085
+
+      // Here we cannot lower to an intrinsic because C99 sqrt() and llvm.sqrt
+      // are not guaranteed to have the same semantics.
+      Value *Sqrt = emitUnaryFloatFnCall(Op1, TLI->getName(LibFunc::sqrt), B,
----------------
majnemer wrote:
> Doesn't hasUsnafeAlgebra make this irrelevant?
Does it? I'm not entirely sure of the implications, see e.g. http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20160808/380416.html @hfinkel 
(I'd leave the lowering to an intrinsic as a follow-up).


================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:1089
+
+      return B.CreateFDiv(ConstantFP::get(CI->getType(), 1.0), Sqrt, "sqrtrecip");
+    }
----------------
efriedma wrote:
> Missing fast-math flags on sqrt() call and fdiv instruction.
Fixed, my bad.


https://reviews.llvm.org/D28479





More information about the llvm-commits mailing list