@@ -1743,24 +1743,24 @@ static PointerBounds expandBounds(const RuntimeCheckingPtrGroup *CG,
1743
1743
auto *HighAR = cast<SCEVAddRecExpr>(High);
1744
1744
auto *LowAR = cast<SCEVAddRecExpr>(Low);
1745
1745
const Loop *OuterLoop = TheLoop->getParentLoop ();
1746
- const SCEV *Recur = LowAR->getStepRecurrence (*Exp.getSE ());
1747
- if (Recur == HighAR->getStepRecurrence (*Exp.getSE ()) &&
1746
+ ScalarEvolution &SE = *Exp.getSE ();
1747
+ const SCEV *Recur = LowAR->getStepRecurrence (SE);
1748
+ if (Recur == HighAR->getStepRecurrence (SE) &&
1748
1749
HighAR->getLoop () == OuterLoop && LowAR->getLoop () == OuterLoop) {
1749
1750
BasicBlock *OuterLoopLatch = OuterLoop->getLoopLatch ();
1750
- const SCEV *OuterExitCount =
1751
- Exp.getSE ()->getExitCount (OuterLoop, OuterLoopLatch);
1751
+ const SCEV *OuterExitCount = SE.getExitCount (OuterLoop, OuterLoopLatch);
1752
1752
if (!isa<SCEVCouldNotCompute>(OuterExitCount) &&
1753
1753
OuterExitCount->getType ()->isIntegerTy ()) {
1754
- const SCEV *NewHigh = cast<SCEVAddRecExpr>(High)-> evaluateAtIteration (
1755
- OuterExitCount, *Exp. getSE () );
1754
+ const SCEV *NewHigh =
1755
+ cast<SCEVAddRecExpr>(High)-> evaluateAtIteration ( OuterExitCount, SE );
1756
1756
if (!isa<SCEVCouldNotCompute>(NewHigh)) {
1757
1757
LLVM_DEBUG (dbgs () << " LAA: Expanded RT check for range to include "
1758
1758
" outer loop in order to permit hoisting\n " );
1759
1759
High = NewHigh;
1760
1760
Low = cast<SCEVAddRecExpr>(Low)->getStart ();
1761
1761
// If there is a possibility that the stride is negative then we have
1762
1762
// to generate extra checks to ensure the stride is positive.
1763
- if (!Exp. getSE ()-> isKnownNonNegative (Recur)) {
1763
+ if (!SE. isKnownNonNegative (Recur)) {
1764
1764
Stride = Recur;
1765
1765
LLVM_DEBUG (dbgs () << " LAA: ... but need to check stride is "
1766
1766
" positive: "
@@ -1821,8 +1821,7 @@ Value *llvm::addRuntimeChecks(
1821
1821
// Our instructions might fold to a constant.
1822
1822
Value *MemoryRuntimeCheck = nullptr ;
1823
1823
1824
- for (const auto &Check : ExpandedChecks) {
1825
- const PointerBounds &A = Check.first , &B = Check.second ;
1824
+ for (const auto &[A, B] : ExpandedChecks) {
1826
1825
// Check if two pointers (A and B) conflict where conflict is computed as:
1827
1826
// start(A) <= end(B) && start(B) <= end(A)
1828
1827
@@ -1880,14 +1879,14 @@ Value *llvm::addDiffRuntimeChecks(
1880
1879
// Map to keep track of created compares, The key is the pair of operands for
1881
1880
// the compare, to allow detecting and re-using redundant compares.
1882
1881
DenseMap<std::pair<Value *, Value *>, Value *> SeenCompares;
1883
- for (const auto &C : Checks) {
1884
- Type *Ty = C. SinkStart ->getType ();
1882
+ for (const auto &[SrcStart, SinkStart, AccessSize, NeedsFreeze] : Checks) {
1883
+ Type *Ty = SinkStart->getType ();
1885
1884
// Compute VF * IC * AccessSize.
1886
1885
auto *VFTimesUFTimesSize =
1887
1886
ChkBuilder.CreateMul (GetVF (ChkBuilder, Ty->getScalarSizeInBits ()),
1888
- ConstantInt::get (Ty, IC * C. AccessSize ));
1889
- Value *Diff = Expander. expandCodeFor (
1890
- SE.getMinusSCEV (C. SinkStart , C. SrcStart ), Ty, Loc);
1887
+ ConstantInt::get (Ty, IC * AccessSize));
1888
+ Value *Diff =
1889
+ Expander. expandCodeFor ( SE.getMinusSCEV (SinkStart, SrcStart), Ty, Loc);
1891
1890
1892
1891
// Check if the same compare has already been created earlier. In that case,
1893
1892
// there is no need to check it again.
@@ -1898,7 +1897,7 @@ Value *llvm::addDiffRuntimeChecks(
1898
1897
IsConflict =
1899
1898
ChkBuilder.CreateICmpULT (Diff, VFTimesUFTimesSize, " diff.check" );
1900
1899
SeenCompares.insert ({{Diff, VFTimesUFTimesSize}, IsConflict});
1901
- if (C. NeedsFreeze )
1900
+ if (NeedsFreeze)
1902
1901
IsConflict =
1903
1902
ChkBuilder.CreateFreeze (IsConflict, IsConflict->getName () + " .fr" );
1904
1903
if (MemoryRuntimeCheck) {
0 commit comments