[PATCH] D50113: [SLC] Fix shrinking of pow()

Evandro Menezes via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 31 15:21:24 PDT 2018


evandro created this revision.
evandro added reviewers: spatel, efriedma.
Herald added subscribers: llvm-commits, hiraditya.

Properly shrink `pow()` as a binary function.


Repository:
  rL LLVM

https://reviews.llvm.org/D50113

Files:
  llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
  llvm/test/Transforms/InstCombine/double-float-shrink-1.ll


Index: llvm/test/Transforms/InstCombine/double-float-shrink-1.ll
===================================================================
--- llvm/test/Transforms/InstCombine/double-float-shrink-1.ll
+++ llvm/test/Transforms/InstCombine/double-float-shrink-1.ll
@@ -344,11 +344,9 @@
   ret double %call
 }
 
-; FIXME: Miscompile - we dropped the 2nd argument!
-
 define float @pow_test1(float %f, float %g)   {
 ; CHECK-LABEL: @pow_test1(
-; CHECK-NEXT:    [[POWF:%.*]] = call fast float @powf(float [[F:%.*]])
+; CHECK-NEXT:    [[POWF:%.*]] = call fast float @powf(float [[F:%.*]], float [[G:%.*]])
 ; CHECK-NEXT:    ret float [[POWF]]
 ;
   %df = fpext float %f to double
@@ -358,14 +356,11 @@
   ret float %fr
 }
 
-; TODO: This should shrink?
-
 define double @pow_test2(float %f, float %g) {
 ; CHECK-LABEL: @pow_test2(
-; CHECK-NEXT:    [[DF:%.*]] = fpext float [[F:%.*]] to double
-; CHECK-NEXT:    [[DG:%.*]] = fpext float [[G:%.*]] to double
-; CHECK-NEXT:    [[CALL:%.*]] = call fast double @pow(double [[DF]], double [[DG]])
-; CHECK-NEXT:    ret double [[CALL]]
+; CHECK-NEXT:    [[POWF:%.*]] = call fast float @powf(float [[F:%.*]], float [[G:%.*]])
+; CHECK-NEXT:    [[TMP1:%.*]] = fpext float [[POWF]] to double
+; CHECK-NEXT:    ret double [[TMP1]]
 ;
   %df = fpext float %f to double
   %dg = fpext float %g to double
Index: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
===================================================================
--- llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -1169,7 +1169,7 @@
 
   if (UnsafeFPShrink &&
       Name == TLI->getName(LibFunc_pow) && hasFloatVersion(Name))
-    Shrunk = optimizeUnaryDoubleFP(Pow, B, true);
+    Shrunk = optimizeBinaryDoubleFP(Pow, B);
 
   // Propagate the math semantics from the call to any created instructions.
   IRBuilder<>::FastMathFlagGuard Guard(B);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50113.158403.patch
Type: text/x-patch
Size: 1892 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180731/f3c8d4b5/attachment.bin>


More information about the llvm-commits mailing list