diff options
| author | Geoff Berry <gberry@codeaurora.org> | 2018-01-30 17:37:39 +0000 |
|---|---|---|
| committer | Geoff Berry <gberry@codeaurora.org> | 2018-01-30 17:37:39 +0000 |
| commit | 1d531013876c02b18df678a5f67d6a7d94e392b9 (patch) | |
| tree | 0fd9364d1502ac5a80d423a64e1dcd987ac5e6ac /llvm/lib/Target | |
| parent | c9265e81f491a3fc1b7b02920479bd34b236fac9 (diff) | |
| download | bcm5719-llvm-1d531013876c02b18df678a5f67d6a7d94e392b9.tar.gz bcm5719-llvm-1d531013876c02b18df678a5f67d6a7d94e392b9.zip | |
[AMDGPU] isRenamable fixes to support copy forwarding
Mark more opcodes as hasExtraSrcRegAllocReq so that their operands will
be marked as not renamable, to avoid copy forwarding violating the
constraint that only one operand may use the constant bus.
These changes fix a few mis-compiles when copy forwarding is enabled in
MachineCopyPropagation by D41835 (and were reviewed as part of that change).
llvm-svn: 323794
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/AMDGPU/SIInsertSkips.cpp | 10 | ||||
| -rw-r--r-- | llvm/lib/Target/AMDGPU/SIInstrFormats.td | 2 | ||||
| -rw-r--r-- | llvm/lib/Target/AMDGPU/VOP3Instructions.td | 2 | ||||
| -rw-r--r-- | llvm/lib/Target/AMDGPU/VOPInstructions.td | 2 |
4 files changed, 12 insertions, 4 deletions
diff --git a/llvm/lib/Target/AMDGPU/SIInsertSkips.cpp b/llvm/lib/Target/AMDGPU/SIInsertSkips.cpp index eb7277b7a5b..bc8cf5eb191 100644 --- a/llvm/lib/Target/AMDGPU/SIInsertSkips.cpp +++ b/llvm/lib/Target/AMDGPU/SIInsertSkips.cpp @@ -262,14 +262,15 @@ void SIInsertSkips::kill(MachineInstr &MI) { assert(MI.getOperand(0).isReg()); + MachineInstr *NewMI; if (TRI->isVGPR(MBB.getParent()->getRegInfo(), MI.getOperand(0).getReg())) { Opcode = AMDGPU::getVOPe32(Opcode); - BuildMI(MBB, &MI, DL, TII->get(Opcode)) + NewMI = BuildMI(MBB, &MI, DL, TII->get(Opcode)) .add(MI.getOperand(1)) .add(MI.getOperand(0)); } else { - BuildMI(MBB, &MI, DL, TII->get(Opcode)) + NewMI = BuildMI(MBB, &MI, DL, TII->get(Opcode)) .addReg(AMDGPU::VCC, RegState::Define) .addImm(0) // src0 modifiers .add(MI.getOperand(1)) @@ -277,6 +278,11 @@ void SIInsertSkips::kill(MachineInstr &MI) { .add(MI.getOperand(0)) .addImm(0); // omod } + // Clear isRenamable bit if new opcode requires it to be 0. + if (NewMI->hasExtraSrcRegAllocReq()) + for (MachineOperand &NewMO : NewMI->uses()) + if (NewMO.isReg() && NewMO.isUse()) + NewMO.setIsRenamable(false); break; } case AMDGPU::SI_KILL_I1_TERMINATOR: { diff --git a/llvm/lib/Target/AMDGPU/SIInstrFormats.td b/llvm/lib/Target/AMDGPU/SIInstrFormats.td index af9908b9846..9e7aea6705f 100644 --- a/llvm/lib/Target/AMDGPU/SIInstrFormats.td +++ b/llvm/lib/Target/AMDGPU/SIInstrFormats.td @@ -203,6 +203,8 @@ class VPseudoInstSI<dag outs, dag ins, list<dag> pattern = [], string asm = ""> : PseudoInstSI<outs, ins, pattern, asm> { let VALU = 1; let Uses = [EXEC]; + // Avoid changing source registers in a way that violates constant bus read limitations. + let hasExtraSrcRegAllocReq = 1; } class CFPseudoInstSI<dag outs, dag ins, list<dag> pattern = [], diff --git a/llvm/lib/Target/AMDGPU/VOP3Instructions.td b/llvm/lib/Target/AMDGPU/VOP3Instructions.td index aedbfa015bf..aee64345f17 100644 --- a/llvm/lib/Target/AMDGPU/VOP3Instructions.td +++ b/llvm/lib/Target/AMDGPU/VOP3Instructions.td @@ -355,14 +355,12 @@ def V_LDEXP_F64 : VOP3Inst <"v_ldexp_f64", VOP3_Profile<VOP_F64_F64_I32>, AMDGPU def V_DIV_SCALE_F32 : VOP3_Pseudo <"v_div_scale_f32", VOP3b_F32_I1_F32_F32_F32, [], 1> { let SchedRW = [WriteFloatFMA, WriteSALU]; - let hasExtraSrcRegAllocReq = 1; let AsmMatchConverter = ""; } // Double precision division pre-scale. def V_DIV_SCALE_F64 : VOP3_Pseudo <"v_div_scale_f64", VOP3b_F64_I1_F64_F64_F64, [], 1> { let SchedRW = [WriteDouble, WriteSALU]; - let hasExtraSrcRegAllocReq = 1; let AsmMatchConverter = ""; } diff --git a/llvm/lib/Target/AMDGPU/VOPInstructions.td b/llvm/lib/Target/AMDGPU/VOPInstructions.td index 520d5dd0f50..dfe18de97be 100644 --- a/llvm/lib/Target/AMDGPU/VOPInstructions.td +++ b/llvm/lib/Target/AMDGPU/VOPInstructions.td @@ -81,6 +81,8 @@ class VOP3_Pseudo <string opName, VOPProfile P, list<dag> pattern = [], let UseNamedOperandTable = 1; let VOP3_OPSEL = isVop3OpSel; let IsPacked = P.IsPacked; + // Avoid changing source registers in a way that violates constant bus read limitations. + let hasExtraSrcRegAllocReq = 1; string Mnemonic = opName; string AsmOperands = !if(isVop3OpSel, |

