diff options
author | tstellar <tstellar@91177308-0d34-0410-b5e6-96231b3b80d8> | 2013-02-19 15:22:42 +0000 |
---|---|---|
committer | Tom Stellard <thomas.stellard@amd.com> | 2013-02-19 15:34:20 +0000 |
commit | 24070a4004464b10b79b15a6c20eafba998904c4 (patch) | |
tree | 8436a59cc9f200a7d273f9b2e3d94826d1b74d40 | |
parent | 9d4fb0b517d6d0aa51b8281d45d0b897864775cd (diff) |
R600: Fix tracking of implicit defs in the IndirectAddressing pass
In some cases, we were losing track of live implicit registers which
was creating dead defs and causing the scheduler to produce invalid
code.
NOTE: This is a candidate for the Mesa stable branch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175516 91177308-0d34-0410-b5e6-96231b3b80d8
(cherry picked from commit f68580f371d52fef8618e6d2dc15d4392c623e5a)
-rw-r--r-- | lib/Target/R600/AMDGPUIndirectAddressing.cpp | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/lib/Target/R600/AMDGPUIndirectAddressing.cpp b/lib/Target/R600/AMDGPUIndirectAddressing.cpp index 56aaf23cae9..15840b32e52 100644 --- a/lib/Target/R600/AMDGPUIndirectAddressing.cpp +++ b/lib/Target/R600/AMDGPUIndirectAddressing.cpp @@ -169,9 +169,6 @@ bool AMDGPUIndirectAddressingPass::runOnMachineFunction(MachineFunction &MF) { } if (RegisterAddressMap[Reg] == Address) { - if (!regHasExplicitDef(MRI, Reg)) { - continue; - } PhiRegisters.push_back(Reg); } } @@ -270,7 +267,8 @@ bool AMDGPUIndirectAddressingPass::runOnMachineFunction(MachineFunction &MF) { // instruction that uses indirect addressing. BuildMI(MBB, I, MBB.findDebugLoc(I), TII->get(AMDGPU::COPY), MI.getOperand(0).getReg()) - .addReg(AddrReg); + .addReg(AddrReg) + .addReg(Reg, RegState::Implicit); } } else { // Indirect register access @@ -292,8 +290,7 @@ bool AMDGPUIndirectAddressingPass::runOnMachineFunction(MachineFunction &MF) { // We only need to use REG_SEQUENCE for explicit defs, since the // register coalescer won't do anything with the implicit defs. MachineInstr *DefInstr = MRI.getVRegDef(Reg); - if (!DefInstr->getOperand(0).isReg() || - DefInstr->getOperand(0).getReg() != Reg) { + if (!regHasExplicitDef(MRI, Reg)) { continue; } @@ -310,6 +307,7 @@ bool AMDGPUIndirectAddressingPass::runOnMachineFunction(MachineFunction &MF) { Mov.addReg(IndirectReg, RegState::Implicit | RegState::Kill); + Mov.addReg(LiveAddressRegisterMap[Address], RegState::Implicit); } MI.eraseFromParent(); @@ -321,6 +319,26 @@ bool AMDGPUIndirectAddressingPass::runOnMachineFunction(MachineFunction &MF) { bool AMDGPUIndirectAddressingPass::regHasExplicitDef(MachineRegisterInfo &MRI, unsigned Reg) const { MachineInstr *DefInstr = MRI.getVRegDef(Reg); - return DefInstr && DefInstr->getOperand(0).isReg() && + + if (!DefInstr) { + return false; + } + + if (DefInstr->getOpcode() == AMDGPU::PHI) { + bool Explicit = false; + for (MachineInstr::const_mop_iterator I = DefInstr->operands_begin(), + E = DefInstr->operands_end(); + I != E; ++I) { + const MachineOperand &MO = *I; + if (!MO.isReg() || MO.isDef()) { + continue; + } + + Explicit = Explicit || regHasExplicitDef(MRI, MO.getReg()); + } + return Explicit; + } + + return DefInstr->getOperand(0).isReg() && DefInstr->getOperand(0).getReg() == Reg; } |