Skip to content

Commit ed5b69e

Browse files
committed
LAA: add missed swap when inverting src, sink
When inverting source and sink on a negative induction step, the types of the source and sink should also be swapped. This fixes a bug in the code that follows, that computes properties based on these types. With 234cc40 ([LAA] Limit no-overlap check to at least one loop-invariant accesses.), that code is guarded by a loop-invariant condition: however, the commit did not add any new tests exercising the guarded code, and hence the bugfix in this patch requires additional tests to exercise that guarded codepath.
1 parent 820111f commit ed5b69e

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

llvm/lib/Analysis/LoopAccessAnalysis.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,6 +1921,7 @@ MemoryDepChecker::getDependenceDistanceStrideAndSize(
19211921
if (StrideAPtr && *StrideAPtr < 0) {
19221922
std::swap(Src, Sink);
19231923
std::swap(AInst, BInst);
1924+
std::swap(ATy, BTy);
19241925
std::swap(StrideAPtr, StrideBPtr);
19251926
}
19261927

llvm/test/Analysis/LoopAccessAnalysis/depend_diff_types.ll

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,8 @@ exit:
237237
define void @type_size_equivalence_sink_loopinv_negind(ptr nocapture %vec, i64 %n) {
238238
; CHECK-LABEL: 'type_size_equivalence_sink_loopinv_negind'
239239
; CHECK-NEXT: loop:
240-
; 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
241-
; CHECK-NEXT: Unknown data dependence.
240+
; CHECK-NEXT: Memory dependences are safe
242241
; CHECK-NEXT: Dependences:
243-
; CHECK-NEXT: Unknown:
244-
; CHECK-NEXT: %ld.i64 = load i64, ptr %gep.minus.iv.4, align 8 ->
245-
; CHECK-NEXT: store i32 %ld.i64.i32, ptr %gep.minus.n, align 8
246-
; CHECK-EMPTY:
247242
; CHECK-NEXT: Run-time memory checks:
248243
; CHECK-NEXT: Grouped accesses:
249244
; CHECK-EMPTY:

0 commit comments

Comments
 (0)