This is an archive of the discontinued LLVM Phabricator instance.

InstCombine: Recognize fneg(fabs) as bitcasted integer
ClosedPublic

Authored by arsenm on Jun 1 2023, 2:10 PM.

Details

Summary

Technically increases the number of instructions if the
result isn't cast back to float. Even in this case it's
still probably a better canonical form since it enables FP value
tracking.

Diff Detail

Event Timeline

arsenm created this revision.Jun 1 2023, 2:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 1 2023, 2:10 PM
arsenm requested review of this revision.Jun 1 2023, 2:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 1 2023, 2:10 PM
Herald added a subscriber: wdng. · View Herald Transcript
arsenm updated this revision to Diff 554781.Aug 30 2023, 10:48 AM

Check noimplicitfloat

This doesn't really feel more canonical if we don't cast back.
I'd argue if we don't cast back we are probably about to analyze some integer operations
in which case or is more useful/recognizable than fneg/fabs.

That being said it seems we don't any of the bitwise abs/neg ops even with the
complete roundtrip: https://godbolt.org/z/Wrje68hq1
and completely support patches to handle that.

This revision is now accepted and ready to land.Aug 31 2023, 3:16 PM

This doesn't really feel more canonical if we don't cast back.
I'd argue if we don't cast back we are probably about to analyze some integer operations
in which case or is more useful/recognizable than fneg/fabs.

If the integer was useful to downstream users, whatever it could have been should have happened already