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

Joerg Sonnenberger via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 9 14:52:01 PST 2015


On Mon, Nov 09, 2015 at 10:12:39PM +0000, Mandeep Singh Grang wrote:
> mgrang marked an inline comment as done.
> mgrang added a comment.
> 
> I have limited the transformation to a max of 8 fmuls (thus max exponent=32).
> 
> Using addition-chains can reduce the no. of fmuls in few cases but storing the addition-chains for each exponent will incur space overhead.
> The current implementation of exponentiation by binary expansion seems much cleaner IMO.

With a limit of 8 fmuls, the number of additional registers should be
quite low, even in the worst case. The addition chains themselve can be
precomputed with a focus on minimizing the the number of multiplications
first and storage second.

Joerg


More information about the llvm-commits mailing list