diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2021-11-19 20:06:13 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2021-11-19 20:06:13 +0000 |
| commit | c0981da47d5696fe36474fcf86b4ce03ae3ff818 (patch) | |
| tree | f42add1021b9f2ac6a69ac7cf6c4499962739a45 /llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp | |
| parent | 344a3780b2e33f6ca763666c380202b18aab72a3 (diff) | |
Diffstat (limited to 'llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp')
| -rw-r--r-- | llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp b/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp index d5c56bf2a321..cf93a63f26a0 100644 --- a/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp +++ b/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp @@ -585,10 +585,43 @@ bool SIFixSGPRCopies::runOnMachineFunction(MachineFunction &MF) { case AMDGPU::SOFT_WQM: case AMDGPU::STRICT_WWM: { Register DstReg = MI.getOperand(0).getReg(); - const TargetRegisterClass *SrcRC, *DstRC; std::tie(SrcRC, DstRC) = getCopyRegClasses(MI, *TRI, *MRI); + if (MI.isCopy()) { + Register SrcReg = MI.getOperand(1).getReg(); + if (SrcReg == AMDGPU::SCC) { + Register SCCCopy = MRI->createVirtualRegister( + TRI->getRegClass(AMDGPU::SReg_1_XEXECRegClassID)); + I = BuildMI(*MI.getParent(), + std::next(MachineBasicBlock::iterator(MI)), + MI.getDebugLoc(), + TII->get(ST.isWave32() ? AMDGPU::S_CSELECT_B32 + : AMDGPU::S_CSELECT_B64), + SCCCopy) + .addImm(-1) + .addImm(0); + I = BuildMI(*MI.getParent(), std::next(I), I->getDebugLoc(), + TII->get(AMDGPU::COPY), DstReg) + .addReg(SCCCopy); + MI.eraseFromParent(); + continue; + } else if (DstReg == AMDGPU::SCC) { + unsigned Opcode = + ST.isWave64() ? AMDGPU::S_AND_B64 : AMDGPU::S_AND_B32; + Register Exec = ST.isWave64() ? AMDGPU::EXEC : AMDGPU::EXEC_LO; + Register Tmp = MRI->createVirtualRegister(TRI->getBoolRC()); + I = BuildMI(*MI.getParent(), + std::next(MachineBasicBlock::iterator(MI)), + MI.getDebugLoc(), TII->get(Opcode)) + .addReg(Tmp, getDefRegState(true)) + .addReg(SrcReg) + .addReg(Exec); + MI.eraseFromParent(); + continue; + } + } + if (!DstReg.isVirtual()) { // If the destination register is a physical register there isn't // really much we can do to fix this. |
