This is the motivate case:
define i32 @foo1(i32 %x) { entry: %and = and i32 %x, -2 ret i32 %and }
PowerPC has several mechanism(tryBitPermutation() and custom select for AND/OR etc) to generate the bit operation better with the combination of AND/OR/XOR etc. This case isn't handled by these mechanism. So, I added a match pattern in the td to do the final selection, though, technical speaking, we could extend those mechanism to handle this case also.
Does (and i32:$in, maskimm32:$imm) also work?