Skip to content

Commit 5511608

Browse files
committed
LAA: fix nits, comments (NFC)
1 parent f169b7f commit 5511608

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

llvm/include/llvm/Analysis/LoopAccessAnalysis.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -367,15 +367,17 @@ class MemoryDepChecker {
367367
struct DepDistanceStrideAndSizeInfo {
368368
const SCEV *Dist;
369369

370-
/// Strides could either be scaled (in bytes, taking the size of the
371-
/// underlying type into account), or unscaled (in indexing units; unscaled
372-
/// stride = scaled stride / size of underlying type). Here, strides are
373-
/// scaled.
370+
/// Strides here are scaled; i.e. in bytes, taking the size of the
371+
/// underlying type into account.
374372
uint64_t MaxStride;
375373
std::optional<uint64_t> CommonStride;
376374

377375
bool ShouldRetryWithRuntimeCheck;
376+
377+
/// TypeByteSize is either the common store size of both accesses, or 0 when
378+
/// store sizes mismatch.
378379
uint64_t TypeByteSize;
380+
379381
bool AIsWrite;
380382
bool BIsWrite;
381383

@@ -394,8 +396,9 @@ class MemoryDepChecker {
394396
/// there's no dependence or the analysis fails. Outlined to lambda to limit
395397
/// he scope of various temporary variables, like A/BPtr, StrideA/BPtr and
396398
/// others. Returns either the dependence result, if it could already be
397-
/// determined, or a struct containing (Distance, Stride, TypeSize, AIsWrite,
398-
/// BIsWrite).
399+
/// determined, or a DepDistanceStrideAndSizeInfo struct, noting that
400+
/// TypeByteSize could be 0 when store sizes mismatch, and this should be
401+
/// checked in the caller.
399402
std::variant<Dependence::DepType, DepDistanceStrideAndSizeInfo>
400403
getDependenceDistanceStrideAndSize(const MemAccessInfo &A, Instruction *AInst,
401404
const MemAccessInfo &B,

llvm/lib/Analysis/LoopAccessAnalysis.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,14 +1781,14 @@ void MemoryDepChecker::mergeInStatus(VectorizationSafetyStatus S) {
17811781
Status = S;
17821782
}
17831783

1784-
/// Given a dependence-distance \p Dist between two
1785-
/// memory accesses, that have strides in the same direction whose absolute
1786-
/// value of the maximum stride is given in \p MaxStride, and that have the same
1787-
/// type size \p TypeByteSize, in a loop whose maximum backedge taken count is
1788-
/// \p MaxBTC, check if it is possible to prove statically that the dependence
1784+
/// Given a dependence-distance \p Dist between two memory accesses, that have
1785+
/// strides in the same direction whose absolute value of the maximum stride is
1786+
/// given in \p MaxStride, in a loop whose maximum backedge taken count is \p
1787+
/// MaxBTC, check if it is possible to prove statically that the dependence
17891788
/// distance is larger than the range that the accesses will travel through the
17901789
/// execution of the loop. If so, return true; false otherwise. This is useful
17911790
/// for example in loops such as the following (PR31098):
1791+
///
17921792
/// for (i = 0; i < D; ++i) {
17931793
/// = out[i];
17941794
/// out[i+D] =
@@ -1844,8 +1844,8 @@ static bool isSafeDependenceDistance(const DataLayout &DL, ScalarEvolution &SE,
18441844
}
18451845

18461846
/// Check the dependence for two accesses with the same stride \p Stride.
1847-
/// \p Distance is the positive distance and \p TypeByteSize is type size in
1848-
/// bytes.
1847+
/// \p Distance is the positive distance in bytes, and \p TypeByteSize is type
1848+
/// size in bytes.
18491849
///
18501850
/// \returns true if they are independent.
18511851
static bool areStridedAccessesIndependent(uint64_t Distance, uint64_t Stride,
@@ -1983,13 +1983,14 @@ MemoryDepChecker::getDependenceDistanceStrideAndSize(
19831983
return MemoryDepChecker::Dependence::Unknown;
19841984
}
19851985

1986-
TypeSize AStoreSz = DL.getTypeStoreSize(ATy),
1987-
BStoreSz = DL.getTypeStoreSize(BTy);
1986+
TypeSize AStoreSz = DL.getTypeStoreSize(ATy);
1987+
TypeSize BStoreSz = DL.getTypeStoreSize(BTy);
19881988

19891989
// If store sizes are not the same, set TypeByteSize to zero, so we can check
1990-
// it in the caller.
1991-
uint64_t ASz = DL.getTypeAllocSize(ATy), BSz = DL.getTypeAllocSize(BTy),
1992-
TypeByteSize = AStoreSz == BStoreSz ? BSz : 0;
1990+
// it in the caller isDependent.
1991+
uint64_t ASz = DL.getTypeAllocSize(ATy);
1992+
uint64_t BSz = DL.getTypeAllocSize(BTy);
1993+
uint64_t TypeByteSize = (AStoreSz == BStoreSz) ? BSz : 0;
19931994

19941995
uint64_t StrideAScaled = std::abs(StrideAPtrInt) * ASz;
19951996
uint64_t StrideBScaled = std::abs(StrideBPtrInt) * BSz;
@@ -2159,7 +2160,7 @@ MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx,
21592160
// B[i] = A[i] + 1;
21602161
// }
21612162
//
2162-
// Two accesses in memory (stride is 2):
2163+
// Two accesses in memory (stride is 4 * 2):
21632164
// | A[0] | | A[2] | | A[4] | | A[6] | |
21642165
// | B[0] | | B[2] | | B[4] |
21652166
//

0 commit comments

Comments
 (0)