[llvm-branch-commits] [llvm] [AMDGPU][InstCombine] Fold constant add/sub into the dot accumulator (PR #225002)

Harrison Hao via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Sep 21 07:11:42 PDT 2026


================
@@ -1968,6 +1968,44 @@ GCNTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
     Result = scalbn(Result, Scale, RoundingMode::NearestTiesToEven);
     return IC.replaceInstUsesWith(II, ConstantFP::get(Src->getType(), Result));
   }
+  case Intrinsic::amdgcn_sdot2:
+  case Intrinsic::amdgcn_udot2:
+  case Intrinsic::amdgcn_sdot4:
+  case Intrinsic::amdgcn_udot4:
+  case Intrinsic::amdgcn_sdot8:
+  case Intrinsic::amdgcn_udot8: {
+    if (!match(II.getArgOperand(3), m_Zero()) || !II.hasOneUse())
+      break;
+
+    const APInt *Acc;
+    if (!match(II.getArgOperand(2), m_APInt(Acc)))
+      break;
+
+    auto *AccumUser = dyn_cast<BinaryOperator>(II.user_back());
+    if (!AccumUser)
----------------
harrisonGPU wrote:

This is already guarded by II.hasOneUse() above, so user_back() cannot be called when there are no users. I  added a no use test called `sdot4_no_use`

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


More information about the llvm-branch-commits mailing list