Skip to content

Commit 6e6e189

Browse files
committed
SCEV: migrate LoopInvariantPredicate to CmpPredicate (NFC)
Follow up on 60dc450 (SCEV: migrate to CmpPredicate (NFC)) to migrate the missed ScalarEvolution::LoopInvariantPredicate to CmpPredicate.
1 parent 3a4376b commit 6e6e189

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

llvm/include/llvm/Analysis/ScalarEvolution.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,21 +1188,19 @@ class ScalarEvolution {
11881188
ICmpInst::Predicate Pred);
11891189

11901190
struct LoopInvariantPredicate {
1191-
ICmpInst::Predicate Pred;
1191+
CmpPredicate Pred;
11921192
const SCEV *LHS;
11931193
const SCEV *RHS;
11941194

1195-
LoopInvariantPredicate(ICmpInst::Predicate Pred, const SCEV *LHS,
1196-
const SCEV *RHS)
1195+
LoopInvariantPredicate(CmpPredicate Pred, const SCEV *LHS, const SCEV *RHS)
11971196
: Pred(Pred), LHS(LHS), RHS(RHS) {}
11981197
};
11991198
/// If the result of the predicate LHS `Pred` RHS is loop invariant with
12001199
/// respect to L, return a LoopInvariantPredicate with LHS and RHS being
12011200
/// invariants, available at L's entry. Otherwise, return std::nullopt.
12021201
std::optional<LoopInvariantPredicate>
1203-
getLoopInvariantPredicate(ICmpInst::Predicate Pred, const SCEV *LHS,
1204-
const SCEV *RHS, const Loop *L,
1205-
const Instruction *CtxI = nullptr);
1202+
getLoopInvariantPredicate(CmpPredicate Pred, const SCEV *LHS, const SCEV *RHS,
1203+
const Loop *L, const Instruction *CtxI = nullptr);
12061204

12071205
/// If the result of the predicate LHS `Pred` RHS is loop invariant with
12081206
/// respect to L at given Context during at least first MaxIter iterations,

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11167,17 +11167,16 @@ ScalarEvolution::getMonotonicPredicateTypeImpl(const SCEVAddRecExpr *LHS,
1116711167
}
1116811168

1116911169
std::optional<ScalarEvolution::LoopInvariantPredicate>
11170-
ScalarEvolution::getLoopInvariantPredicate(ICmpInst::Predicate Pred,
11171-
const SCEV *LHS, const SCEV *RHS,
11172-
const Loop *L,
11170+
ScalarEvolution::getLoopInvariantPredicate(CmpPredicate Pred, const SCEV *LHS,
11171+
const SCEV *RHS, const Loop *L,
1117311172
const Instruction *CtxI) {
1117411173
// If there is a loop-invariant, force it into the RHS, otherwise bail out.
1117511174
if (!isLoopInvariant(RHS, L)) {
1117611175
if (!isLoopInvariant(LHS, L))
1117711176
return std::nullopt;
1117811177

1117911178
std::swap(LHS, RHS);
11180-
Pred = ICmpInst::getSwappedPredicate(Pred);
11179+
Pred = ICmpInst::getSwappedCmpPredicate(Pred);
1118111180
}
1118211181

1118311182
const SCEVAddRecExpr *ArLHS = dyn_cast<SCEVAddRecExpr>(LHS);
@@ -11205,7 +11204,7 @@ ScalarEvolution::getLoopInvariantPredicate(ICmpInst::Predicate Pred,
1120511204
// A similar reasoning applies for a monotonically decreasing predicate, by
1120611205
// replacing true with false and false with true in the above two bullets.
1120711206
bool Increasing = *MonotonicType == ScalarEvolution::MonotonicallyIncreasing;
11208-
auto P = Increasing ? Pred : ICmpInst::getInversePredicate(Pred);
11207+
auto P = Increasing ? Pred : ICmpInst::getInverseCmpPredicate(Pred);
1120911208

1121011209
if (isLoopBackedgeGuardedByCond(L, P, LHS, RHS))
1121111210
return ScalarEvolution::LoopInvariantPredicate(Pred, ArLHS->getStart(),

0 commit comments

Comments
 (0)