Sequence of same shift instructions with constant operands can be combined into
a single shift instruction.
Change to assert().
I don't think Shl2Def can ever be null here, can it?
"Imm" instead of "MatchInfo.Imm"
Logically you want the size of the first operand here, not the size of the immediate. I'm not sure if they are guaranteed to be the same.
Sorry, I was wrong about G_USHLSAT. You can't handle it quite the same way as G_ASHR. With 8-bit ints:
If the combined shift amount for ushlsat is >= 8 then you could replace it with "x == 0 ? 0 : 0xff" but it's probably not worth doing this.
I think you mean "saturating signed or unsigned left shift" here.
But this does not work for saturating unsigned left shift. There is no good replacement for "x ushlsat 20 ushlsat 25" where 20 + 25 exceeds the width of the type. I suggest catching this case in the match func and returning false.