aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2022-02-08 06:56:05 -0800
committerPhilip Reames <listmail@philipreames.com>2022-02-08 08:18:09 -0800
commitc302f1e6771b0cbfad466e56f19e36d4dcaecd11 (patch)
treecc59bea6247b7d5b2bc6cc3b89ae2b94939845bd /llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
parent074561a4a22f610d756109170285d8626c4cc3bc (diff)
downloadllvm-c302f1e6771b0cbfad466e56f19e36d4dcaecd11.zip
llvm-c302f1e6771b0cbfad466e56f19e36d4dcaecd11.tar.gz
llvm-c302f1e6771b0cbfad466e56f19e36d4dcaecd11.tar.bz2
[SCEV] Generalize SCEVEqualsPredicate to any compare [NFC]
PredicatedScalarEvolution has a predicate type for representing A == B. This change generalizes it into something which can represent a A <pred> B. This generality is currently unused, but is motivated by a couple of recent cases which have come up. In particular, I'm currently playing around with using this to simplify the runtime checking code in LoopVectorizer. Regardless of the outcome of that prototyping, generalizing the compare node seemed useful.
Diffstat (limited to 'llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
index 277431f..fbd42ce 100644
--- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
@@ -2469,8 +2469,8 @@ Value *SCEVExpander::expandCodeForPredicate(const SCEVPredicate *Pred,
switch (Pred->getKind()) {
case SCEVPredicate::P_Union:
return expandUnionPredicate(cast<SCEVUnionPredicate>(Pred), IP);
- case SCEVPredicate::P_Equal:
- return expandEqualPredicate(cast<SCEVEqualPredicate>(Pred), IP);
+ case SCEVPredicate::P_Compare:
+ return expandComparePredicate(cast<SCEVComparePredicate>(Pred), IP);
case SCEVPredicate::P_Wrap: {
auto *AddRecPred = cast<SCEVWrapPredicate>(Pred);
return expandWrapPredicate(AddRecPred, IP);
@@ -2479,15 +2479,16 @@ Value *SCEVExpander::expandCodeForPredicate(const SCEVPredicate *Pred,
llvm_unreachable("Unknown SCEV predicate type");
}
-Value *SCEVExpander::expandEqualPredicate(const SCEVEqualPredicate *Pred,
- Instruction *IP) {
+Value *SCEVExpander::expandComparePredicate(const SCEVComparePredicate *Pred,
+ Instruction *IP) {
Value *Expr0 =
expandCodeForImpl(Pred->getLHS(), Pred->getLHS()->getType(), IP, false);
Value *Expr1 =
expandCodeForImpl(Pred->getRHS(), Pred->getRHS()->getType(), IP, false);
Builder.SetInsertPoint(IP);
- auto *I = Builder.CreateICmpNE(Expr0, Expr1, "ident.check");
+ auto InvPred = ICmpInst::getInversePredicate(Pred->getPredicate());
+ auto *I = Builder.CreateICmp(InvPred, Expr0, Expr1, "ident.check");
return I;
}