[llvm] 8d5bf07 - [NFC] Prefer ConstantRange::makeExactICmpRegion over makeAllowedICmpRegion
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 25 14:44:12 PDT 2021
Author: Eli Friedman
Date: 2021-06-25T14:43:13-07:00
New Revision: 8d5bf0709da893cee20f9b3100bf1bcd4a5f0210
URL: https://github.com/llvm/llvm-project/commit/8d5bf0709da893cee20f9b3100bf1bcd4a5f0210
DIFF: https://github.com/llvm/llvm-project/commit/8d5bf0709da893cee20f9b3100bf1bcd4a5f0210.diff
LOG: [NFC] Prefer ConstantRange::makeExactICmpRegion over makeAllowedICmpRegion
The implementation is identical, but it makes the semantics a bit more
obvious.
Added:
Modified:
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/lib/Analysis/ValueTracking.cpp
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 34e671b7a72f..990f3d6040f4 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -11369,7 +11369,7 @@ bool ScalarEvolution::isImpliedCondOperandsViaRanges(ICmpInst::Predicate Pred,
// `FoundLHSRange` is the range we know `FoundLHS` to be in by virtue of the
// antecedent "`FoundLHS` `Pred` `FoundRHS`".
ConstantRange FoundLHSRange =
- ConstantRange::makeAllowedICmpRegion(Pred, ConstFoundRHS);
+ ConstantRange::makeExactICmpRegion(Pred, ConstFoundRHS);
// Since `LHS` is `FoundLHS` + `Addend`, we can compute a range for `LHS`:
ConstantRange LHSRange = FoundLHSRange.add(ConstantRange(*Addend));
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 276a5a4c09c9..e877fb1155f3 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -6465,8 +6465,7 @@ isImpliedCondMatchingImmOperands(CmpInst::Predicate APred,
const ConstantInt *C2) {
ConstantRange DomCR =
ConstantRange::makeExactICmpRegion(APred, C1->getValue());
- ConstantRange CR =
- ConstantRange::makeAllowedICmpRegion(BPred, C2->getValue());
+ ConstantRange CR = ConstantRange::makeExactICmpRegion(BPred, C2->getValue());
ConstantRange Intersection = DomCR.intersectWith(CR);
ConstantRange Difference = DomCR.
diff erence(CR);
if (Intersection.isEmptySet())
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 7cafe46b75f8..0c1629d49bd9 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -1497,7 +1497,7 @@ Instruction *InstCombinerImpl::foldICmpWithDominatingICmp(ICmpInst &Cmp) {
// br DomCond, CmpBB, FalseBB
// CmpBB:
// Cmp = icmp Pred X, C
- ConstantRange CR = ConstantRange::makeAllowedICmpRegion(Pred, *C);
+ ConstantRange CR = ConstantRange::makeExactICmpRegion(Pred, *C);
ConstantRange DominatingCR =
(CmpBB == TrueBB) ? ConstantRange::makeExactICmpRegion(DomPred, *DomC)
: ConstantRange::makeExactICmpRegion(
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 6c3acb8bbc7a..6288a6232655 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -621,8 +621,8 @@ struct ConstantComparesGatherer {
}
// If we have "x ult 3", for example, then we can add 0,1,2 to the set.
- ConstantRange Span = ConstantRange::makeAllowedICmpRegion(
- ICI->getPredicate(), C->getValue());
+ ConstantRange Span =
+ ConstantRange::makeExactICmpRegion(ICI->getPredicate(), C->getValue());
// Shift the range if the compare is fed by an add. This is the range
// compare idiom as emitted by instcombine.
More information about the llvm-commits
mailing list