[llvm] [AMDGPU] Select S_CSELECT_B32/64 for uniform extensions from i1 (PR #204238)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 24 03:11:16 PDT 2026
================
@@ -8687,14 +8687,30 @@ void SIInstrInfo::lowerSelect(SIInstrWorklist &Worklist, MachineInstr &Inst,
Register CondReg = Cond.getReg();
bool IsSCC = (CondReg == AMDGPU::SCC);
- // If this is a trivial select where the condition is effectively not SCC
- // (CondReg is a source of copy to SCC), then the select is semantically
- // equivalent to copying CondReg. Hence, there is no need to create
- // V_CNDMASK, we can just use that and bail out.
+ // Remove S_CSELECT instructions that we previously inserted to feed the SCC
+ // condition output from S_CMP into the SGPR condition input of V_CNDMASK. If
+ // the S_CMP has been promoted to V_CMP then we can feed its SGPR condition
+ // output directly into the V_CNDMASK.
if (!IsSCC && Src0.isImm() && (Src0.getImm() == -1) && Src1.isImm() &&
(Src1.getImm() == 0)) {
- MRI.replaceRegWith(Dest.getReg(), CondReg);
----------------
jayfoad wrote:
The new uniform sext patterns can generate `S_CSELECT -1, 0` which were getting removed here wrongly. I had to tighten the checks so that we only remove them if they're feeding into the condition input of V_CNDMASK. @alex-t FYI.
https://github.com/llvm/llvm-project/pull/204238
More information about the llvm-commits
mailing list