[PATCH] D14045: [SimplifyLibCalls] Add a new transform: pow(exp(x), y) -> exp(x*y)

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 3 10:56:55 PST 2015


majnemer accepted this revision.
majnemer added a comment.
This revision is now accepted and ready to land.

LGTM once the tests have been cleaned up.


================
Comment at: test/Transforms/InstCombine/pow-exp2.ll:3-14
@@ +2,14 @@
+
+define double @mypow(double %x, double %y) #0 {
+entry:
+  %x.addr = alloca double, align 8
+  %y.addr = alloca double, align 8
+  store double %x, double* %x.addr, align 8
+  store double %y, double* %y.addr, align 8
+  %0 = load double, double* %x.addr, align 8
+  %call = call double @exp2(double %0) #2
+  %1 = load double, double* %y.addr, align 8
+  %2 = call double @llvm.pow.f64(double %call, double %1)
+  ret double %2
+}
+
----------------
Please simplify this test case, you don't need the `alloca`/`store`/`load` sequence.  I believe the following should work:
  define double @mypow(double %x, double %y) #0 {
  entry:
    %call = call double @exp2(double %x) #2
    %pow = call double @llvm.pow.f64(double %call, double %y)
    ret double %pow
  }

================
Comment at: test/Transforms/InstCombine/pow-exp2.ll:10
@@ +9,3 @@
+  %0 = load double, double* %x.addr, align 8
+  %call = call double @exp2(double %0) #2
+  %1 = load double, double* %y.addr, align 8
----------------
You don't define attribute `#2`, please remove this reference to it.

================
Comment at: test/Transforms/InstCombine/pow-exp2.ll:17
@@ +16,3 @@
+declare double @exp2(double) #1
+declare double @llvm.pow.f64(double, double) #2
+attributes #0 = { "unsafe-fp-math"="true" }
----------------
You don't define attribute `#2`, please remove it.

================
Comment at: test/Transforms/InstCombine/pow-exp2.ll:20-26
@@ +19,8 @@
+attributes #1 = { "unsafe-fp-math"="true" }
+
+; CHECK: define double @mypow(double %x, double %y) #0 {
+; CHECK: entry:
+; CHECK:   %mul = fmul fast double %x, %y
+; CHECK:   %exp2 = call double @exp2(double %mul) #0
+; CHECK:   ret double %exp2
+; CHECK: }
----------------
Please move these check directives immediately after the function.

================
Comment at: test/Transforms/InstCombine/pow-exp2.ll:21
@@ +20,3 @@
+
+; CHECK: define double @mypow(double %x, double %y) #0 {
+; CHECK: entry:
----------------
I would use the following:
  ; CHECK-LABEL: define double @mypow(

================
Comment at: test/Transforms/InstCombine/pow-exp2.ll:22
@@ +21,3 @@
+; CHECK: define double @mypow(double %x, double %y) #0 {
+; CHECK: entry:
+; CHECK:   %mul = fmul fast double %x, %y
----------------
This check line is a little superfluous.


http://reviews.llvm.org/D14045





More information about the llvm-commits mailing list