[llvm] [AMDGPU][MachineVerifier] test failures in SIFoldOperands (PR #166600)

Abhay Kanhere via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 5 13:24:31 PST 2025


https://github.com/AbhayKanhere updated https://github.com/llvm/llvm-project/pull/166600

>From c37f1d1f49111bc2e818de8592270566355bdd90 Mon Sep 17 00:00:00 2001
From: Abhay Kanhere <abhay at kanhere.net>
Date: Wed, 5 Nov 2025 09:51:02 -0800
Subject: [PATCH 1/2] [AMDGPU][MachineVerifier] test failures in SIFoldOperands

After PR:https://github.com/llvm/llvm-project/pull/151421 merged
following fails in SIFoldOperands showed up.

LLVM :: CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.mfma.gfx90a.ll
LLVM :: CodeGen/AMDGPU/llvm.amdgcn.mfma.gfx90a.ll
LLVM :: CodeGen/AMDGPU/llvm.amdgcn.mfma.ll
LLVM :: CodeGen/AMDGPU/mfma-loop.ll
LLVM :: CodeGen/AMDGPU/rewrite-vgpr-mfma-to-agpr.ll

In Folding code, if folded operand is register ensure earlyClobber
is set.
---
 llvm/lib/Target/AMDGPU/SIFoldOperands.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
index 6616b30410590..cf9a6f021fd9b 100644
--- a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
+++ b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
@@ -689,6 +689,10 @@ bool SIFoldOperandsImpl::updateOperand(FoldCandidate &Fold) const {
     if (!TII->isOperandLegal(*MI, OpNo, &New))
       return false;
 
+    const MCInstrDesc &MCID = MI->getDesc();
+    if (MCID.getOperandConstraint(OpNo, MCOI::EARLY_CLOBBER) != -1) {
+      MI->getOperand(OpNo).setIsEarlyClobber(true);
+    }
     Old.ChangeToImmediate(*ImmVal);
     return true;
   }

>From 53599abd7639aeb57179442673ee1c367c821aa2 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <arsenm2 at gmail.com>
Date: Wed, 5 Nov 2025 10:50:50 -0800
Subject: [PATCH 2/2] Apply suggestion from @shiltian

Co-authored-by: Shilei Tian <i at tianshilei.me>
---
 llvm/lib/Target/AMDGPU/SIFoldOperands.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
index cf9a6f021fd9b..aed75f55b0ee2 100644
--- a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
+++ b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
@@ -690,9 +690,8 @@ bool SIFoldOperandsImpl::updateOperand(FoldCandidate &Fold) const {
       return false;
 
     const MCInstrDesc &MCID = MI->getDesc();
-    if (MCID.getOperandConstraint(OpNo, MCOI::EARLY_CLOBBER) != -1) {
+    if (MCID.getOperandConstraint(OpNo, MCOI::EARLY_CLOBBER) != -1)
       MI->getOperand(OpNo).setIsEarlyClobber(true);
-    }
     Old.ChangeToImmediate(*ImmVal);
     return true;
   }



More information about the llvm-commits mailing list