Given pattern:
icmp eq/ne (and ((x shift Q), (y oppositeshift K))), 0
we should move shifts to the same hand of 'and', i.e. rewrite as
icmp eq/ne (and (x shift (Q+K)), y), 0 iff (Q+K) u< bitwidth(x)
It might be tempting to not restrict this to situations where we know
we'd fold two shifts together, but i'm not sure what rules should there be
to avoid endless combine loops.
We pick the same shift that was originally used to shift the variable we picked to shift:
https://rise4fun.com/Alive/6x1v
Should fix PR42399.
This would be easier to read for me if we did the simple icmp checks first:
And then do a mega-match on only I.getOperand(0).
...although that match raises a question if the one-use checks are balanced:
Do we prefer to shift left or right?
https://rise4fun.com/Alive/