[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 18:45:12 PDT 2015


majnemer added inline comments.

================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:1077
@@ +1076,3 @@
+    PrevVal = Val;
+    Exp = Exp >> 1;
+  }
----------------
mgrang wrote:
> majnemer wrote:
> > mgrang wrote:
> > > majnemer wrote:
> > > > Please don't strength reduce manually.
> > > Can you please clarify what do you mean by "don't strength reduce manually".
> > Unless I am mistaken, you can rewrite that expression as `Exp / 2`.
> Yes, I can rewrite that as Exp / 2 but wouldn't that be slower than Exp >> 1 since the former case would involve generating a div instruction?
I would recommend against premature optimization.


Repository:
  rL LLVM

http://reviews.llvm.org/D13994





More information about the llvm-commits mailing list