[llvm] [AArch64] Use CMN instruction for negative SUBS immediates (PR #221398)

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 13 15:47:39 PDT 2026


================
@@ -4218,6 +4218,18 @@ static bool canEmitConjunction(SelectionDAG &DAG, const SDValue Val,
     // of a SUB operation can be reused.
     PreferFirst = DAG.doesNodeExist(ISD::SUB, DAG.getVTList(VT),
                                     {Val->getOperand(0), Val->getOperand(1)});
+    // The first comparison supports the full 12-bit CMP/CMN immediate range,
+    // while subsequent CCMP/CCMN comparisons only support a 5-bit immediate [0,
+    // 31]. Prefer a wider-immediate comparison first to avoid materializing
+    // constants.
+    if (!PreferFirst && VT.isInteger()) {
----------------
efriedma-quic wrote:

Can we split this into a separate PR?  It looks like it stands on its own.

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


More information about the llvm-commits mailing list