[PATCH] D12460: AMDGPU/SI: Fix creating v_mov_b32s without exec uses

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 28 17:19:46 PDT 2015


arsenm created this revision.
arsenm added a reviewer: tstellarAMD.
arsenm added a subscriber: llvm-commits.
Herald added a subscriber: arsenm.

This will be caught by existing tests with a verifier check to be added in a future commit.


http://reviews.llvm.org/D12460

Files:
  lib/Target/AMDGPU/SIFoldOperands.cpp

Index: lib/Target/AMDGPU/SIFoldOperands.cpp
===================================================================
--- lib/Target/AMDGPU/SIFoldOperands.cpp
+++ lib/Target/AMDGPU/SIFoldOperands.cpp
@@ -226,6 +226,12 @@
            OpToFold.getSubReg()))
         continue;
 
+
+      // We need mutate the operands of new mov instructions to add implicit
+      // uses of EXEC, but adding them invalidates the use_iterator, so defer
+      // this.
+      SmallVector<MachineInstr *, 4> CopiesToReplace;
+
       std::vector<FoldCandidate> FoldList;
       for (MachineRegisterInfo::use_iterator
            Use = MRI.use_begin(MI.getOperand(0).getReg()), E = MRI.use_end();
@@ -278,6 +284,7 @@
               continue;
 
             UseMI->setDesc(TII->get(MovOp));
+            CopiesToReplace.push_back(UseMI);
           }
         }
 
@@ -302,6 +309,10 @@
         // already does this.
       }
 
+      // Make sure we add EXEC uses to any new v_mov instructions created.
+      for (MachineInstr *Copy : CopiesToReplace)
+        Copy->addImplicitDefUseOperands(MF);
+
       for (FoldCandidate &Fold : FoldList) {
         if (updateOperand(Fold, TRI)) {
           // Clear kill flags.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12460.33497.patch
Type: text/x-patch
Size: 1194 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150829/1e0a0694/attachment.bin>


More information about the llvm-commits mailing list