[llvm] [AArch64] Take cmn into account when adjusting compare constants (PR #98634)

David Green via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 14 05:31:39 PDT 2024


================
@@ -3876,10 +3876,15 @@ static SDValue getAArch64Cmp(SDValue LHS, SDValue RHS, ISD::CondCode CC,
   //    cmp     w13, w12
   // can be turned into:
   //    cmp     w12, w11, lsl #1
-  if (!isa<ConstantSDNode>(RHS) || !isLegalArithImmed(RHS->getAsZExtVal())) {
-    SDValue TheLHS = isCMN(LHS, CC) ? LHS.getOperand(1) : LHS;
-
-    if (getCmpOperandFoldingProfit(TheLHS) > getCmpOperandFoldingProfit(RHS)) {
+  if (!isa<ConstantSDNode>(RHS) ||
+      !isLegalArithImmed(RHS->getAsAPIntVal().abs().getZExtValue())) {
+    bool LHSIsCMN = LHS.getOpcode() == ISD::SUB && isCMN(LHS, CC);
+    bool RHSIsCMN = RHS.getOpcode() == ISD::SUB && isCMN(RHS, CC);
----------------
davemgreen wrote:

Why does it need to to check ==SUB, is that not already handled in isCMN?

https://github.com/llvm/llvm-project/pull/98634


More information about the llvm-commits mailing list