@@ -2066,17 +2066,16 @@ MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx,
20662066 // Attempt to prove strided accesses independent.
20672067 const APInt *APDist = nullptr ;
20682068
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 =
2069+ // The rest of this function relies on ConstDist being at most 64-bits, which
2070+ // is checked earlier. Will assert if the calling code changes.
2071+ uint64_t ConstDist =
20722072 match (Dist, m_scev_APInt (APDist)) ? APDist->abs ().getZExtValue () : 0 ;
20732073
20742074 if (APDist) {
20752075 // If the distance between accesses and their strides are known constants,
20762076 // check whether the accesses interlace each other.
2077- if (ConstDistance > 0 && CommonStride && CommonStride > 1 && HasSameSize &&
2078- areStridedAccessesIndependent (ConstDistance, *CommonStride,
2079- TypeByteSize)) {
2077+ if (ConstDist > 0 && CommonStride && CommonStride > 1 && HasSameSize &&
2078+ areStridedAccessesIndependent (ConstDist, *CommonStride, TypeByteSize)) {
20802079 LLVM_DEBUG (dbgs () << " LAA: Strided accesses are independent\n " );
20812080 return Dependence::NoDep;
20822081 }
@@ -2109,7 +2108,7 @@ MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx,
21092108 // forward dependency will allow vectorization using any width.
21102109
21112110 if (IsTrueDataDependence && EnableForwardingConflictDetection) {
2112- if (!ConstDistance ) {
2111+ if (!ConstDist ) {
21132112 // TODO: FoundNonConstantDistanceDependence is used as a necessary
21142113 // condition to consider retrying with runtime checks. Historically, we
21152114 // did not set it when strides were different but there is no inherent
@@ -2118,7 +2117,7 @@ MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx,
21182117 return Dependence::Unknown;
21192118 }
21202119 if (!HasSameSize ||
2121- couldPreventStoreLoadForward (ConstDistance , TypeByteSize)) {
2120+ couldPreventStoreLoadForward (ConstDist , TypeByteSize)) {
21222121 LLVM_DEBUG (
21232122 dbgs () << " LAA: Forward but may prevent st->ld forwarding\n " );
21242123 return Dependence::ForwardButPreventsForwarding;
@@ -2129,15 +2128,14 @@ MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx,
21292128 return Dependence::Forward;
21302129 }
21312130
2132- std::optional<int64_t > MinDistance =
2133- SE.getSignedRangeMin (Dist).trySExtValue ();
2131+ int64_t MinDistance = SE.getSignedRangeMin (Dist).getSExtValue ();
21342132 // Below we only handle strictly positive distances.
2135- if (!MinDistance || MinDistance <= 0 ) {
2133+ if (MinDistance <= 0 ) {
21362134 FoundNonConstantDistanceDependence |= ShouldRetryWithRuntimeCheck;
21372135 return Dependence::Unknown;
21382136 }
21392137
2140- if (!ConstDistance ) {
2138+ if (!ConstDist ) {
21412139 // Previously this case would be treated as Unknown, possibly setting
21422140 // FoundNonConstantDistanceDependence to force re-trying with runtime
21432141 // checks. Until the TODO below is addressed, set it here to preserve
@@ -2196,8 +2194,8 @@ MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx,
21962194 // minimum for computations below, as this ensures we compute the closest
21972195 // possible dependence distance.
21982196 uint64_t MinDistanceNeeded = MaxStride * (MinNumIter - 1 ) + TypeByteSize;
2199- if (MinDistanceNeeded > static_cast <uint64_t >(* MinDistance)) {
2200- if (!ConstDistance ) {
2197+ if (MinDistanceNeeded > static_cast <uint64_t >(MinDistance)) {
2198+ if (!ConstDist ) {
22012199 // For non-constant distances, we checked the lower bound of the
22022200 // dependence distance and the distance may be larger at runtime (and safe
22032201 // for vectorization). Classify it as Unknown, so we re-try with runtime
@@ -2234,20 +2232,19 @@ MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx,
22342232 // is 8, which is less than 2 and forbidden vectorization, But actually
22352233 // both A and B could be vectorized by 2 iterations.
22362234 MinDepDistBytes =
2237- std::min (static_cast <uint64_t >(* MinDistance), MinDepDistBytes);
2235+ std::min (static_cast <uint64_t >(MinDistance), MinDepDistBytes);
22382236
22392237 bool IsTrueDataDependence = (!AIsWrite && BIsWrite);
2240- if (IsTrueDataDependence && EnableForwardingConflictDetection &&
2241- ConstDistance &&
2242- couldPreventStoreLoadForward (*MinDistance, TypeByteSize, *CommonStride))
2238+ if (IsTrueDataDependence && EnableForwardingConflictDetection && ConstDist &&
2239+ couldPreventStoreLoadForward (MinDistance, TypeByteSize, *CommonStride))
22432240 return Dependence::BackwardVectorizableButPreventsForwarding;
22442241
22452242 uint64_t MaxVF = MinDepDistBytes / MaxStride;
22462243 LLVM_DEBUG (dbgs () << " LAA: Positive min distance " << MinDistance
22472244 << " with max VF = " << MaxVF << ' \n ' );
22482245
22492246 uint64_t MaxVFInBits = MaxVF * TypeByteSize * 8 ;
2250- if (!ConstDistance && MaxVFInBits < MaxTargetVectorWidthInBits) {
2247+ if (!ConstDist && MaxVFInBits < MaxTargetVectorWidthInBits) {
22512248 // For non-constant distances, we checked the lower bound of the dependence
22522249 // distance and the distance may be larger at runtime (and safe for
22532250 // vectorization). Classify it as Unknown, so we re-try with runtime checks.
0 commit comments