This is an archive of the discontinued LLVM Phabricator instance.

DAG: Fix incorrect folding of fmul -1 to fneg
ClosedPublic

Authored by arsenm on Sep 8 2021, 9:05 AM.

Details

Summary

The fmul is a canonicalizing operation, and fneg is not so this would
break denormals that need flushing and also would not quiet signaling
nans.

Diff Detail

Event Timeline

arsenm created this revision.Sep 8 2021, 9:05 AM
arsenm requested review of this revision.Sep 8 2021, 9:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 8 2021, 9:05 AM
Herald added a subscriber: wdng. · View Herald Transcript

I think we can fold (fmul X, -1.0) -> (fsub -0.0, X) unconditionally; at least, Alive2 is happy with it. If we can do that, we can just let the existing fsub code figure out the rest. Does that sound like a plan?

I think we can fold (fmul X, -1.0) -> (fsub -0.0, X) unconditionally; at least, Alive2 is happy with it. If we can do that, we can just let the existing fsub code figure out the rest. Does that sound like a plan?

That works (although is a code size regression for AMDGPU). We have other combines like this that we have to undo later for this reason anyway

arsenm updated this revision to Diff 372280.Sep 13 2021, 9:31 AM

Use fsub instead

This revision is now accepted and ready to land.Sep 13 2021, 11:16 AM