• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -store-to-load-forwarding-conflict-detection=false -loop-accesses -analyze | FileCheck %s
2; RUN: opt -passes='require<scalar-evolution>,require<aa>,loop(print-access-info)' -store-to-load-forwarding-conflict-detection=false  -disable-output  < %s 2>&1 | FileCheck %s
3
4; This test checks that we prove the strided accesses to be independent before
5; concluding that there is a forward dependence.
6
7; struct pair {
8;   int x;
9;   int y;
10; };
11;
12; int independent_interleaved(struct pair *p, int z, int n) {
13;   int s = 0;
14;   for (int i = 0; i < n; i++) {
15;     p[i].y = z;
16;     s += p[i].x;
17;   }
18;   return s;
19; }
20
21; CHECK:     for.body:
22; CHECK-NOT:     Forward:
23; CHECK-NOT:         store i32 %z, i32* %p_i.y, align 8 ->
24; CHECK-NOT:         %0 = load i32, i32* %p_i.x, align 8
25
26%pair = type { i32, i32 }
27define i32 @independent_interleaved(%pair *%p, i64 %n, i32 %z) {
28entry:
29  br label %for.body
30
31for.body:
32  %i = phi i64 [ %i.next, %for.body ], [ 0, %entry ]
33  %s = phi i32 [ %1, %for.body ], [ 0, %entry ]
34  %p_i.x = getelementptr inbounds %pair, %pair* %p, i64 %i, i32 0
35  %p_i.y = getelementptr inbounds %pair, %pair* %p, i64 %i, i32 1
36  store i32 %z, i32* %p_i.y, align 8
37  %0 = load i32, i32* %p_i.x, align 8
38  %1 = add nsw i32 %0, %s
39  %i.next = add nuw nsw i64 %i, 1
40  %cond = icmp slt i64 %i.next, %n
41  br i1 %cond, label %for.body, label %for.end
42
43for.end:
44  %2 = phi i32 [ %1, %for.body ]
45  ret i32 %2
46}
47