Skip to content

Commit 65136a3

Browse files
authored
SCEV: migrate LoopInvariantPredicate to CmpPredicate (NFC) (llvm#125204)
Follow up on 60dc450 (SCEV: migrate to CmpPredicate (NFC)) to migrate the missed ScalarEvolution::LoopInvariantPredicate to CmpPredicate.
1 parent e31c6c9 commit 65136a3

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

llvm/include/llvm/Analysis/ScalarEvolution.h

+4-6
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

+4-5
Original file line numberDiff line numberDiff line change
@@ -11165,17 +11165,16 @@ ScalarEvolution::getMonotonicPredicateTypeImpl(const SCEVAddRecExpr *LHS,
1116511165
}
1116611166

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

1117711176
std::swap(LHS, RHS);
11178-
Pred = ICmpInst::getSwappedPredicate(Pred);
11177+
Pred = ICmpInst::getSwappedCmpPredicate(Pred);
1117911178
}
1118011179

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

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

0 commit comments

Comments
 (0)