Skip to content

Commit 8d5bf07

Browse files
committed
[NFC] Prefer ConstantRange::makeExactICmpRegion over makeAllowedICmpRegion
The implementation is identical, but it makes the semantics a bit more obvious.
1 parent c8d0d8a commit 8d5bf07

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11369,7 +11369,7 @@ bool ScalarEvolution::isImpliedCondOperandsViaRanges(ICmpInst::Predicate Pred,
1136911369
// `FoundLHSRange` is the range we know `FoundLHS` to be in by virtue of the
1137011370
// antecedent "`FoundLHS` `Pred` `FoundRHS`".
1137111371
ConstantRange FoundLHSRange =
11372-
ConstantRange::makeAllowedICmpRegion(Pred, ConstFoundRHS);
11372+
ConstantRange::makeExactICmpRegion(Pred, ConstFoundRHS);
1137311373

1137411374
// Since `LHS` is `FoundLHS` + `Addend`, we can compute a range for `LHS`:
1137511375
ConstantRange LHSRange = FoundLHSRange.add(ConstantRange(*Addend));

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6465,8 +6465,7 @@ isImpliedCondMatchingImmOperands(CmpInst::Predicate APred,
64656465
const ConstantInt *C2) {
64666466
ConstantRange DomCR =
64676467
ConstantRange::makeExactICmpRegion(APred, C1->getValue());
6468-
ConstantRange CR =
6469-
ConstantRange::makeAllowedICmpRegion(BPred, C2->getValue());
6468+
ConstantRange CR = ConstantRange::makeExactICmpRegion(BPred, C2->getValue());
64706469
ConstantRange Intersection = DomCR.intersectWith(CR);
64716470
ConstantRange Difference = DomCR.difference(CR);
64726471
if (Intersection.isEmptySet())

llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1497,7 +1497,7 @@ Instruction *InstCombinerImpl::foldICmpWithDominatingICmp(ICmpInst &Cmp) {
14971497
// br DomCond, CmpBB, FalseBB
14981498
// CmpBB:
14991499
// Cmp = icmp Pred X, C
1500-
ConstantRange CR = ConstantRange::makeAllowedICmpRegion(Pred, *C);
1500+
ConstantRange CR = ConstantRange::makeExactICmpRegion(Pred, *C);
15011501
ConstantRange DominatingCR =
15021502
(CmpBB == TrueBB) ? ConstantRange::makeExactICmpRegion(DomPred, *DomC)
15031503
: ConstantRange::makeExactICmpRegion(

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,8 +621,8 @@ struct ConstantComparesGatherer {
621621
}
622622

623623
// If we have "x ult 3", for example, then we can add 0,1,2 to the set.
624-
ConstantRange Span = ConstantRange::makeAllowedICmpRegion(
625-
ICI->getPredicate(), C->getValue());
624+
ConstantRange Span =
625+
ConstantRange::makeExactICmpRegion(ICI->getPredicate(), C->getValue());
626626

627627
// Shift the range if the compare is fed by an add. This is the range
628628
// compare idiom as emitted by instcombine.

0 commit comments

Comments
 (0)