This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] fold fneg into constant operand of fmul/fdiv
ClosedPublic

Authored by spatel on Aug 7 2018, 4:29 PM.

Details

Summary

I think this is the missing IR fold noted in D50195, but AFAICT, we don't need any fast-math to enable the transform. FP negation can always be folded into an fmul/fdiv constant to eliminate the fneg.

I've limited this to one-use to ensure that we are eliminating an instruction rather than replacing fneg by a potentially expensive fdiv or fmul.

Diff Detail

Repository
rL LLVM

Event Timeline

spatel created this revision.Aug 7 2018, 4:29 PM

Looked it over in detail, the transformations all track.
LGTM, up to you if you want second set of eyes.

spatel accepted this revision.Aug 8 2018, 7:28 AM

Marking as accepted here on Phab to avoid unknown state when committing.

This revision is now accepted and ready to land.Aug 8 2018, 7:28 AM
This revision was automatically updated to reflect the committed changes.