[llvm] [GlobalIsel] Combine select to integer minmax (second attemnt). (PR #77520)
Thorsten Schütt via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 9 12:51:05 PST 2024
================
@@ -6548,6 +6548,87 @@ bool CombinerHelper::tryFoldBoolSelectToLogic(GSelect *Select,
return false;
}
+bool CombinerHelper::tryFoldSelectToIntMinMax(GSelect *Select,
+ BuildFnTy &MatchInfo) {
+ Register DstReg = Select->getReg(0);
+ Register Cond = Select->getCondReg();
+ Register True = Select->getTrueReg();
+ Register False = Select->getFalseReg();
+ LLT DstTy = MRI.getType(DstReg);
+
+ // We need an G_ICMP on the condition register.
+ GICmp *Cmp = getOpcodeDef<GICmp>(Cond, MRI);
+ if (!Cmp)
+ return false;
+
+ // We want to fold the icmp and replace the select.
+ if (!MRI.hasOneNonDBGUse(Cmp->getReg(0)))
----------------
tschuett wrote:
one use one icmp.
https://github.com/llvm/llvm-project/pull/77520
More information about the llvm-commits
mailing list