• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -analyze -basicaa -lda | FileCheck %s
2
3@x = common global [256 x i32] zeroinitializer, align 4
4@y = common global [256 x i32] zeroinitializer, align 4
5
6;; for (i = 0; i < 256; i++)
7;;   x[i] = x[42] + y[i]
8
9define void @f1(...) nounwind {
10entry:
11  %x.ld.addr = getelementptr [256 x i32]* @x, i64 0, i64 42
12  br label %for.body
13
14for.body:
15  %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]
16  %x.addr = getelementptr [256 x i32]* @x, i64 0, i64 %i
17  %y.addr = getelementptr [256 x i32]* @y, i64 0, i64 %i
18  %x = load i32* %x.ld.addr   ; 0
19  %y = load i32* %y.addr      ; 1
20  %r = add i32 %y, %x
21  store i32 %r, i32* %x.addr  ; 2
22; CHECK: 0,2: dep
23; CHECK: 1,2: ind
24  %i.next = add i64 %i, 1
25  %exitcond = icmp eq i64 %i.next, 256
26  br i1 %exitcond, label %for.end, label %for.body
27
28for.end:
29  ret void
30}
31
32;; for (i = 0; i < 250; i++)
33;;   x[i] = x[255] + y[i]
34
35define void @f2(...) nounwind {
36entry:
37  %x.ld.addr = getelementptr [256 x i32]* @x, i64 0, i64 255
38  br label %for.body
39
40for.body:
41  %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]
42  %x.addr = getelementptr [256 x i32]* @x, i64 0, i64 %i
43  %y.addr = getelementptr [256 x i32]* @y, i64 0, i64 %i
44  %x = load i32* %x.ld.addr   ; 0
45  %y = load i32* %y.addr      ; 1
46  %r = add i32 %y, %x
47  store i32 %r, i32* %x.addr  ; 2
48; CHECK: 0,2: dep
49; CHECK: 1,2: ind
50  %i.next = add i64 %i, 1
51  %exitcond = icmp eq i64 %i.next, 250
52  br i1 %exitcond, label %for.end, label %for.body
53
54for.end:
55  ret void
56}
57