This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Fold (A & 2^C1) + A => A & (2^C1 - 1) iff bit C1 in A is a sign bit (PR21929)
ClosedPublic

Authored by RKSimon on Apr 8 2022, 3:05 AM.

Diff Detail

Event Timeline

RKSimon created this revision.Apr 8 2022, 3:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 8 2022, 3:05 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
RKSimon requested review of this revision.Apr 8 2022, 3:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 8 2022, 3:05 AM
nikic added a comment.Apr 11 2022, 4:20 AM

Can you please add some explicit tests for the actual pattern being folded? I don't think you're testing the commuted case currently, as well as some of the pre-conditions (like the fact that the and must be a power of two).

RKSimon updated this revision to Diff 423364.Apr 18 2022, 5:28 AM

rebase with additional tests

nikic added a comment.Apr 21 2022, 4:16 AM

Unless I overlooked it, I think this is still missing a test with a non-pow2 mask.

RKSimon updated this revision to Diff 424213.Apr 21 2022, 8:50 AM

rebase now that we have a (negative) non-pow2 test

nikic accepted this revision.Apr 22 2022, 3:18 AM

LGTM

This revision is now accepted and ready to land.Apr 22 2022, 3:18 AM