This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Fold icmp x, ~x and icmp ~x, x by testing the sign
Needs ReviewPublic

Authored by tianz on Sep 5 2022, 3:47 PM.

Details

Reviewers
spatel
RKSimon
Summary

[InstCombine] Fold icmp x, ~x and icmp ~x, x by testing the sign

Fixes #57532.

Examples:
https://alive2.llvm.org/ce/z/XBj9Pf
https://alive2.llvm.org/ce/z/UNkucP

Diff Detail

Event Timeline

tianz created this revision.Sep 5 2022, 3:47 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 5 2022, 3:47 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
tianz requested review of this revision.Sep 5 2022, 3:47 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 5 2022, 3:47 PM
RKSimon added a subscriber: RKSimon.
RKSimon added inline comments.
llvm/test/Transforms/InstCombine/icmp-not.ll
8

please don't enumerate tests - chose a name that describes the pattern + any specific constant you're using

tianz updated this revision to Diff 463421.Sep 27 2022, 10:32 PM

Updated the tests according to review comment

The predicate check is too restrictive. We can handle unsigned preds too:
https://alive2.llvm.org/ce/z/s38fNL