@@ -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-
150122bool 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))
0 commit comments