summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2015-09-10 01:06:06 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2015-09-10 01:06:06 +0000
commitad46e0c1ab1093c49811f745d693d5b540240a73 (patch)
treebd55b011477ecca8fd311f98eeb4b68ac1fe3a32
parent9a2c1c96038bdb2f2d0cd25f93418856beb0a924 (diff)
downloadbcm5719-llvm-ad46e0c1ab1093c49811f745d693d5b540240a73.tar.gz
bcm5719-llvm-ad46e0c1ab1093c49811f745d693d5b540240a73.zip
AMDGPU/SI: Fix creating v_mov_b32s without exec uses
This will be caught by existing tests with a verifier check to be added in a future commit. llvm-svn: 247229
-rw-r--r--llvm/lib/Target/AMDGPU/SIFoldOperands.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
index fe11385d0cd..ef377116939 100644
--- a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
+++ b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
@@ -189,6 +189,7 @@ static bool tryAddToFoldList(std::vector<FoldCandidate> &FoldList,
static void foldOperand(MachineOperand &OpToFold, MachineInstr *UseMI,
unsigned UseOpIdx,
std::vector<FoldCandidate> &FoldList,
+ SmallVectorImpl<MachineInstr *> &CopiesToReplace,
const SIInstrInfo *TII, const SIRegisterInfo &TRI,
MachineRegisterInfo &MRI) {
const MachineOperand &UseOp = UseMI->getOperand(UseOpIdx);
@@ -242,6 +243,7 @@ static void foldOperand(MachineOperand &OpToFold, MachineInstr *UseMI,
return;
UseMI->setDesc(TII->get(MovOp));
+ CopiesToReplace.push_back(UseMI);
}
}
@@ -261,7 +263,7 @@ static void foldOperand(MachineOperand &OpToFold, MachineInstr *UseMI,
continue;
foldOperand(OpToFold, RSUseMI, RSUse.getOperandNo(), FoldList,
- TII, TRI, MRI);
+ CopiesToReplace, TII, TRI, MRI);
}
return;
}
@@ -328,6 +330,12 @@ bool SIFoldOperands::runOnMachineFunction(MachineFunction &MF) {
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();
@@ -336,9 +344,13 @@ bool SIFoldOperands::runOnMachineFunction(MachineFunction &MF) {
MachineInstr *UseMI = Use->getParent();
foldOperand(OpToFold, UseMI, Use.getOperandNo(), FoldList,
- TII, TRI, MRI);
+ CopiesToReplace, TII, TRI, MRI);
}
+ // 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.
OpenPOWER on IntegriCloud