If the truncation has been pushed past the or-node, look through it and truncate afterwards.
LGTM, though it'd be interesting to see if there's any other cases where (FOO (ROTATE pattern) [...]) gets torn apart besides FOO == truncate.
Yup, there's likely something more general that we could match, but it's also worth taking this as is.
Do you need to check that LHS.getOperand(0).getValueType() == RHS.getOperand(0).getValueType()?
Sorry, just hit commit before I saw this. You're right, I need to check that.