diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2016-09-03 17:25:39 +0000 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2016-09-03 17:25:39 +0000 |
commit | 5ffe3e1d935494011b60601137c46c20aded8b97 (patch) | |
tree | 9a71537c0df9e194608c4c206c515353fffde940 /llvm/lib/Target/AMDGPU/SIShrinkInstructions.cpp | |
parent | 907b580d7243293b3b21be690e149872fa0f7311 (diff) | |
download | bcm5719-llvm-5ffe3e1d935494011b60601137c46c20aded8b97.tar.gz bcm5719-llvm-5ffe3e1d935494011b60601137c46c20aded8b97.zip |
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.
llvm-svn: 280594
Diffstat (limited to 'llvm/lib/Target/AMDGPU/SIShrinkInstructions.cpp')
-rw-r--r-- | llvm/lib/Target/AMDGPU/SIShrinkInstructions.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/llvm/lib/Target/AMDGPU/SIShrinkInstructions.cpp b/llvm/lib/Target/AMDGPU/SIShrinkInstructions.cpp index 9f1c9b04f95..9a7fb96493d 100644 --- a/llvm/lib/Target/AMDGPU/SIShrinkInstructions.cpp +++ b/llvm/lib/Target/AMDGPU/SIShrinkInstructions.cpp @@ -194,6 +194,20 @@ static bool isKImmOperand(const SIInstrInfo *TII, const MachineOperand &Src) { 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::runOnMachineFunction(MachineFunction &MF) { ++NumInstructionsShrunk; // Copy extra operands not present in the instruction definition. - Inst32->copyImplicitOps(MF, MI); + copyExtraImplicitOps(*Inst32, MF, MI); MI.eraseFromParent(); foldImmediates(*Inst32, TII, MRI); |