[llvm] r280594 - AMDGPU: Fix adding duplicate implicit exec uses

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 3 10:25:40 PDT 2016


Author: arsenm
Date: Sat Sep  3 12:25:39 2016
New Revision: 280594

URL: http://llvm.org/viewvc/llvm-project?rev=280594&view=rev
Log:
AMDGPU: Fix adding duplicate implicit exec uses

I'm not sure if this should be considered a bug in
copyImplicitOps or not, but implicit operands that are part
of the static instruction definition should not be copied.

Modified:
    llvm/trunk/lib/Target/AMDGPU/SIShrinkInstructions.cpp

Modified: llvm/trunk/lib/Target/AMDGPU/SIShrinkInstructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/SIShrinkInstructions.cpp?rev=280594&r1=280593&r2=280594&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/SIShrinkInstructions.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/SIShrinkInstructions.cpp Sat Sep  3 12:25:39 2016
@@ -194,6 +194,20 @@ static bool isKImmOperand(const SIInstrI
   return isInt<16>(Src.getImm()) && !TII->isInlineConstant(Src, 4);
 }
 
+/// Copy implicit register operands from specified instruction to this
+/// instruction that are not part of the instruction definition.
+static void copyExtraImplicitOps(MachineInstr &NewMI, MachineFunction &MF,
+                                 const MachineInstr &MI) {
+  for (unsigned i = MI.getDesc().getNumOperands() +
+         MI.getDesc().getNumImplicitUses() +
+         MI.getDesc().getNumImplicitDefs(), e = MI.getNumOperands();
+       i != e; ++i) {
+    const MachineOperand &MO = MI.getOperand(i);
+    if ((MO.isReg() && MO.isImplicit()) || MO.isRegMask())
+      NewMI.addOperand(MF, MO);
+  }
+}
+
 bool SIShrinkInstructions::runOnMachineFunction(MachineFunction &MF) {
   if (skipFunction(*MF.getFunction()))
     return false;
@@ -401,7 +415,7 @@ bool SIShrinkInstructions::runOnMachineF
       ++NumInstructionsShrunk;
 
       // Copy extra operands not present in the instruction definition.
-      Inst32->copyImplicitOps(MF, MI);
+      copyExtraImplicitOps(*Inst32, MF, MI);
 
       MI.eraseFromParent();
       foldImmediates(*Inst32, TII, MRI);




More information about the llvm-commits mailing list