This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Generalize (icmp sgt (1 << Y), -1) -> (icmp ne Y, BitWidth-1) to any negative constant.
ClosedPublic

Authored by craig.topper on Jan 14 2023, 11:44 AM.

Details

Summary

Similar for the sle version which will be canonicalized to slt first.

Alive2 proof as implemented: https://alive2.llvm.org/ce/z/_YawdM

@spatel's original Alive2: https://alive2.llvm.org/ce/z/3YB2vs

Diff Detail

Event Timeline

craig.topper created this revision.Jan 14 2023, 11:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 14 2023, 11:44 AM
craig.topper requested review of this revision.Jan 14 2023, 11:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 14 2023, 11:44 AM
lebedev.ri added inline comments.Jan 14 2023, 6:10 PM
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
2051

Nitpick: either change the proof to check *this* precondition, or use the same check as in the proof.

2057–2058

Same nitpick. Not what the proof shows.

(or, well, just post two proofs)

craig.topper edited the summary of this revision. (Show Details)Jan 14 2023, 6:28 PM

(or, well, just post two proofs)

I've added new proofs for the version as implemented.

lebedev.ri accepted this revision.Jan 15 2023, 4:55 AM

https://alive2.llvm.org/ce/z/ynf5JE
LG, thank you.

I suspect, there should be a generalization for non-negative constants, too.

This revision is now accepted and ready to land.Jan 15 2023, 4:55 AM
This revision was landed with ongoing or failed builds.Jan 15 2023, 1:43 PM
This revision was automatically updated to reflect the committed changes.