[llvm] [X86] Lower i512 ADD/SUB using Kogge-Stone on AVX512 (PR #174761)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 3 09:52:21 PST 2026


================
@@ -54559,8 +54616,20 @@ static SDValue combineStore(SDNode *N, SelectionDAG &DAG,
   // vector type or the operation is likely to expand to a vector type
   // (legalization can scalarize back if it the op failed).
   if (VT == MVT::i256 || VT == MVT::i512) {
+    // issue : 173996 , pr : 174761 : when add/sub lowered on avx512 we hit a
+    // regression issue. my approach is to allow the combine only when the
+    // operation is done by our custome handling.
+    // X86TargetLowering::ReplaceNodeResults (ADD/SUB) cases.
+    bool IsCheapAddSub = true;
+    if ((VT == MVT::i512) && (StoredVal->getOpcode() == ISD::ADD ||
+                              StoredVal->getOpcode() == ISD::SUB)) {
+      SDValue LHS = StoredVal->getOperand(0);
+      SDValue RHS = StoredVal->getOperand(1);
+      IsCheapAddSub = mayFoldIntoVector(LHS, Subtarget) &&
+                      mayFoldIntoVector(RHS, Subtarget);
+    }
----------------
RKSimon wrote:

Please can you move this handling into mayFoldIntoVector - see #179503 for reference

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


More information about the llvm-commits mailing list