[llvm] [AArch64] Combine signext_inreg of setcc(... != splat(0)) (PR #157665)
Hari Limaye via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 10 02:08:55 PDT 2025
================
@@ -26097,6 +26097,17 @@ static SDValue performSetCCPunpkCombine(SDNode *N, SelectionDAG &DAG) {
return SDValue();
}
+static bool isSignExtInReg(const SDValue &V) {
+ if (V.getOpcode() != AArch64ISD::VASHR ||
----------------
hazzlim wrote:
So my original approach was to match the `SIGN_EXTEND_INREG` itself, rather than the expansion, as you suggest. The issue here seems to be that for some/most of the cases this is not sufficient to trigger the transformation. In the `@llvm.experimental.cttz.elts` tests this works as you show above, but for example in the `@llvm.masked.load` casees we expand the sign_extend_inreg node BEFORE we expand the masked_load node, so the pattern we're trying to match doesn't exist:
```
Vector/type-legalized selection DAG: %bb.0 'do_masked_load:'
SelectionDAG has 15 nodes:
t0: ch,glue = EntryToken
t2: i64,ch = CopyFromReg t0, Register:i64 %0
t4: v16i8,ch = CopyFromReg t0, Register:v16i8 %1
t21: v16i8 = AArch64ISD::VSHL t4, Constant:i32<7>
t22: v16i8 = AArch64ISD::VASHR t21, Constant:i32<7>
t7: v16i8 = BUILD_VECTOR Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Con
stant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>
t9: v16i8,ch = masked_load<(load unknown-size from %ir.src, align 8)> t0, t2, undef:i64, t22, t7
t11: ch,glue = CopyToReg t0, Register:v16i8 $q0, t9
t12: ch = AArch64ISD::RET_GLUE t11, Register:v16i8 $q0, t11:1
```
It seemed like matching the expansion of the `SIGN_EXTEND_INREG` made the most sense to catch all the cases, but maybe there's an alternative approach I'm not seeing that would still allow us to match the `SIGN_EXTEND_INREG` ?
https://github.com/llvm/llvm-project/pull/157665
More information about the llvm-commits
mailing list