This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Add transforms for `(icmp spred (or X, Y), X)`
Needs ReviewPublic

Authored by goldstein.w.n on Mar 3 2023, 3:57 PM.

Details

Summary

If we know the sign of Y or the value of Y we can either evaluate or
simplify the condition.

icmp (X | MinInt) s> X --> false

icmp (X | MinInt) s<= X --> true

icmp (X | MinInt) s>= X --> X s< 0

icmp (X | MinInt) s< X --> X s>= 0

icmp (X | Pos_Y) s> X --> (X | Pos_Y) != X

icmp (X | Pos_Y) s<= X --> (X | Pos_Y) == X

Diff Detail

Event Timeline

goldstein.w.n created this revision.Mar 3 2023, 3:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 3 2023, 3:57 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
goldstein.w.n requested review of this revision.Mar 3 2023, 3:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 3 2023, 3:57 PM
goldstein.w.n retitled this revision from [InstCombine] Add transforms for `(icmp spred (xor X, Y), X)` to [InstCombine] Add transforms for `(icmp spred (or X, Y), X)`.Mar 3 2023, 4:02 PM
RKSimon added a subscriber: RKSimon.
RKSimon added inline comments.
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
4137

Maybe move this into the if() to reduce scope

if (auto KnownSign = getKnownSign(A, &I, Q.DL, Q.AC, Q.DT))