Skip to content

Commit ecfd957

Browse files
Jun Wangjwanggit86
authored andcommitted
Assume machineverifier will handle the cases where the register
size is incorrect. In that case, a copy from physical reg to VCC is allowed.
1 parent 3529b06 commit ecfd957

File tree

4 files changed

+4
-72
lines changed

4 files changed

+4
-72
lines changed

llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -119,34 +119,6 @@ bool AMDGPUInstructionSelector::constrainCopyLikeIntrin(MachineInstr &MI,
119119
RBI.constrainGenericRegister(Src.getReg(), *SrcRC, *MRI);
120120
}
121121

122-
// Returns true if this is a copy from physical reg to VCC.
123-
// The parameter IsValid further indicates if the copy is valid.
124-
bool AMDGPUInstructionSelector::isCopyPhysicalToVCC(
125-
Register DstReg, Register SrcReg, const MachineRegisterInfo &MRI,
126-
bool &IsValid) const {
127-
if (DstReg.isPhysical())
128-
return false;
129-
if (!SrcReg.isPhysical() || SrcReg == AMDGPU::SCC)
130-
return false;
131-
132-
auto &RegClassOrBank = MRI.getRegClassOrRegBank(DstReg);
133-
const TargetRegisterClass *RC =
134-
RegClassOrBank.dyn_cast<const TargetRegisterClass *>();
135-
if (RC) {
136-
const LLT Ty = MRI.getType(DstReg);
137-
if (!Ty.isValid() || Ty.getSizeInBits() != 1)
138-
return false;
139-
// G_TRUNC s1 result is never vcc.
140-
if (MRI.getVRegDef(DstReg)->getOpcode() == AMDGPU::G_TRUNC ||
141-
!RC->hasSuperClassEq(TRI.getBoolRC()))
142-
return false;
143-
IsValid = RC->contains(SrcReg);
144-
return true;
145-
}
146-
147-
return false;
148-
}
149-
150122
bool AMDGPUInstructionSelector::selectCOPY(MachineInstr &I) const {
151123
const DebugLoc &DL = I.getDebugLoc();
152124
MachineBasicBlock *BB = I.getParent();
@@ -157,10 +129,6 @@ bool AMDGPUInstructionSelector::selectCOPY(MachineInstr &I) const {
157129
Register DstReg = Dst.getReg();
158130
Register SrcReg = Src.getReg();
159131

160-
bool validPhyToRCC = false;
161-
if (isCopyPhysicalToVCC(DstReg, SrcReg, *MRI, validPhyToRCC))
162-
return validPhyToRCC;
163-
164132
if (isVCC(DstReg, *MRI)) {
165133
if (SrcReg == AMDGPU::SCC) {
166134
const TargetRegisterClass *RC
@@ -170,6 +138,10 @@ bool AMDGPUInstructionSelector::selectCOPY(MachineInstr &I) const {
170138
return RBI.constrainGenericRegister(DstReg, *RC, *MRI);
171139
}
172140

141+
// Allow copy from physical register other than SCC to s1.
142+
if (SrcReg.isPhysical() && SrcReg != AMDGPU::SCC)
143+
return true;
144+
173145
if (!isVCC(SrcReg, *MRI)) {
174146
// TODO: Should probably leave the copy and let copyPhysReg expand it.
175147
if (!RBI.constrainGenericRegister(DstReg, *TRI.getBoolRC(), *MRI))

llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ class AMDGPUInstructionSelector final : public InstructionSelector {
7373

7474
bool isInstrUniform(const MachineInstr &MI) const;
7575
bool isVCC(Register Reg, const MachineRegisterInfo &MRI) const;
76-
bool isCopyPhysicalToVCC(Register DstReg, Register SrcReg,
77-
const MachineRegisterInfo &MRI, bool &IsValid) const;
7876

7977
const RegisterBank *getArtifactRegBank(
8078
Register Reg, const MachineRegisterInfo &MRI,

llvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-copy-sgpr-to-s1-wave32-err.mir

Lines changed: 0 additions & 19 deletions
This file was deleted.

llvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-copy-sgpr-to-s1-wave64-err.mir

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)