@@ -389,9 +389,9 @@ void RuntimePointerChecking::generateChecks(
389
389
390
390
bool RuntimePointerChecking::needsChecking (
391
391
const RuntimeCheckingPtrGroup &M, const RuntimeCheckingPtrGroup &N) const {
392
- for (unsigned I = 0 , EI = M.Members . size (); EI != I; ++I )
393
- for (unsigned J = 0 , EJ = N.Members . size (); EJ != J; ++J )
394
- if (needsChecking (M. Members [I], N. Members [J] ))
392
+ for (auto &I : M.Members )
393
+ for (auto &J : N.Members )
394
+ if (needsChecking (I, J ))
395
395
return true ;
396
396
return false ;
397
397
}
@@ -405,9 +405,7 @@ static const SCEV *getMinFromExprs(const SCEV *I, const SCEV *J,
405
405
406
406
if (!C)
407
407
return nullptr ;
408
- if (C->getValue ()->isNegative ())
409
- return J;
410
- return I;
408
+ return C->getValue ()->isNegative () ? J : I;
411
409
}
412
410
413
411
bool RuntimeCheckingPtrGroup::addPointer (unsigned Index,
@@ -505,8 +503,8 @@ void RuntimePointerChecking::groupChecks(
505
503
506
504
DenseMap<Value *, SmallVector<unsigned >> PositionMap;
507
505
for (unsigned Index = 0 ; Index < Pointers.size (); ++Index) {
508
- auto Iter = PositionMap.insert ({Pointers[Index].PointerValue , {}});
509
- Iter. first ->second .push_back (Index);
506
+ auto [It, _] = PositionMap.insert ({Pointers[Index].PointerValue , {}});
507
+ It ->second .push_back (Index);
510
508
}
511
509
512
510
// We need to keep track of what pointers we've already seen so we
@@ -605,16 +603,16 @@ void RuntimePointerChecking::printChecks(
605
603
raw_ostream &OS, const SmallVectorImpl<RuntimePointerCheck> &Checks,
606
604
unsigned Depth) const {
607
605
unsigned N = 0 ;
608
- for (const auto &Check : Checks) {
609
- const auto &First = Check. first ->Members , &Second = Check. second ->Members ;
606
+ for (const auto &[Check1, Check2] : Checks) {
607
+ const auto &First = Check1 ->Members , &Second = Check2 ->Members ;
610
608
611
609
OS.indent (Depth) << " Check " << N++ << " :\n " ;
612
610
613
- OS.indent (Depth + 2 ) << " Comparing group (" << Check. first << " ):\n " ;
611
+ OS.indent (Depth + 2 ) << " Comparing group (" << Check1 << " ):\n " ;
614
612
for (unsigned K = 0 ; K < First.size (); ++K)
615
613
OS.indent (Depth + 2 ) << *Pointers[First[K]].PointerValue << " \n " ;
616
614
617
- OS.indent (Depth + 2 ) << " Against group (" << Check. second << " ):\n " ;
615
+ OS.indent (Depth + 2 ) << " Against group (" << Check2 << " ):\n " ;
618
616
for (unsigned K = 0 ; K < Second.size (); ++K)
619
617
OS.indent (Depth + 2 ) << *Pointers[Second[K]].PointerValue << " \n " ;
620
618
}
@@ -1155,8 +1153,8 @@ bool AccessAnalysis::canCheckPtrAtRT(RuntimePointerChecking &RtCheck,
1155
1153
// First, count how many write and read accesses are in the alias set. Also
1156
1154
// collect MemAccessInfos for later.
1157
1155
SmallVector<MemAccessInfo, 4 > AccessInfos;
1158
- for (const Value *Ptr_ : ASPointers) {
1159
- Value *Ptr = const_cast <Value *>(Ptr_ );
1156
+ for (const Value *ConstPtr : ASPointers) {
1157
+ Value *Ptr = const_cast <Value *>(ConstPtr );
1160
1158
bool IsWrite = Accesses.count (MemAccessInfo (Ptr, true ));
1161
1159
if (IsWrite)
1162
1160
++NumWritePtrChecks;
@@ -1212,9 +1210,7 @@ bool AccessAnalysis::canCheckPtrAtRT(RuntimePointerChecking &RtCheck,
1212
1210
// We know that we need these checks, so we can now be more aggressive
1213
1211
// and add further checks if required (overflow checks).
1214
1212
CanDoAliasSetRT = true ;
1215
- for (auto Retry : Retries) {
1216
- MemAccessInfo Access = Retry.first ;
1217
- Type *AccessTy = Retry.second ;
1213
+ for (const auto &[Access, AccessTy] : Retries) {
1218
1214
if (!createCheckForAccess (RtCheck, Access, AccessTy, StridesMap,
1219
1215
DepSetId, TheLoop, RunningDepId, ASId,
1220
1216
ShouldCheckWrap, /* Assume=*/ true )) {
@@ -1286,12 +1282,11 @@ void AccessAnalysis::processMemAccesses() {
1286
1282
LLVM_DEBUG (dbgs () << " AST: " ; AST.dump ());
1287
1283
LLVM_DEBUG (dbgs () << " LAA: Accesses(" << Accesses.size () << " ):\n " );
1288
1284
LLVM_DEBUG ({
1289
- for (auto A : Accesses)
1290
- dbgs () << " \t " << *A.first .getPointer () << " ("
1291
- << (A.first .getInt ()
1292
- ? " write"
1293
- : (ReadOnlyPtr.count (A.first .getPointer ()) ? " read-only"
1294
- : " read" ))
1285
+ for (const auto &[A, _] : Accesses)
1286
+ dbgs () << " \t " << *A.getPointer () << " ("
1287
+ << (A.getInt () ? " write"
1288
+ : (ReadOnlyPtr.count (A.getPointer ()) ? " read-only"
1289
+ : " read" ))
1295
1290
<< " )\n " ;
1296
1291
});
1297
1292
@@ -1320,16 +1315,16 @@ void AccessAnalysis::processMemAccesses() {
1320
1315
bool UseDeferred = SetIteration > 0 ;
1321
1316
PtrAccessMap &S = UseDeferred ? DeferredAccesses : Accesses;
1322
1317
1323
- for (const Value *Ptr_ : ASPointers) {
1324
- Value *Ptr = const_cast <Value *>(Ptr_ );
1318
+ for (const Value *ConstPtr : ASPointers) {
1319
+ Value *Ptr = const_cast <Value *>(ConstPtr );
1325
1320
1326
1321
// For a single memory access in AliasSetTracker, Accesses may contain
1327
1322
// both read and write, and they both need to be handled for CheckDeps.
1328
- for (const auto &AC : S) {
1329
- if (AC.first . getPointer () != Ptr)
1323
+ for (const auto &[AC, _] : S) {
1324
+ if (AC.getPointer () != Ptr)
1330
1325
continue ;
1331
1326
1332
- bool IsWrite = AC.first . getInt ();
1327
+ bool IsWrite = AC.getInt ();
1333
1328
1334
1329
// If we're using the deferred access set, then it contains only
1335
1330
// reads.
@@ -1856,10 +1851,7 @@ static bool isSafeDependenceDistance(const DataLayout &DL, ScalarEvolution &SE,
1856
1851
// (If so, then we have proven (**) because |Dist| >= -1*Dist)
1857
1852
const SCEV *NegDist = SE.getNegativeSCEV (CastedDist);
1858
1853
Minus = SE.getMinusSCEV (NegDist, CastedProduct);
1859
- if (SE.isKnownPositive (Minus))
1860
- return true ;
1861
-
1862
- return false ;
1854
+ return SE.isKnownPositive (Minus);
1863
1855
}
1864
1856
1865
1857
// / Check the dependence for two accesses with the same stride \p Stride.
@@ -2030,7 +2022,7 @@ MemoryDepChecker::Dependence::DepType MemoryDepChecker::isDependent(
2030
2022
if (isa<SCEVCouldNotCompute>(Dist)) {
2031
2023
// TODO: Relax requirement that there is a common stride to retry with
2032
2024
// non-constant distance dependencies.
2033
- FoundNonConstantDistanceDependence |= !! CommonStride;
2025
+ FoundNonConstantDistanceDependence |= CommonStride. has_value () ;
2034
2026
LLVM_DEBUG (dbgs () << " LAA: Dependence because of uncomputable distance.\n " );
2035
2027
return Dependence::Unknown;
2036
2028
}
@@ -2070,14 +2062,12 @@ MemoryDepChecker::Dependence::DepType MemoryDepChecker::isDependent(
2070
2062
// Negative distances are not plausible dependencies.
2071
2063
if (SE.isKnownNonPositive (Dist)) {
2072
2064
if (SE.isKnownNonNegative (Dist)) {
2073
- if (HasSameSize) {
2065
+ if (HasSameSize)
2074
2066
// Write to the same location with the same size.
2075
2067
return Dependence::Forward;
2076
- } else {
2077
- LLVM_DEBUG (dbgs () << " LAA: possibly zero dependence difference but "
2078
- " different type sizes\n " );
2079
- return Dependence::Unknown;
2080
- }
2068
+ LLVM_DEBUG (dbgs () << " LAA: possibly zero dependence difference but "
2069
+ " different type sizes\n " );
2070
+ return Dependence::Unknown;
2081
2071
}
2082
2072
2083
2073
bool IsTrueDataDependence = (AIsWrite && !BIsWrite);
@@ -2323,7 +2313,7 @@ bool MemoryDepChecker::areDepsSafe(
2323
2313
}
2324
2314
++OI;
2325
2315
}
2326
- AI++ ;
2316
+ ++AI ;
2327
2317
}
2328
2318
}
2329
2319
@@ -2332,8 +2322,8 @@ bool MemoryDepChecker::areDepsSafe(
2332
2322
}
2333
2323
2334
2324
SmallVector<Instruction *, 4 >
2335
- MemoryDepChecker::getInstructionsForAccess (Value *Ptr, bool isWrite ) const {
2336
- MemAccessInfo Access (Ptr, isWrite );
2325
+ MemoryDepChecker::getInstructionsForAccess (Value *Ptr, bool IsWrite ) const {
2326
+ MemAccessInfo Access (Ptr, IsWrite );
2337
2327
auto &IndexVector = Accesses.find (Access)->second ;
2338
2328
2339
2329
SmallVector<Instruction *, 4 > Insts;
@@ -2709,13 +2699,14 @@ void LoopAccessInfo::analyzeLoop(AAResults *AA, LoopInfo *LI,
2709
2699
}
2710
2700
2711
2701
void LoopAccessInfo::emitUnsafeDependenceRemark () {
2712
- auto Deps = getDepChecker ().getDependences ();
2702
+ const auto * Deps = getDepChecker ().getDependences ();
2713
2703
if (!Deps)
2714
2704
return ;
2715
- auto Found = llvm::find_if (*Deps, [](const MemoryDepChecker::Dependence &D) {
2716
- return MemoryDepChecker::Dependence::isSafeForVectorization (D.Type ) !=
2717
- MemoryDepChecker::VectorizationSafetyStatus::Safe;
2718
- });
2705
+ const auto *Found =
2706
+ llvm::find_if (*Deps, [](const MemoryDepChecker::Dependence &D) {
2707
+ return MemoryDepChecker::Dependence::isSafeForVectorization (D.Type ) !=
2708
+ MemoryDepChecker::VectorizationSafetyStatus::Safe;
2709
+ });
2719
2710
if (Found == Deps->end ())
2720
2711
return ;
2721
2712
MemoryDepChecker::Dependence Dep = *Found;
@@ -2854,9 +2845,9 @@ static Value *stripGetElementPtr(Value *Ptr, ScalarEvolution *SE, Loop *Lp) {
2854
2845
2855
2846
// Check that all of the gep indices are uniform except for our induction
2856
2847
// operand.
2857
- for (unsigned i = 0 , e = GEP->getNumOperands (); i != e ; ++i )
2858
- if (i != InductionOperand &&
2859
- !SE->isLoopInvariant (SE->getSCEV (GEP->getOperand (i )), Lp))
2848
+ for (unsigned I = 0 , E = GEP->getNumOperands (); I != E ; ++I )
2849
+ if (I != InductionOperand &&
2850
+ !SE->isLoopInvariant (SE->getSCEV (GEP->getOperand (I )), Lp))
2860
2851
return Ptr;
2861
2852
return GEP->getOperand (InductionOperand);
2862
2853
}
@@ -3038,11 +3029,10 @@ LoopAccessInfo::LoopAccessInfo(Loop *L, ScalarEvolution *SE,
3038
3029
if (TTI) {
3039
3030
TypeSize FixedWidth =
3040
3031
TTI->getRegisterBitWidth (TargetTransformInfo::RGK_FixedWidthVector);
3041
- if (FixedWidth.isNonZero ()) {
3032
+ if (FixedWidth.isNonZero ())
3042
3033
// Scale the vector width by 2 as rough estimate to also consider
3043
3034
// interleaving.
3044
3035
MaxTargetVectorWidthInBits = FixedWidth.getFixedValue () * 2 ;
3045
- }
3046
3036
3047
3037
TypeSize ScalableWidth =
3048
3038
TTI->getRegisterBitWidth (TargetTransformInfo::RGK_ScalableVector);
@@ -3052,9 +3042,8 @@ LoopAccessInfo::LoopAccessInfo(Loop *L, ScalarEvolution *SE,
3052
3042
DepChecker =
3053
3043
std::make_unique<MemoryDepChecker>(*PSE, L, MaxTargetVectorWidthInBits);
3054
3044
PtrRtChecking = std::make_unique<RuntimePointerChecking>(*DepChecker, SE);
3055
- if (canAnalyzeLoop ()) {
3045
+ if (canAnalyzeLoop ())
3056
3046
analyzeLoop (AA, LI, TLI, DT);
3057
- }
3058
3047
}
3059
3048
3060
3049
void LoopAccessInfo::print (raw_ostream &OS, unsigned Depth) const {
@@ -3106,13 +3095,13 @@ void LoopAccessInfo::print(raw_ostream &OS, unsigned Depth) const {
3106
3095
}
3107
3096
3108
3097
const LoopAccessInfo &LoopAccessInfoManager::getInfo (Loop &L) {
3109
- auto I = LoopAccessInfoMap.insert ({&L, nullptr });
3098
+ auto [It, Inserted] = LoopAccessInfoMap.insert ({&L, nullptr });
3110
3099
3111
- if (I. second )
3112
- I. first ->second =
3100
+ if (Inserted )
3101
+ It ->second =
3113
3102
std::make_unique<LoopAccessInfo>(&L, &SE, TTI, TLI, &AA, &DT, &LI);
3114
3103
3115
- return *I. first ->second ;
3104
+ return *It ->second ;
3116
3105
}
3117
3106
3118
3107
bool LoopAccessInfoManager::invalidate (
0 commit comments