(or (icmp eq X, 0), (icmp eq X, Pow2OrZero))
> `(icmp eq (and X, Pow2OrZero), X)`
(and (icmp ne X, 0), (icmp ne X, Pow2OrZero))
> `(icmp ne (and X, Pow2OrZero), X)`
Differential D157312
[InstCombine] Add transforms for `(or/and (icmp eq/ne X,0),(icmp eq/ne X,Pow2OrZero))` goldstein.w.n on Aug 7 2023, 10:50 AM. Authored by
Details (or (icmp eq X, 0), (icmp eq X, Pow2OrZero)) > `(icmp eq (and X, Pow2OrZero), X)` (and (icmp ne X, 0), (icmp ne X, Pow2OrZero)) > `(icmp ne (and X, Pow2OrZero), X)`
Diff Detail
Event Timeline
Comment Actions Not sure we should do this transform in IR. The original form seems to be a lot simpler to reason about than the new one  e.g. if you have that as condition, it's obvious that %x can't be zero (as there's an explicit check for it). Afterwards, that would be fairly hard to determine. Comment Actions Really? We have a fair amount of logic for X & Y eq/ne ... and we do this fold already for constants (and similiar folds for nonconstants). Comment Actions For constants this is turned into an X & ~C eq 0 or X & ~C ne 0 pattern. That is well understood due to the obvious KnownBits implications. X & Y == X not so much I think. Comment Actions Okay, let's give this a try.
