This is an archive of the discontinued LLVM Phabricator instance.

SimplifyLibCalls: Remove incorrect optimization of fabs
ClosedPublic

Authored by arsenm on Jan 5 2017, 9:48 AM.

Details

Reviewers
scanon
efriedma
Summary

fabs(x * x) is not generally safe to assume x is positive if x is a NaN.
This is also less general than it could be, so this will be replaced
with a transformation on the intrinsic.

Diff Detail

Event Timeline

arsenm updated this revision to Diff 83268.Jan 5 2017, 9:48 AM
arsenm retitled this revision from to SimplifyLibCalls: Remove incorrect optimization of fabs.
arsenm updated this object.
arsenm added reviewers: scanon, efriedma.
arsenm added a subscriber: llvm-commits.
efriedma accepted this revision.Jan 5 2017, 10:08 AM
efriedma edited edge metadata.

You might want to put a comment in the tests briefly noting the problem with this transformation.

I think this transform is safe if the @llvm.fabs call is marked nnan, but I'm sure you already have some plan for that.

This revision is now accepted and ready to land.Jan 5 2017, 10:08 AM
majnemer added inline comments.
lib/Transforms/Utils/SimplifyLibCalls.cpp
1200

Couldn't this stay if the fmul is marked as nnan?

arsenm added inline comments.Jan 6 2017, 11:45 AM
lib/Transforms/Utils/SimplifyLibCalls.cpp
1200

Yes, but I want to move this to an optimization on the intrinsic

arsenm closed this revision.Jan 7 2017, 12:06 PM

r291359