Skip to content

Commit 7d21d73

Browse files
authored
[LAA] Add a test case to show incorrect dependency classification (NFC). (#70473)
Currently the loop access analysis classifies this loop as unsafe to vectorize because the memory dependencies are 'ForwardButPreventsForwarding'. However, the access pattern is 'write-after-read' with no subsequent read accessing the written memory locations. I can't see how store-to-load forwarding is applicable here. void vectorizable_Read_Write(int *A) { for (unsigned i = 1022; i >= 0; i--) A[i+1] = A[i] + 1; }
1 parent 34362c6 commit 7d21d73

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
; RUN: opt -passes='print<access-info>' -disable-output < %s 2>&1 | FileCheck %s
2+
3+
target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
4+
5+
; FIXME: This should be vectorizable
6+
7+
; void vectorizable_Read_Write(int *A) {
8+
; for (unsigned i = 1022; i >= 0; i--)
9+
; A[i+1] = A[i] + 1;
10+
; }
11+
12+
; CHECK: function 'vectorizable_Read_Write':
13+
; CHECK-NEXT: for.body:
14+
; CHECK-NEXT: Report: unsafe dependent memory operations in loop
15+
; CHECK-NEXT: Forward loop carried data dependence that prevents store-to-load forwarding.
16+
; CHECK-NEXT: Dependences:
17+
; CHECK-NEXT: ForwardButPreventsForwarding:
18+
; CHECK-NEXT: %0 = load i32, ptr %arrayidx, align 4 ->
19+
; CHECK-NEXT: store i32 %add, ptr %gep, align 4
20+
21+
define void @vectorizable_Read_Write(ptr nocapture %A) {
22+
entry:
23+
%invariant.gep = getelementptr i32, ptr %A, i64 1
24+
br label %for.body
25+
26+
for.cond.cleanup:
27+
ret void
28+
29+
for.body:
30+
%indvars.iv = phi i64 [ 1022, %entry ], [ %indvars.iv.next, %for.body ]
31+
%arrayidx = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
32+
%0 = load i32, ptr %arrayidx, align 4
33+
%add = add nsw i32 %0, 1
34+
%gep = getelementptr i32, ptr %invariant.gep, i64 %indvars.iv
35+
store i32 %add, ptr %gep, align 4
36+
%indvars.iv.next = add nsw i64 %indvars.iv, -1
37+
%cmp.not = icmp eq i64 %indvars.iv, 0
38+
br i1 %cmp.not, label %for.cond.cleanup, label %for.body
39+
}
40+

0 commit comments

Comments
 (0)