From 6e6e189f2ca6d03d2fb2c9b82342bcd70f41b65f Mon Sep 17 00:00:00 2001 From: Ramkumar Ramachandra Date: Fri, 31 Jan 2025 11:05:19 +0000 Subject: [PATCH] SCEV: migrate LoopInvariantPredicate to CmpPredicate (NFC) Follow up on 60dc450 (SCEV: migrate to CmpPredicate (NFC)) to migrate the missed ScalarEvolution::LoopInvariantPredicate to CmpPredicate. --- llvm/include/llvm/Analysis/ScalarEvolution.h | 10 ++++------ llvm/lib/Analysis/ScalarEvolution.cpp | 9 ++++----- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h index a011f16b4d95c..f729b07076d29 100644 --- a/llvm/include/llvm/Analysis/ScalarEvolution.h +++ b/llvm/include/llvm/Analysis/ScalarEvolution.h @@ -1188,21 +1188,19 @@ class ScalarEvolution { ICmpInst::Predicate Pred); struct LoopInvariantPredicate { - ICmpInst::Predicate Pred; + CmpPredicate Pred; const SCEV *LHS; const SCEV *RHS; - LoopInvariantPredicate(ICmpInst::Predicate Pred, const SCEV *LHS, - const SCEV *RHS) + LoopInvariantPredicate(CmpPredicate Pred, const SCEV *LHS, const SCEV *RHS) : Pred(Pred), LHS(LHS), RHS(RHS) {} }; /// If the result of the predicate LHS `Pred` RHS is loop invariant with /// respect to L, return a LoopInvariantPredicate with LHS and RHS being /// invariants, available at L's entry. Otherwise, return std::nullopt. std::optional - getLoopInvariantPredicate(ICmpInst::Predicate Pred, const SCEV *LHS, - const SCEV *RHS, const Loop *L, - const Instruction *CtxI = nullptr); + getLoopInvariantPredicate(CmpPredicate Pred, const SCEV *LHS, const SCEV *RHS, + const Loop *L, const Instruction *CtxI = nullptr); /// If the result of the predicate LHS `Pred` RHS is loop invariant with /// respect to L at given Context during at least first MaxIter iterations, diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 7d7d37b3d228d..71d725be59770 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -11167,9 +11167,8 @@ ScalarEvolution::getMonotonicPredicateTypeImpl(const SCEVAddRecExpr *LHS, } std::optional -ScalarEvolution::getLoopInvariantPredicate(ICmpInst::Predicate Pred, - const SCEV *LHS, const SCEV *RHS, - const Loop *L, +ScalarEvolution::getLoopInvariantPredicate(CmpPredicate Pred, const SCEV *LHS, + const SCEV *RHS, const Loop *L, const Instruction *CtxI) { // If there is a loop-invariant, force it into the RHS, otherwise bail out. if (!isLoopInvariant(RHS, L)) { @@ -11177,7 +11176,7 @@ ScalarEvolution::getLoopInvariantPredicate(ICmpInst::Predicate Pred, return std::nullopt; std::swap(LHS, RHS); - Pred = ICmpInst::getSwappedPredicate(Pred); + Pred = ICmpInst::getSwappedCmpPredicate(Pred); } const SCEVAddRecExpr *ArLHS = dyn_cast(LHS); @@ -11205,7 +11204,7 @@ ScalarEvolution::getLoopInvariantPredicate(ICmpInst::Predicate Pred, // A similar reasoning applies for a monotonically decreasing predicate, by // replacing true with false and false with true in the above two bullets. bool Increasing = *MonotonicType == ScalarEvolution::MonotonicallyIncreasing; - auto P = Increasing ? Pred : ICmpInst::getInversePredicate(Pred); + auto P = Increasing ? Pred : ICmpInst::getInverseCmpPredicate(Pred); if (isLoopBackedgeGuardedByCond(L, P, LHS, RHS)) return ScalarEvolution::LoopInvariantPredicate(Pred, ArLHS->getStart(),