[llvm] clastb representation in existing IR, and AArch64 codegen (PR #112738)
Sander de Smalen via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 31 10:23:18 PST 2025
================
@@ -25032,6 +25057,41 @@ static SDValue reassociateCSELOperandsForCSE(SDNode *N, SelectionDAG &DAG) {
}
}
+static SDValue foldCSELofLASTB(SDNode *Op, SelectionDAG &DAG) {
+ AArch64CC::CondCode OpCC =
+ static_cast<AArch64CC::CondCode>(Op->getConstantOperandVal(2));
+
+ if (OpCC != AArch64CC::NE)
+ return SDValue();
+
+ SDValue PTest = Op->getOperand(3);
+ if (PTest.getOpcode() != AArch64ISD::PTEST_ANY)
+ return SDValue();
+
+ SDValue TruePred = PTest.getOperand(0);
+ SDValue AnyPred = PTest.getOperand(1);
+
+ if (TruePred.getOpcode() == AArch64ISD::REINTERPRET_CAST)
+ TruePred = TruePred.getOperand(0);
+
+ if (AnyPred.getOpcode() == AArch64ISD::REINTERPRET_CAST)
+ AnyPred = AnyPred.getOperand(0);
+
+ if (TruePred != AnyPred && TruePred.getOpcode() != AArch64ISD::PTRUE)
+ return SDValue();
+
+ SDValue LastB = Op->getOperand(0);
+ SDValue Default = Op->getOperand(1);
+
+ if (LastB.getOpcode() != AArch64ISD::LASTB || LastB.getOperand(0) != AnyPred)
+ return SDValue();
+
+ SDValue Vec = LastB.getOperand(1);
----------------
sdesmalen-arm wrote:
nit: only has one use, can just as well propagate into expression below.
https://github.com/llvm/llvm-project/pull/112738
More information about the llvm-commits
mailing list