diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp --- a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp +++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp @@ -670,15 +670,14 @@ } if (DestReg == AMDGPU::SCC) { - unsigned Opcode; - if (AMDGPU::SReg_32RegClass.contains(SrcReg)) { - Opcode = AMDGPU::S_CMP_LG_U32; - } else { - assert(AMDGPU::SReg_64RegClass.contains(SrcReg)); - Opcode = AMDGPU::S_CMP_LG_U64; + + // We only care about the low bit here. + if (AMDGPU::SReg_64RegClass.contains(SrcReg)) { + SrcReg = RI.getSubReg(SrcReg, AMDGPU::sub0); } + assert(AMDGPU::SReg_32RegClass.contains(SrcReg)); - BuildMI(MBB, MI, DL, get(Opcode)) + BuildMI(MBB, MI, DL, get(AMDGPU::S_CMP_LG_U32)) .addReg(SrcReg, getKillRegState(KillSrc)) .addImm(0); diff --git a/llvm/lib/Target/AMDGPU/SOPInstructions.td b/llvm/lib/Target/AMDGPU/SOPInstructions.td --- a/llvm/lib/Target/AMDGPU/SOPInstructions.td +++ b/llvm/lib/Target/AMDGPU/SOPInstructions.td @@ -471,15 +471,14 @@ [{ return N->getOperand(0)->hasOneUse() && !N->isDivergent(); }] >; -let Uses = [SCC], AddedComplexity = 20 in { - def S_CSELECT_B64 : SOP2_64 <"s_cselect_b64", - [(set i64:$sdst, (SelectPat i32:$src0, i32:$src1))] ->; +let Uses = [SCC] in { + let AddedComplexity = 20 in { + def S_CSELECT_B32 : SOP2_32 <"s_cselect_b32", + [(set i32:$sdst, (SelectPat