[llvm] [AArch64] - Fold and and cmp into tst (PR #110347)
Jorge Botto via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 3 07:03:50 PDT 2024
================
@@ -4301,6 +4301,29 @@ static SDValue LowerPREFETCH(SDValue Op, SelectionDAG &DAG) {
Op.getOperand(1));
}
+// Converts SETCC (AND X Y) Z ULT -> SETCC (AND X (Y & ~(Z - 1)) 0 EQ when Y is
+// a power of 2. This is then lowered to ANDS X (Y & ~(Z - 1)) instead of SUBS
+// (AND X Y) Z which produces a better opt with EmitComparison
+static void simplifySetCCIntoEq(ISD::CondCode &CC, SDValue &LHS, SDValue &RHS,
+ SelectionDAG &DAG, const SDLoc dl) {
+ if (CC == ISD::SETULT && LHS.getOpcode() == ISD::AND && LHS->hasOneUse()) {
+ ConstantSDNode *LHSConstOp = dyn_cast<ConstantSDNode>(LHS.getOperand(1));
+ ConstantSDNode *RHSConst = dyn_cast<ConstantSDNode>(RHS);
+ if (LHSConstOp && RHSConst) {
+ uint64_t lhsConstValue = LHSConstOp->getZExtValue();
----------------
jf-botto wrote:
Apologies, fixed it.
https://github.com/llvm/llvm-project/pull/110347
More information about the llvm-commits
mailing list