This is an archive of the discontinued LLVM Phabricator instance.

[SimplifyLibCalls] Tranform log(pow(x, y)) -> y*log(x)
ClosedPublic

Authored by davide on Nov 5 2015, 3:42 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

davide updated this revision to Diff 39430.Nov 5 2015, 3:42 PM
davide retitled this revision from to [SimplifyLibCalls] Tranform log(pow(x, y)) -> y*log(x).
davide updated this object.
davide added reviewers: majnemer, scanon, escha, resistor.
davide added a subscriber: llvm-commits.
scanon edited edge metadata.Nov 5 2015, 3:44 PM

Seems reasonable from a mathematical perspective.

scanon added a comment.Nov 5 2015, 3:48 PM

The one thing that's a little bit weird here is cases like x = -1, y = 4; log(pow(-1, 4)) is 0, but 4*log(-1) is NaN. That's a dramatic difference even for fast-math. Do we find exact integer exponents before we get to this point?

davide updated this revision to Diff 39442.Nov 5 2015, 4:16 PM
davide edited edge metadata.

Fix inverted logic.

davide added a comment.Nov 5 2015, 4:17 PM

The one thing that's a little bit weird here is cases like x = -1, y = 4; log(pow(-1, 4)) is 0, but 4*log(-1) is NaN. That's a dramatic difference even for fast-math. Do we find exact integer exponents before we get to this point?

Yes, that's a little bit unfortunate. I don't think we find exact exponents before we get to this point. Do you think it's a showstopper to get this patch into the tree? By the way, I also noticed gcc produces the same very ouput on your testcase, for what it's worth.

majnemer accepted this revision.Nov 27 2015, 6:45 PM
majnemer edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Nov 27 2015, 6:45 PM
This revision was automatically updated to reflect the committed changes.