[llvm] [AArch64] Fold vector select with power-of-2 bit-test to CMTST+BSP (PR #209100)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 3 05:49:25 PDT 2026
================
@@ -29067,6 +29089,17 @@ static SDValue performSETCCCombine(SDNode *N,
SplatLHSVal.isOne())
return DAG.getSetCC(DL, VT, DAG.getConstant(0, DL, CmpVT), RHS, ISD::SETGE);
+ // Fold setcc(and(X, Y), 0, seteq) --> NOT(AArch64ISD::CMTST(X, Y))
+ // after DAG legalization. SETNE will have been legalized to SETEQ by now.
+ // The NOT folds away when the result feeds a BSP.
+ if (DCI.isAfterLegalizeDAG() && CmpVT.isFixedLengthVector() &&
+ Cond == ISD::SETEQ && LHS.getOpcode() == ISD::AND &&
+ ISD::isConstantSplatVectorAllZeros(RHS.getNode())) {
----------------
davemgreen wrote:
isZerosVector might capture a few more cases that are AArch64 specific.
https://github.com/llvm/llvm-project/pull/209100
More information about the llvm-commits
mailing list