Skip to content

Commit 1dc0934

Browse files
committed
[LAA] Address review
1 parent dc23457 commit 1dc0934

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

llvm/lib/Analysis/LoopAccessAnalysis.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2065,15 +2065,17 @@ MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx,
20652065

20662066
// Attempt to prove strided accesses independent.
20672067
const APInt *APDist = nullptr;
2068-
std::optional<uint64_t> ConstDistance = match(Dist, m_scev_APInt(APDist))
2069-
? APDist->abs().tryZExtValue()
2070-
: std::nullopt;
2068+
2069+
// The rest of this function relies on ConstantDistance being at most 64-bits,
2070+
// which is checked earlier. Will assert if the calling code changes.
2071+
uint64_t ConstDistance =
2072+
match(Dist, m_scev_APInt(APDist)) ? APDist->abs().getZExtValue() : 0;
20712073

20722074
if (ConstDistance) {
20732075
// If the distance between accesses and their strides are known constants,
20742076
// check whether the accesses interlace each other.
20752077
if (ConstDistance > 0 && CommonStride && CommonStride > 1 && HasSameSize &&
2076-
areStridedAccessesIndependent(*ConstDistance, *CommonStride,
2078+
areStridedAccessesIndependent(ConstDistance, *CommonStride,
20772079
TypeByteSize)) {
20782080
LLVM_DEBUG(dbgs() << "LAA: Strided accesses are independent\n");
20792081
return Dependence::NoDep;
@@ -2116,7 +2118,7 @@ MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx,
21162118
return Dependence::Unknown;
21172119
}
21182120
if (!HasSameSize ||
2119-
couldPreventStoreLoadForward(*ConstDistance, TypeByteSize)) {
2121+
couldPreventStoreLoadForward(ConstDistance, TypeByteSize)) {
21202122
LLVM_DEBUG(
21212123
dbgs() << "LAA: Forward but may prevent st->ld forwarding\n");
21222124
return Dependence::ForwardButPreventsForwarding;

0 commit comments

Comments
 (0)