Slightly reformat LDA tests to ease grepping.
[oota-llvm.git] / test / Analysis / LoopDependenceAnalysis / siv-weak-crossing.ll
1 ; RUN: llvm-as < %s | opt -disable-output -analyze -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[256 - i] + y[i]
8
9 define void @f1(...) nounwind {
10 entry:
11   br label %for.body
12
13 for.body:
14   %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]
15   %i.256 = sub i64 256, %i
16   %y.ld.addr = getelementptr [256 x i32]* @y, i64 0, i64 %i.256
17   %x.ld.addr = getelementptr [256 x i32]* @x, i64 0, i64 %i
18   %x.st.addr = getelementptr [256 x i32]* @x, i64 0, i64 %i
19   %x = load i32* %x.ld.addr     ; 0
20   %y = load i32* %y.ld.addr     ; 1
21   %r = add i32 %y, %x
22   store i32 %r, i32* %x.st.addr ; 2
23 ; CHECK: 0,2: dep
24 ; CHECK: 1,2: ind
25   %i.next = add i64 %i, 1
26   %exitcond = icmp eq i64 %i.next, 256
27   br i1 %exitcond, label %for.end, label %for.body
28
29 for.end:
30   ret void
31 }
32
33 ;; // the same example, using more realistic IR
34 ;; for (i = 0; i < 256; i++)
35 ;;   x[i] = x[256 - i] + y[i]
36
37 define void @f2(...) nounwind {
38 entry:
39   br label %for.body
40
41 for.body:
42   %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]
43   %i.256 = sub i64 0, %i
44   %y.ld.addr = getelementptr [256 x i32]* @y, i64 0, i64 %i
45   %x.ld.addr = getelementptr [256 x i32]* @x, i64 1, i64 %i.256
46   %x.st.addr = getelementptr [256 x i32]* @x, i64 0, i64 %i
47   %x = load i32* %x.ld.addr     ; 0
48   %y = load i32* %y.ld.addr     ; 1
49   %r = add i32 %y, %x
50   store i32 %r, i32* %x.st.addr ; 2
51 ; CHECK: 0,2: dep
52 ; CHECK: 1,2: ind
53   %i.next = add i64 %i, 1
54   %exitcond = icmp eq i64 %i.next, 256
55   br i1 %exitcond, label %for.end, label %for.body
56
57 for.end:
58   ret void
59 }
60
61 ;; for (i = 0; i < 100; i++)
62 ;;   x[i] = x[256 - i] + y[i]
63
64 define void @f3(...) nounwind {
65 entry:
66   br label %for.body
67
68 for.body:
69   %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]
70   %i.256 = sub i64 0, %i
71   %y.ld.addr = getelementptr [256 x i32]* @y, i64 0, i64 %i
72   %x.ld.addr = getelementptr [256 x i32]* @x, i64 1, i64 %i.256
73   %x.st.addr = getelementptr [256 x i32]* @x, i64 0, i64 %i
74   %x = load i32* %x.ld.addr     ; 0
75   %y = load i32* %y.ld.addr     ; 1
76   %r = add i32 %y, %x
77   store i32 %r, i32* %x.st.addr ; 2
78 ; CHECK: 0,2: dep
79 ; CHECK: 1,2: ind
80   %i.next = add i64 %i, 1
81   %exitcond = icmp eq i64 %i.next, 100
82   br i1 %exitcond, label %for.end, label %for.body
83
84 for.end:
85   ret void
86 }