diff options
author | Tom Stellard <thomas.stellard@amd.com> | 2015-10-09 23:47:40 +0000 |
---|---|---|
committer | Tom Stellard <thomas.stellard@amd.com> | 2015-10-15 15:40:45 +0000 |
commit | f55927b1609fab352d69e8b17f2a6067109eebef (patch) | |
tree | 39bcd0121c4743f72312b9c38409d7651e752fd8 | |
parent | c045197eeb6962e77119aeb6625c68c9848cce94 (diff) |
SCALAR branching
-rw-r--r-- | lib/Target/AMDGPU/SIInstrInfo.cpp | 27 | ||||
-rw-r--r-- | lib/Target/AMDGPU/SIInstrInfo.h | 3 |
2 files changed, 29 insertions, 1 deletions
diff --git a/lib/Target/AMDGPU/SIInstrInfo.cpp b/lib/Target/AMDGPU/SIInstrInfo.cpp index 1af08a82ebe..ca9a27c39a3 100644 --- a/lib/Target/AMDGPU/SIInstrInfo.cpp +++ b/lib/Target/AMDGPU/SIInstrInfo.cpp @@ -1518,6 +1518,8 @@ unsigned SIInstrInfo::getVALUOp(const MachineInstr &MI) { case AMDGPU::S_FF1_I32_B32: return AMDGPU::V_FFBL_B32_e32; case AMDGPU::S_FLBIT_I32_B32: return AMDGPU::V_FFBH_U32_e32; case AMDGPU::S_FLBIT_I32: return AMDGPU::V_FFBH_I32_e64; + case AMDGPU::S_CBRANCH_SCC0: return AMDGPU::S_CBRANCH_VCCZ; + case AMDGPU::S_CBRANCH_SCC1: return AMDGPU::S_CBRANCH_VCCNZ; } } @@ -2311,8 +2313,10 @@ void SIInstrInfo::moveToVALU(MachineInstr &TopInst) const { // both. for (unsigned i = Inst->getNumOperands() - 1; i > 0; --i) { MachineOperand &Op = Inst->getOperand(i); - if (Op.isReg() && Op.getReg() == AMDGPU::SCC) + if (Op.isReg() && Op.getReg() == AMDGPU::SCC) { Inst->RemoveOperand(i); + addSCBranchUsersToVALUWorklist(Inst, Worklist); + } } if (Opcode == AMDGPU::S_SEXT_I32_I8 || Opcode == AMDGPU::S_SEXT_I32_I16) { @@ -2345,6 +2349,10 @@ void SIInstrInfo::moveToVALU(MachineInstr &TopInst) const { Inst->addOperand(MachineOperand::CreateImm(BitWidth)); } + // We are done if the instruction has no defs. + if (!NewDesc.NumDefs) + continue; + // Update the destination register class. const TargetRegisterClass *NewDstRC = getDestEquivalentVGPRClass(*Inst); if (!NewDstRC) @@ -2614,6 +2622,23 @@ void SIInstrInfo::addUsersToMoveToVALUWorklist( } } +void SIInstrInfo::addSCBranchUsersToVALUWorklist(MachineInstr *SCCDefInst, + SmallVectorImpl<MachineInstr *> &Worklist) const { + // This assumes that all the S_CBRANCH* users of SCC are in the same block + // as the SCC def. + for (MachineBasicBlock::iterator I = SCCDefInst, + E = SCCDefInst->getParent()->end(); I != E; ++I) { + + // Exit if we find another SCC def. + if (I->findRegisterDefOperandIdx(AMDGPU::SCC) != -1) + return; + + if (I->getOpcode() == AMDGPU::S_CBRANCH_SCC0 || + I->getOpcode() == AMDGPU::S_CBRANCH_SCC1) + Worklist.push_back(I); + } +} + const TargetRegisterClass *SIInstrInfo::getDestEquivalentVGPRClass( const MachineInstr &Inst) const { const TargetRegisterClass *NewDstRC = getOpRegClass(Inst, 0); diff --git a/lib/Target/AMDGPU/SIInstrInfo.h b/lib/Target/AMDGPU/SIInstrInfo.h index ba8b89adc70..df4aa67b0a8 100644 --- a/lib/Target/AMDGPU/SIInstrInfo.h +++ b/lib/Target/AMDGPU/SIInstrInfo.h @@ -56,6 +56,9 @@ private: unsigned Reg, MachineRegisterInfo &MRI, SmallVectorImpl<MachineInstr *> &Worklist) const; + void addSCBranchUsersToVALUWorklist( + MachineInstr *SCCDefInst, SmallVectorImpl<MachineInstr *> &Worklist) const; + const TargetRegisterClass * getDestEquivalentVGPRClass(const MachineInstr &Inst) const; |