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

Mandeep Singh Grang via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 18 12:42:38 PST 2015


mgrang updated this revision to Diff 40539.
mgrang added a comment.

Thanks for the suggestions everyone.

I have now implemented Addition-Chains using recursion with memoization. The result being that we do not need to generate extraneous instructions.

Here is an example:

7 --> (2, 5) --> (2, (2, 3)) --> (2, (2, (1, 2)))

We now generate instructions for only the intermediate products needed by our exponent. Storing the results at each step saves us repetitive  recursive calls.

I have also addressed David's comments in this patch (added an assertion for Exp!=0 and removed check-prefix from the test case).

Please let me know your thoughts on this.


http://reviews.llvm.org/D13994

Files:
  lib/Transforms/Utils/SimplifyLibCalls.cpp
  test/Transforms/InstCombine/pow-4.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13994.40539.patch
Type: text/x-patch
Size: 7053 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151118/697ac2e1/attachment.bin>


More information about the llvm-commits mailing list