This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Fold abs(-x) -> abs(x)
ClosedPublic

Authored by craig.topper on Jul 31 2020, 4:05 PM.

Details

Summary

Negating the input doesn't matter. I left a FIXME to copy the nsw flag if its present on the neg but not on the abs.

Diff Detail

Event Timeline

craig.topper created this revision.Jul 31 2020, 4:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 31 2020, 4:05 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
craig.topper requested review of this revision.Jul 31 2020, 4:05 PM
nikic accepted this revision.Aug 1 2020, 1:09 AM

LG. I was wondering if we can use any of our more powerful negation machinery here, but I don't think so, because it would end up looping infinitely.

This revision is now accepted and ready to land.Aug 1 2020, 1:09 AM
This revision was automatically updated to reflect the committed changes.