[llvm] LICM: teach hoistMinMax about samesign (PR #122730)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 13 07:57:51 PST 2025
================
@@ -2453,16 +2453,16 @@ static bool hoistMinMax(Instruction &I, Loop &L, ICFLoopSafetyInfo &SafetyInfo,
if (!MatchICmpAgainstInvariant(Cond1, P1, LHS1, RHS1) ||
!MatchICmpAgainstInvariant(Cond2, P2, LHS2, RHS2))
return false;
- // FIXME: Use CmpPredicate::getMatching here.
- if (P1 != static_cast<CmpInst::Predicate>(P2) || LHS1 != LHS2)
+ auto MatchingPred = CmpPredicate::getMatching(P1, P2);
+ if (!MatchingPred || LHS1 != LHS2)
return false;
// Everything is fine, we can do the transform.
bool UseMin = ICmpInst::isLT(P1) || ICmpInst::isLE(P1);
----------------
nikic wrote:
Also use MatchingPred here? Strictly speaking doesn't matter as these checks are signedness independent, but better safe than sorry.
https://github.com/llvm/llvm-project/pull/122730
More information about the llvm-commits
mailing list