Closed Quuxplusone closed 4 years ago
Attached pkhbt.ll
(193 bytes, text/plain): Reproducer
The SelectionDAG code for this is a bit odd. I'm surprised that and/or are covered by special cases but xor isn't. It's also surprising that always-true predicates and powers of 2 (including 0x80000000) prevent the special case.
It sounds like the right thing to do is to only check the bits that are actually present in the LLT (similar to SelectionDAG's use of APInt). In this case, the 0xffff0000 and the s32 type should be treated as check for (X & 0xffffffff) == (0xffff0000 & 0xffffffff). We should probably have a warning if the pattern uses a constant that isn't an extension like 0x1000ffff with s16.
I'll take a look at the reproducer
I've looked into it a bit more and I've ended up fixing it by sign-extending the table value to match the sign-extension that getConstantVRegVal() will perform.
pkhbt.ll
(193 bytes, text/plain)