[llvm] [AArch64][DAG] Port adde and sube combine to AArch64 (PR #202227)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 3 11:56:34 PDT 2026


================
@@ -23002,6 +23002,43 @@ static SDValue foldADCToCINC(SDNode *N, SelectionDAG &DAG) {
   return DAG.getNode(AArch64ISD::CSINC, DL, VT, LHS, LHS, CC, Cond);
 }
 
+static SDValue performAddSubCarryCombine(SDNode *N, SelectionDAG &DAG) {
+  SDValue RHS = N->getOperand(1);
+  if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(RHS)) {
+    int64_t Imm = C->getSExtValue();
+
+    // -1 is exempt because 0 gets the zero reg
+    if (Imm == -1 || (Imm < 0 && C->hasOneUse())) {
----------------
zip-stack-debug wrote:

> > They can't be encoded as immediates.
> 
> These instructions don't encode immediates. What makes negative immediates intrinsically more costly to expand?

My brain was thinking of ARM32 again, and even then in ARM backend this is for Thumb, which does not encode immediates. My bad.

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


More information about the llvm-commits mailing list