[PATCH] D41940: [InstSimplify] Missed optimization in math expression: log10(pow(10.0, x)) == x, log2(pow(2.0, x)) == x

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 31 06:09:16 PST 2019


spatel accepted this revision.
spatel added a comment.

In D41940#1378426 <https://reviews.llvm.org/D41940#1378426>, @Quolyk wrote:

> In D41940#1378402 <https://reviews.llvm.org/D41940#1378402>, @lebedev.ri wrote:
>
> > LG unless others have more comments (@spatel ?)
> >  You probably know this already, but there are some other low-hanging fruit here, e.g.
> >  https://godbolt.org/z/Trdf_e
> >  https://www.wolframalpha.com/input/?i=log2(x)+%2F+log2(10)+%3D+log10(x)
>
>
> Thanks, I'll dive into it. Btw, `pow(2.0, x)` --> `exp2(x)` is already implemented, see https://godbolt.org/z/UADcWe.


If you're interested in math call transforms, you might also want to look at:
https://bugs.llvm.org/show_bug.cgi?id=40541

One more comment: 'reassoc' is generally enough to go crazy with FP, but we might also want to require 'nsz' on this and related transforms to be safer because:
x = -0.0
exp2(x) = 1.0
log2(exp2(x)) = 0.0 <-- output flipped sign from input


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D41940/new/

https://reviews.llvm.org/D41940





More information about the llvm-commits mailing list