This is an archive of the discontinued LLVM Phabricator instance.

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

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

Details

Summary

There are a variety of cases we can simplify either saving
instructions are creating sequences that are easier to optimize
elsewhere.

(X ^ Y) u> X --> X & MSB(Y) == 0

(X ^ Y) u< X --> X & MSB(Y) != 0

(X ^ Pos_Y) s> X --> X & MSB(Pow2_Y) == 0

(X ^ Pos_Y) s< X --> X & MSB(Pow2_Y) != 0

(X ^ Neg_Y) s> X --> X s< 0

(X ^ Neg_Y) s< X --> X s>= 0

Diff Detail

Event Timeline

goldstein.w.n created this revision.Mar 3 2023, 3:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 3 2023, 3:55 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
goldstein.w.n requested review of this revision.Mar 3 2023, 3:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 3 2023, 3:55 PM
nikic added a comment.Mar 9 2023, 12:19 PM

Is there any real-world motivation for these xor transforms (and also the signed predicate variants in this patch stack)? If not, I'm not sure this is worthwhile.

Is there any real-world motivation for these xor transforms (and also the signed predicate variants in this patch stack)? If not, I'm not sure this is worthwhile.

None handy, but doesn't seem like unreasonably obscure codes. You think this is unreasonably unlikely?