This is an archive of the discontinued LLVM Phabricator instance.

In finite-only mode, transform pow(x, 0.5) directly to fabs(sqrt(x)).
AbandonedPublic

Authored by davide on Feb 2 2016, 5:36 PM.

Details

Summary

This patch implements a TODO.

Currently, the expansion of pow(x, 0.5) always checks for + and - infinity. Instead if x is finite, we could simply transform it to fabs(sqrt(x)).

Patch by Mandeep Singh Grang.

Diff Detail

Event Timeline

mgrang updated this revision to Diff 46728.Feb 2 2016, 5:36 PM
mgrang retitled this revision from to In finite-only mode, transform pow(x, 0.5) directly to fabs(sqrt(x))..
mgrang updated this object.
mgrang added reviewers: joerg, majnemer, davide, escha, scanon.
mgrang added a subscriber: weimingz.
weimingz added inline comments.Feb 2 2016, 6:09 PM
lib/Transforms/Utils/SimplifyLibCalls.cpp
1245

you are checking the op1, which is the 2nd parameter (e.g. 0.5), but the comments says "If x is finite".

majnemer requested changes to this revision.Feb 2 2016, 8:10 PM
majnemer edited edge metadata.

This change has no tests.

This revision now requires changes to proceed.Feb 2 2016, 8:10 PM
mgrang added inline comments.Feb 3 2016, 10:57 AM
lib/Transforms/Utils/SimplifyLibCalls.cpp
1245

Weimingz, Op1 is the first parameter and Op2 is the second. Look at lines 1180 and 1229:

if (Op1C->isExactlyValue(1.0)) // pow(1.0, x) -> 1.0

if (Op2C->getValueAPF().isZero()) // pow(x, 0.0) -> 1.0

davide edited edge metadata.Jun 9 2016, 8:51 AM

Are you still planning to work on this? Thanks, --Davide

Hi Davide,

I got busy with other work so did not get time to look into it.
Please feel free to work on this.

Thanks,
Mandeep

lib/Transforms/Utils/SimplifyLibCalls.cpp
1245

Also :

Value *Op1 = CI->getArgOperand(0), *Op2 = CI->getArgOperand(1);

davide accepted this revision.Jul 7 2016, 11:39 AM
davide edited edge metadata.

Continuing somewhere else

davide commandeered this revision.Jul 7 2016, 11:40 AM
davide edited reviewers, added: mgrang; removed: davide.

Continuing somewhere else

davide abandoned this revision.Jul 7 2016, 11:40 AM