[llvm] [AMDGPU] Remove redundant s_cmp_lg_* sX, 0 (PR #162352)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 7 21:37:01 PDT 2025
================
@@ -10608,6 +10608,73 @@ bool SIInstrInfo::optimizeCompareInstr(MachineInstr &CmpInstr, Register SrcReg,
if (SrcReg2 && !getFoldableImm(SrcReg2, *MRI, CmpValue))
return false;
+ const auto optimizeCmpSelect = [&CmpInstr, SrcReg, CmpValue, MRI,
+ this]() -> bool {
+ if (CmpValue != 0)
+ return false;
+
+ MachineInstr *Def = MRI->getUniqueVRegDef(SrcReg);
+ if (!Def || Def->getParent() != CmpInstr.getParent())
+ return false;
+
+ if (!(Def->getOpcode() == AMDGPU::S_LSHL_B32 ||
----------------
LU-JOHN wrote:
It should be all instructions that set SCC = DST!=0. s_max/s_min are excluded since they set SCC but with a different condition. I need to review the list since I missed some instructions that should be included (e.g. s_absdiff).
https://github.com/llvm/llvm-project/pull/162352
More information about the llvm-commits
mailing list