[llvm] [RISCV] Fixed redundant add instructions generated during the fold of vscale add in rvv. (PR #225266)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 27 22:01:57 PDT 2026


================
@@ -18613,6 +18616,33 @@ static SDValue combineAddMulh(SDNode *N, SelectionDAG &DAG,
   return DAG.getNode(RISCVISD::MULHSU, DL, VT, X, Mulh.getOperand(1));
 }
 
+// Fold (add (add A, (vscale C1)), (vscale C2))
+//   -> (add A, (vscale (C1 + C2)))
+// Optimize only when (add A, (vscale C1)) is not reused.
+static SDValue combineVscaleAdd(SDNode *N, SelectionDAG &DAG,
----------------
topperc wrote:

Should we just pass the SDNode's to isDesirableToFoldVScaleAdd and do the one use check there so we don't need to duplicate the combine?

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


More information about the llvm-commits mailing list