The code change is hopefully straightforward: replace dyn_casts with m_APInt, and we get transforms for splat vectors.
But these transforms raise some questions:
- In the cases where we need a 'not', we're increasing the instruction count. Is this justified because ext/not is always assumed cheaper/more canonical than a select?
- In the not+zext case, notice that the zext gets moved ahead of the xor. This is because visitZext() has: // zext (xor i1 X, true) to i32 --> xor (zext i1 X to i32), 1
There's no code comment for the motivation. Assuming there is good reason to break the m_Not pattern should sext+xor do the same?
- If we're ok with increasing the instruction count for #1, is the scalar select of vectors example also a good transform? In the worst case, we'd need 4 instructions in place of the select: xor, zext, insertelement, shufflevector.