@@ -392,9 +392,9 @@ void RuntimePointerChecking::generateChecks(
392
392
393
393
bool RuntimePointerChecking::needsChecking (
394
394
const RuntimeCheckingPtrGroup &M, const RuntimeCheckingPtrGroup &N) const {
395
- for (unsigned I = 0 , EI = M.Members . size (); EI != I; ++I )
396
- for (unsigned J = 0 , EJ = N.Members . size (); EJ != J; ++J )
397
- if (needsChecking (M. Members [I], N. Members [J] ))
395
+ for (const auto &I : M.Members )
396
+ for (const auto &J : N.Members )
397
+ if (needsChecking (I, J ))
398
398
return true ;
399
399
return false ;
400
400
}
@@ -408,9 +408,7 @@ static const SCEV *getMinFromExprs(const SCEV *I, const SCEV *J,
408
408
409
409
if (!C)
410
410
return nullptr ;
411
- if (C->getValue ()->isNegative ())
412
- return J;
413
- return I;
411
+ return C->getValue ()->isNegative () ? J : I;
414
412
}
415
413
416
414
bool RuntimeCheckingPtrGroup::addPointer (unsigned Index,
@@ -508,8 +506,8 @@ void RuntimePointerChecking::groupChecks(
508
506
509
507
DenseMap<Value *, SmallVector<unsigned >> PositionMap;
510
508
for (unsigned Index = 0 ; Index < Pointers.size (); ++Index) {
511
- auto Iter = PositionMap.insert ({Pointers[Index].PointerValue , {}});
512
- Iter. first ->second .push_back (Index);
509
+ auto [It, _] = PositionMap.insert ({Pointers[Index].PointerValue , {}});
510
+ It ->second .push_back (Index);
513
511
}
514
512
515
513
// We need to keep track of what pointers we've already seen so we
@@ -608,16 +606,16 @@ void RuntimePointerChecking::printChecks(
608
606
raw_ostream &OS, const SmallVectorImpl<RuntimePointerCheck> &Checks,
609
607
unsigned Depth) const {
610
608
unsigned N = 0 ;
611
- for (const auto &Check : Checks) {
612
- const auto &First = Check. first ->Members , &Second = Check. second ->Members ;
609
+ for (const auto &[Check1, Check2] : Checks) {
610
+ const auto &First = Check1 ->Members , &Second = Check2 ->Members ;
613
611
614
612
OS.indent (Depth) << " Check " << N++ << " :\n " ;
615
613
616
- OS.indent (Depth + 2 ) << " Comparing group (" << Check. first << " ):\n " ;
614
+ OS.indent (Depth + 2 ) << " Comparing group (" << Check1 << " ):\n " ;
617
615
for (unsigned K = 0 ; K < First.size (); ++K)
618
616
OS.indent (Depth + 2 ) << *Pointers[First[K]].PointerValue << " \n " ;
619
617
620
- OS.indent (Depth + 2 ) << " Against group (" << Check. second << " ):\n " ;
618
+ OS.indent (Depth + 2 ) << " Against group (" << Check2 << " ):\n " ;
621
619
for (unsigned K = 0 ; K < Second.size (); ++K)
622
620
OS.indent (Depth + 2 ) << *Pointers[Second[K]].PointerValue << " \n " ;
623
621
}
@@ -1158,8 +1156,8 @@ bool AccessAnalysis::canCheckPtrAtRT(RuntimePointerChecking &RtCheck,
1158
1156
// First, count how many write and read accesses are in the alias set. Also
1159
1157
// collect MemAccessInfos for later.
1160
1158
SmallVector<MemAccessInfo, 4 > AccessInfos;
1161
- for (const Value *Ptr_ : ASPointers) {
1162
- Value *Ptr = const_cast <Value *>(Ptr_ );
1159
+ for (const Value *ConstPtr : ASPointers) {
1160
+ Value *Ptr = const_cast <Value *>(ConstPtr );
1163
1161
bool IsWrite = Accesses.count (MemAccessInfo (Ptr, true ));
1164
1162
if (IsWrite)
1165
1163
++NumWritePtrChecks;
@@ -1215,9 +1213,7 @@ bool AccessAnalysis::canCheckPtrAtRT(RuntimePointerChecking &RtCheck,
1215
1213
// We know that we need these checks, so we can now be more aggressive
1216
1214
// and add further checks if required (overflow checks).
1217
1215
CanDoAliasSetRT = true ;
1218
- for (auto Retry : Retries) {
1219
- MemAccessInfo Access = Retry.first ;
1220
- Type *AccessTy = Retry.second ;
1216
+ for (const auto &[Access, AccessTy] : Retries) {
1221
1217
if (!createCheckForAccess (RtCheck, Access, AccessTy, StridesMap,
1222
1218
DepSetId, TheLoop, RunningDepId, ASId,
1223
1219
ShouldCheckWrap, /* Assume=*/ true )) {
@@ -1289,12 +1285,11 @@ void AccessAnalysis::processMemAccesses() {
1289
1285
LLVM_DEBUG (dbgs () << " AST: " ; AST.dump ());
1290
1286
LLVM_DEBUG (dbgs () << " LAA: Accesses(" << Accesses.size () << " ):\n " );
1291
1287
LLVM_DEBUG ({
1292
- for (auto A : Accesses)
1293
- dbgs () << " \t " << *A.first .getPointer () << " ("
1294
- << (A.first .getInt ()
1295
- ? " write"
1296
- : (ReadOnlyPtr.count (A.first .getPointer ()) ? " read-only"
1297
- : " read" ))
1288
+ for (const auto &[A, _] : Accesses)
1289
+ dbgs () << " \t " << *A.getPointer () << " ("
1290
+ << (A.getInt () ? " write"
1291
+ : (ReadOnlyPtr.count (A.getPointer ()) ? " read-only"
1292
+ : " read" ))
1298
1293
<< " )\n " ;
1299
1294
});
1300
1295
@@ -1323,16 +1318,16 @@ void AccessAnalysis::processMemAccesses() {
1323
1318
bool UseDeferred = SetIteration > 0 ;
1324
1319
PtrAccessMap &S = UseDeferred ? DeferredAccesses : Accesses;
1325
1320
1326
- for (const Value *Ptr_ : ASPointers) {
1327
- Value *Ptr = const_cast <Value *>(Ptr_ );
1321
+ for (const Value *ConstPtr : ASPointers) {
1322
+ Value *Ptr = const_cast <Value *>(ConstPtr );
1328
1323
1329
1324
// For a single memory access in AliasSetTracker, Accesses may contain
1330
1325
// both read and write, and they both need to be handled for CheckDeps.
1331
- for (const auto &AC : S) {
1332
- if (AC.first . getPointer () != Ptr)
1326
+ for (const auto &[AC, _] : S) {
1327
+ if (AC.getPointer () != Ptr)
1333
1328
continue ;
1334
1329
1335
- bool IsWrite = AC.first . getInt ();
1330
+ bool IsWrite = AC.getInt ();
1336
1331
1337
1332
// If we're using the deferred access set, then it contains only
1338
1333
// reads.
@@ -1859,10 +1854,7 @@ static bool isSafeDependenceDistance(const DataLayout &DL, ScalarEvolution &SE,
1859
1854
// (If so, then we have proven (**) because |Dist| >= -1*Dist)
1860
1855
const SCEV *NegDist = SE.getNegativeSCEV (CastedDist);
1861
1856
Minus = SE.getMinusSCEV (NegDist, CastedProduct);
1862
- if (SE.isKnownPositive (Minus))
1863
- return true ;
1864
-
1865
- return false ;
1857
+ return SE.isKnownPositive (Minus);
1866
1858
}
1867
1859
1868
1860
// / Check the dependence for two accesses with the same stride \p Stride.
@@ -2050,7 +2042,7 @@ MemoryDepChecker::Dependence::DepType MemoryDepChecker::isDependent(
2050
2042
if (isa<SCEVCouldNotCompute>(Dist)) {
2051
2043
// TODO: Relax requirement that there is a common stride to retry with
2052
2044
// non-constant distance dependencies.
2053
- FoundNonConstantDistanceDependence |= !! CommonStride;
2045
+ FoundNonConstantDistanceDependence |= CommonStride. has_value () ;
2054
2046
LLVM_DEBUG (dbgs () << " LAA: Dependence because of uncomputable distance.\n " );
2055
2047
return Dependence::Unknown;
2056
2048
}
@@ -2093,11 +2085,10 @@ MemoryDepChecker::Dependence::DepType MemoryDepChecker::isDependent(
2093
2085
if (HasSameSize) {
2094
2086
// Write to the same location with the same size.
2095
2087
return Dependence::Forward;
2096
- } else {
2097
- LLVM_DEBUG (dbgs () << " LAA: possibly zero dependence difference but "
2098
- " different type sizes\n " );
2099
- return Dependence::Unknown;
2100
2088
}
2089
+ LLVM_DEBUG (dbgs () << " LAA: possibly zero dependence difference but "
2090
+ " different type sizes\n " );
2091
+ return Dependence::Unknown;
2101
2092
}
2102
2093
2103
2094
bool IsTrueDataDependence = (AIsWrite && !BIsWrite);
@@ -2343,7 +2334,7 @@ bool MemoryDepChecker::areDepsSafe(
2343
2334
}
2344
2335
++OI;
2345
2336
}
2346
- AI++ ;
2337
+ ++AI ;
2347
2338
}
2348
2339
}
2349
2340
@@ -2352,8 +2343,8 @@ bool MemoryDepChecker::areDepsSafe(
2352
2343
}
2353
2344
2354
2345
SmallVector<Instruction *, 4 >
2355
- MemoryDepChecker::getInstructionsForAccess (Value *Ptr, bool isWrite ) const {
2356
- MemAccessInfo Access (Ptr, isWrite );
2346
+ MemoryDepChecker::getInstructionsForAccess (Value *Ptr, bool IsWrite ) const {
2347
+ MemAccessInfo Access (Ptr, IsWrite );
2357
2348
auto &IndexVector = Accesses.find (Access)->second ;
2358
2349
2359
2350
SmallVector<Instruction *, 4 > Insts;
@@ -2729,13 +2720,14 @@ void LoopAccessInfo::analyzeLoop(AAResults *AA, LoopInfo *LI,
2729
2720
}
2730
2721
2731
2722
void LoopAccessInfo::emitUnsafeDependenceRemark () {
2732
- auto Deps = getDepChecker ().getDependences ();
2723
+ const auto * Deps = getDepChecker ().getDependences ();
2733
2724
if (!Deps)
2734
2725
return ;
2735
- auto Found = llvm::find_if (*Deps, [](const MemoryDepChecker::Dependence &D) {
2736
- return MemoryDepChecker::Dependence::isSafeForVectorization (D.Type ) !=
2737
- MemoryDepChecker::VectorizationSafetyStatus::Safe;
2738
- });
2726
+ const auto *Found =
2727
+ llvm::find_if (*Deps, [](const MemoryDepChecker::Dependence &D) {
2728
+ return MemoryDepChecker::Dependence::isSafeForVectorization (D.Type ) !=
2729
+ MemoryDepChecker::VectorizationSafetyStatus::Safe;
2730
+ });
2739
2731
if (Found == Deps->end ())
2740
2732
return ;
2741
2733
MemoryDepChecker::Dependence Dep = *Found;
@@ -2874,9 +2866,9 @@ static Value *stripGetElementPtr(Value *Ptr, ScalarEvolution *SE, Loop *Lp) {
2874
2866
2875
2867
// Check that all of the gep indices are uniform except for our induction
2876
2868
// operand.
2877
- for (unsigned i = 0 , e = GEP->getNumOperands (); i != e ; ++i )
2878
- if (i != InductionOperand &&
2879
- !SE->isLoopInvariant (SE->getSCEV (GEP->getOperand (i )), Lp))
2869
+ for (unsigned I = 0 , E = GEP->getNumOperands (); I != E ; ++I )
2870
+ if (I != InductionOperand &&
2871
+ !SE->isLoopInvariant (SE->getSCEV (GEP->getOperand (I )), Lp))
2880
2872
return Ptr;
2881
2873
return GEP->getOperand (InductionOperand);
2882
2874
}
@@ -3072,9 +3064,8 @@ LoopAccessInfo::LoopAccessInfo(Loop *L, ScalarEvolution *SE,
3072
3064
DepChecker =
3073
3065
std::make_unique<MemoryDepChecker>(*PSE, L, MaxTargetVectorWidthInBits);
3074
3066
PtrRtChecking = std::make_unique<RuntimePointerChecking>(*DepChecker, SE);
3075
- if (canAnalyzeLoop ()) {
3067
+ if (canAnalyzeLoop ())
3076
3068
analyzeLoop (AA, LI, TLI, DT);
3077
- }
3078
3069
}
3079
3070
3080
3071
void LoopAccessInfo::print (raw_ostream &OS, unsigned Depth) const {
@@ -3126,13 +3117,13 @@ void LoopAccessInfo::print(raw_ostream &OS, unsigned Depth) const {
3126
3117
}
3127
3118
3128
3119
const LoopAccessInfo &LoopAccessInfoManager::getInfo (Loop &L) {
3129
- auto I = LoopAccessInfoMap.insert ({&L, nullptr });
3120
+ auto [It, Inserted] = LoopAccessInfoMap.insert ({&L, nullptr });
3130
3121
3131
- if (I. second )
3132
- I. first ->second =
3122
+ if (Inserted )
3123
+ It ->second =
3133
3124
std::make_unique<LoopAccessInfo>(&L, &SE, TTI, TLI, &AA, &DT, &LI);
3134
3125
3135
- return *I. first ->second ;
3126
+ return *It ->second ;
3136
3127
}
3137
3128
3138
3129
bool LoopAccessInfoManager::invalidate (
0 commit comments