[PATCH] D13994: Optimization for pow(x, n) where n is some constant

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 22 17:41:53 PDT 2015


majnemer added a comment.

Please upload a diff with more context.


================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:1065
@@ -1059,1 +1064,3 @@
 
+static Value *getPow(Value* Op1, int Exp, IRBuilder<> &B) {
+  Value *Val = Op1, *FMul = nullptr, *PrevVal = nullptr;
----------------
Pointers go on the right side.  Why is `Exp` signed?

================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:1069
@@ +1068,3 @@
+  while (Exp) {
+    // the idea here is that: x^(2^i) = x^(2^(i/2)) * x^(2^(i/2)).
+    if (PrevVal)
----------------
Sentences start with an upper case letter.

================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:1077
@@ +1076,3 @@
+    PrevVal = Val;
+    Exp = Exp >> 1;
+  }
----------------
Please don't strength reduce manually.


Repository:
  rL LLVM

http://reviews.llvm.org/D13994





More information about the llvm-commits mailing list