[PATCH] D15937: [LibCallSimplifier] use instruction-level fast-math-flags to transform sqrt calls

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 11 11:08:40 PST 2016


spatel added inline comments.

================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:1425
@@ -1423,2 +1424,3 @@
     Value *OtherMul0, *OtherMul1;
+    // FIXME: This multiply must be unsafe to allow this transform.
     if (match(Op0, m_FMul(m_Value(OtherMul0), m_Value(OtherMul1)))) {
----------------
davide wrote:
> I think you're correct that if any of the ops is strict we should bail out, and your code is fine. Have you checked by any chance what GCC does? Steven Canon might have some more opinions on this.
Based on:
https://gcc.godbolt.org/

I don't think GCC has this optimization. It only matches the simpler case of "sqrt(x * x)".

================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:1442
@@ -1441,2 +1441,3 @@
   B.SetFastMathFlags(I->getFastMathFlags());
+
   // If we found a repeated factor, hoist it out of the square root and
----------------
davide wrote:
> davide wrote:
> > Spurious blank linke.
> Oh I think this one makes sense but please commit the style fix separately.
Will do.

Thanks for the review!


http://reviews.llvm.org/D15937





More information about the llvm-commits mailing list