[LAA] Limit no-overlap check to at least one loop-invariant accesses.
Limit the logic added in https://github.com/llvm/llvm-project/pull/9230 to cases where either sink or source are loop-invariant, to avoid compile-time increases. This is not needed for correctness. I am working on follow-up changes to reduce the compile-time impact in general to allow us to enable this again for any source/sink. This should fix the compile-time regression introduced by this change: * compile-time improvement with this change: https://llvm-compile-time-tracker.com/compare.php?from=4351787fb650da6d1bfb8d6e58753c90dcd4c418&to=b89010a2eb5f98494787c1c3b77f25208c59090c&stat=instructions:u * compile-time improvement with original patch reverted on top of this change: https://llvm-compile-time-tracker.com/compare.php?from=b89010a2eb5f98494787c1c3b77f25208c59090c&to=19a1103fe68115cfd7d6472c6961f4fabe81a593&stat=instructions:u
This commit is contained in:
@@ -1983,20 +1983,25 @@ getDependenceDistanceStrideAndSize(
|
||||
return MemoryDepChecker::Dependence::IndirectUnsafe;
|
||||
|
||||
// Check if we can prove that Sink only accesses memory after Src's end or
|
||||
// vice versa.
|
||||
const auto &[SrcStart, SrcEnd] =
|
||||
getStartAndEndForAccess(InnermostLoop, Src, ATy, PSE);
|
||||
const auto &[SinkStart, SinkEnd] =
|
||||
getStartAndEndForAccess(InnermostLoop, Sink, BTy, PSE);
|
||||
// vice versa. At the moment this is limited to cases where either source or
|
||||
// sink are loop invariant to avoid compile-time increases. This is not
|
||||
// required for correctness.
|
||||
if (SE.isLoopInvariant(Src, InnermostLoop) ||
|
||||
SE.isLoopInvariant(Sink, InnermostLoop)) {
|
||||
const auto &[SrcStart, SrcEnd] =
|
||||
getStartAndEndForAccess(InnermostLoop, Src, ATy, PSE);
|
||||
const auto &[SinkStart, SinkEnd] =
|
||||
getStartAndEndForAccess(InnermostLoop, Sink, BTy, PSE);
|
||||
|
||||
if (!isa<SCEVCouldNotCompute>(SrcStart) &&
|
||||
!isa<SCEVCouldNotCompute>(SrcEnd) &&
|
||||
!isa<SCEVCouldNotCompute>(SinkStart) &&
|
||||
!isa<SCEVCouldNotCompute>(SinkEnd)) {
|
||||
if (SE.isKnownPredicate(CmpInst::ICMP_ULE, SrcEnd, SinkStart))
|
||||
return MemoryDepChecker::Dependence::NoDep;
|
||||
if (SE.isKnownPredicate(CmpInst::ICMP_ULE, SinkEnd, SrcStart))
|
||||
return MemoryDepChecker::Dependence::NoDep;
|
||||
if (!isa<SCEVCouldNotCompute>(SrcStart) &&
|
||||
!isa<SCEVCouldNotCompute>(SrcEnd) &&
|
||||
!isa<SCEVCouldNotCompute>(SinkStart) &&
|
||||
!isa<SCEVCouldNotCompute>(SinkEnd)) {
|
||||
if (SE.isKnownPredicate(CmpInst::ICMP_ULE, SrcEnd, SinkStart))
|
||||
return MemoryDepChecker::Dependence::NoDep;
|
||||
if (SE.isKnownPredicate(CmpInst::ICMP_ULE, SinkEnd, SrcStart))
|
||||
return MemoryDepChecker::Dependence::NoDep;
|
||||
}
|
||||
}
|
||||
|
||||
// Need accesses with constant strides and the same direction. We don't want
|
||||
|
||||
@@ -130,8 +130,16 @@ define void @neg_dist_dep_type_size_equivalence(ptr nocapture %vec, i64 %n) {
|
||||
; CHECK-LABEL: 'neg_dist_dep_type_size_equivalence'
|
||||
; CHECK-NEXT: loop:
|
||||
; CHECK-NEXT: Report: unsafe dependent memory operations in loop. Use #pragma clang loop distribute(enable) to allow loop distribution to attempt to isolate the offending operations into a separate loop
|
||||
; CHECK-NEXT: Backward loop carried data dependence that prevents store-to-load forwarding.
|
||||
; CHECK-NEXT: Unknown data dependence.
|
||||
; CHECK-NEXT: Dependences:
|
||||
; CHECK-NEXT: Unknown:
|
||||
; CHECK-NEXT: %ld.f64 = load double, ptr %gep.iv, align 8 ->
|
||||
; CHECK-NEXT: store i32 %ld.i64.i32, ptr %gep.iv.n.i64, align 8
|
||||
; CHECK-EMPTY:
|
||||
; CHECK-NEXT: Unknown:
|
||||
; CHECK-NEXT: %ld.i64 = load i64, ptr %gep.iv, align 8 ->
|
||||
; CHECK-NEXT: store i32 %ld.i64.i32, ptr %gep.iv.n.i64, align 8
|
||||
; CHECK-EMPTY:
|
||||
; CHECK-NEXT: BackwardVectorizableButPreventsForwarding:
|
||||
; CHECK-NEXT: %ld.f64 = load double, ptr %gep.iv, align 8 ->
|
||||
; CHECK-NEXT: store double %val, ptr %gep.iv.101.i64, align 8
|
||||
|
||||
@@ -45,8 +45,13 @@ exit:
|
||||
define void @different_non_constant_strides_known_backward_distance_larger_than_trip_count(ptr %A) {
|
||||
; CHECK-LABEL: 'different_non_constant_strides_known_backward_distance_larger_than_trip_count'
|
||||
; CHECK-NEXT: loop:
|
||||
; CHECK-NEXT: Memory dependences are safe
|
||||
; CHECK-NEXT: Report: unsafe dependent memory operations in loop. Use #pragma clang loop distribute(enable) to allow loop distribution to attempt to isolate the offending operations into a separate loop
|
||||
; CHECK-NEXT: Unknown data dependence.
|
||||
; CHECK-NEXT: Dependences:
|
||||
; CHECK-NEXT: Unknown:
|
||||
; CHECK-NEXT: %l = load i32, ptr %gep, align 4 ->
|
||||
; CHECK-NEXT: store i32 %add, ptr %gep.mul.2, align 4
|
||||
; CHECK-EMPTY:
|
||||
; CHECK-NEXT: Run-time memory checks:
|
||||
; CHECK-NEXT: Grouped accesses:
|
||||
; CHECK-EMPTY:
|
||||
|
||||
Reference in New Issue
Block a user