@@ -1976,13 +1976,12 @@ MemoryDepChecker::getDependenceDistanceStrideAndSize(
1976
1976
<< " Sink induction step: " << StrideBPtrInt << " \n " );
1977
1977
// At least Src or Sink are loop invariant and the other is strided or
1978
1978
// invariant. We can generate a runtime check to disambiguate the accesses.
1979
- if (StrideAPtrInt == 0 || StrideBPtrInt == 0 )
1979
+ if (! StrideAPtrInt || ! StrideBPtrInt)
1980
1980
return MemoryDepChecker::Dependence::Unknown;
1981
1981
1982
1982
// Both Src and Sink have a constant stride, check if they are in the same
1983
1983
// direction.
1984
- if ((StrideAPtrInt > 0 && StrideBPtrInt < 0 ) ||
1985
- (StrideAPtrInt < 0 && StrideBPtrInt > 0 )) {
1984
+ if (StrideAPtrInt > 0 != StrideBPtrInt > 0 ) {
1986
1985
LLVM_DEBUG (
1987
1986
dbgs () << " Pointer access with strides in different directions\n " );
1988
1987
return MemoryDepChecker::Dependence::Unknown;
@@ -2038,19 +2037,16 @@ MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx,
2038
2037
*Dist, MaxStride, TypeByteSize))
2039
2038
return Dependence::NoDep;
2040
2039
2041
- const SCEVConstant *C = dyn_cast<SCEVConstant>(Dist);
2040
+ const SCEVConstant *ConstDist = dyn_cast<SCEVConstant>(Dist);
2042
2041
2043
2042
// Attempt to prove strided accesses independent.
2044
- if (C) {
2045
- const APInt &Val = C->getAPInt ();
2046
- int64_t Distance = Val.getSExtValue ();
2043
+ if (ConstDist) {
2044
+ int64_t Distance = std::abs (ConstDist->getAPInt ().getSExtValue ());
2047
2045
2048
2046
// If the distance between accesses and their strides are known constants,
2049
2047
// check whether the accesses interlace each other.
2050
- if (std::abs (Distance) > 0 && CommonStride && *CommonStride > 1 &&
2051
- HasSameSize &&
2052
- areStridedAccessesIndependent (std::abs (Distance), *CommonStride,
2053
- TypeByteSize)) {
2048
+ if (Distance > 0 && CommonStride && CommonStride > 1 && HasSameSize &&
2049
+ areStridedAccessesIndependent (Distance, *CommonStride, TypeByteSize)) {
2054
2050
LLVM_DEBUG (dbgs () << " LAA: Strided accesses are independent\n " );
2055
2051
return Dependence::NoDep;
2056
2052
}
@@ -2083,7 +2079,7 @@ MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx,
2083
2079
// forward dependency will allow vectorization using any width.
2084
2080
2085
2081
if (IsTrueDataDependence && EnableForwardingConflictDetection) {
2086
- if (!C ) {
2082
+ if (!ConstDist ) {
2087
2083
// TODO: FoundNonConstantDistanceDependence is used as a necessary
2088
2084
// condition to consider retrying with runtime checks. Historically, we
2089
2085
// did not set it when strides were different but there is no inherent
@@ -2092,8 +2088,8 @@ MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx,
2092
2088
return Dependence::Unknown;
2093
2089
}
2094
2090
if (!HasSameSize ||
2095
- couldPreventStoreLoadForward (C-> getAPInt (). abs (). getZExtValue (),
2096
- TypeByteSize)) {
2091
+ couldPreventStoreLoadForward (
2092
+ ConstDist-> getAPInt (). abs (). getZExtValue (), TypeByteSize)) {
2097
2093
LLVM_DEBUG (
2098
2094
dbgs () << " LAA: Forward but may prevent st->ld forwarding\n " );
2099
2095
return Dependence::ForwardButPreventsForwarding;
@@ -2111,7 +2107,7 @@ MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx,
2111
2107
return Dependence::Unknown;
2112
2108
}
2113
2109
2114
- if (!isa<SCEVConstant>(Dist) ) {
2110
+ if (!ConstDist ) {
2115
2111
// Previously this case would be treated as Unknown, possibly setting
2116
2112
// FoundNonConstantDistanceDependence to force re-trying with runtime
2117
2113
// checks. Until the TODO below is addressed, set it here to preserve
@@ -2173,7 +2169,7 @@ MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx,
2173
2169
uint64_t MinDistanceNeeded =
2174
2170
TypeByteSize * *CommonStride * (MinNumIter - 1 ) + TypeByteSize;
2175
2171
if (MinDistanceNeeded > static_cast <uint64_t >(MinDistance)) {
2176
- if (!isa<SCEVConstant>(Dist) ) {
2172
+ if (!ConstDist ) {
2177
2173
// For non-constant distances, we checked the lower bound of the
2178
2174
// dependence distance and the distance may be larger at runtime (and safe
2179
2175
// for vectorization). Classify it as Unknown, so we re-try with runtime
@@ -2214,8 +2210,7 @@ MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx,
2214
2210
2215
2211
bool IsTrueDataDependence = (!AIsWrite && BIsWrite);
2216
2212
uint64_t MinDepDistBytesOld = MinDepDistBytes;
2217
- if (IsTrueDataDependence && EnableForwardingConflictDetection &&
2218
- isa<SCEVConstant>(Dist) &&
2213
+ if (IsTrueDataDependence && EnableForwardingConflictDetection && ConstDist &&
2219
2214
couldPreventStoreLoadForward (MinDistance, TypeByteSize)) {
2220
2215
// Sanity check that we didn't update MinDepDistBytes when calling
2221
2216
// couldPreventStoreLoadForward
@@ -2233,7 +2228,7 @@ MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx,
2233
2228
<< " with max VF = " << MaxVF << ' \n ' );
2234
2229
2235
2230
uint64_t MaxVFInBits = MaxVF * TypeByteSize * 8 ;
2236
- if (!isa<SCEVConstant>(Dist) && MaxVFInBits < MaxTargetVectorWidthInBits) {
2231
+ if (!ConstDist && MaxVFInBits < MaxTargetVectorWidthInBits) {
2237
2232
// For non-constant distances, we checked the lower bound of the dependence
2238
2233
// distance and the distance may be larger at runtime (and safe for
2239
2234
// vectorization). Classify it as Unknown, so we re-try with runtime checks.
0 commit comments