From: Eli Friedman Date: Fri, 25 Jun 2021 21:43:13 +0000 (-0700) Subject: [NFC] Prefer ConstantRange::makeExactICmpRegion over makeAllowedICmpRegion X-Git-Tag: llvmorg-14-init~2962 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8d5bf0709da893cee20f9b3100bf1bcd4a5f0210;p=platform%2Fupstream%2Fllvm.git [NFC] Prefer ConstantRange::makeExactICmpRegion over makeAllowedICmpRegion The implementation is identical, but it makes the semantics a bit more obvious. --- diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 34e671b..990f3d6 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 276a5a4..e877fb1 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.difference(CR); if (Intersection.isEmptySet()) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index 7cafe46..0c1629d 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 6c3acb8..6288a62 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -621,8 +621,8 @@ private: } // 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.