[PATCH] D120815: [AMDGPU] Fix deleting of move-immediate instructions after folding

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 2 07:23:04 PST 2022


foad created this revision.
foad added reviewers: arsenm, rampitec, piotr.
Herald added subscribers: kerbowa, hiraditya, t-tye, tpr, dstuttard, yaxunl, nhaehnle, jvesely, kzhuravl.
Herald added a project: All.
foad requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

SIInstrInfo::FoldImmediate tried to delete move-immediate instructions
after folding them into their only use. This did not work because it was
checking hasOneNonDBGUse after doing the fold, at which point there
should be no uses. This seems to have no effect on codegen, it just
means less stuff for DCE to clean up later.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120815

Files:
  llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
  llvm/test/CodeGen/AMDGPU/madak-inline-constant.mir


Index: llvm/test/CodeGen/AMDGPU/madak-inline-constant.mir
===================================================================
--- llvm/test/CodeGen/AMDGPU/madak-inline-constant.mir
+++ llvm/test/CodeGen/AMDGPU/madak-inline-constant.mir
@@ -2,7 +2,6 @@
 
 
 # GCN-LABEL: bb.0:
-# GCN:  V_MOV_B32_e32 1092616192
 # GCN:  S_MOV_B32 1082130432
 # GCN:  %3:vgpr_32 = V_MADAK_F32 1082130432, killed %0, 1092616192, implicit $mode, implicit $exec
 
@@ -21,7 +20,6 @@
 
 
 # GCN-LABEL: bb.0:
-# GCN:  V_MOV_B32_e32 1092616192
 # GCN:  S_MOV_B32 1082130432
 # GCN:  %3:vgpr_32 = V_MADAK_F32 1082130432, killed %0, 1092616192, implicit $mode, implicit $exec
 
@@ -39,7 +37,6 @@
 ...
 
 # GCN-LABEL: bb.0:
-# GCN:  V_MOV_B32_e32 1092616192
 # GCN:  S_MOV_B32 1082130432
 # GCN:  %3:vgpr_32 = V_MADAK_F32 killed %0, killed %0, 1092616192, implicit $mode, implicit $exec
 
@@ -57,7 +54,6 @@
 ...
 
 # GCN-LABEL: bb.0:
-# GCN:  V_MOV_B32_e32 1092616192
 # GCN:  V_MOV_B32_e32 1082130432
 # GCN:  %3:vgpr_32 = V_MADAK_F32 1082130432, killed %0, 1092616192, implicit $mode, implicit $exec
 
@@ -76,7 +72,6 @@
 
 
 # GCN-LABEL: bb.0:
-# GCN:  V_MOV_B32_e32 1092616192
 # GCN:  V_MOV_B32_e32 1082130432
 # GCN:  %3:vgpr_32 = V_MADAK_F32 1082130432, killed %0, 1092616192, implicit $mode, implicit $exec
 
@@ -94,7 +89,6 @@
 ...
 
 # GCN-LABEL: bb.0:
-# GCN:  V_MOV_B32_e32 1092616192, implicit $exec
 # GCN:  S_MOV_B32 1082130432
 # GCN:  V_MADAK_F32 1082130432, killed $vgpr1, 1092616192, implicit $mode, implicit $exec
 
@@ -113,7 +107,6 @@
 ...
 
 # GCN-LABEL: bb.0:
-# GCN:  V_MOV_B32_e32 1092616192, implicit $exec
 # GCN:  S_MOV_B32 1082130432
 # GCN:  V_MADAK_F32 1082130432, killed $vgpr0, 1092616192, implicit $mode, implicit $exec
 
@@ -166,7 +159,6 @@
 ...
 
 # GCN-LABEL: bb.0:
-# GCN:  V_MOV_B32_e32 1092616192, implicit $exec
 # GCN:  $sgpr2 = S_MOV_B32 1082130432
 # GCN:  V_MADAK_F32 1082130432, killed %0, 1092616192, implicit $mode, implicit $exec
 
Index: llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
+++ llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
@@ -3000,7 +3000,7 @@
       removeModOperands(UseMI);
       UseMI.setDesc(get(NewOpc));
 
-      bool DeleteDef = MRI->hasOneNonDBGUse(Reg);
+      bool DeleteDef = MRI->use_nodbg_empty(Reg);
       if (DeleteDef)
         DefMI.eraseFromParent();
 
@@ -3083,7 +3083,7 @@
       // constant and SGPR are illegal.
       legalizeOperands(UseMI);
 
-      bool DeleteDef = MRI->hasOneNonDBGUse(Reg);
+      bool DeleteDef = MRI->use_nodbg_empty(Reg);
       if (DeleteDef)
         DefMI.eraseFromParent();
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120815.412410.patch
Type: text/x-patch
Size: 2659 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220302/86f50335/attachment.bin>


More information about the llvm-commits mailing list