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[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 %y.addr = getelementptr [256 x i32]* @y, i64 0, i64 %i 16 %x.addr = getelementptr [256 x i32]* @x, i64 0, i64 %i 17 %x = load i32* %x.addr ; 0 18 %y = load i32* %y.addr ; 1 19 %r = add i32 %y, %x 20 store i32 %r, i32* %x.addr ; 2 21 ; CHECK: 0,2: dep 22 ; CHECK: 1,2: ind 23 %i.next = add i64 %i, 1 24 %exitcond = icmp eq i64 %i.next, 256 25 br i1 %exitcond, label %for.end, label %for.body 26 27 for.end: 28 ret void 29 } 30 31 ;; for (i = 0; i < 256; i++) 32 ;; x[i+1] = x[i] + y[i] 33 34 define void @f2(...) nounwind { 35 entry: 36 br label %for.body 37 38 for.body: 39 %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ] 40 %y.ld.addr = getelementptr [256 x i32]* @y, i64 0, i64 %i 41 %x.ld.addr = getelementptr [256 x i32]* @x, i64 0, i64 %i 42 %i.next = add i64 %i, 1 43 %x.st.addr = getelementptr [256 x i32]* @x, i64 0, i64 %i.next 44 %x = load i32* %x.ld.addr ; 0 45 %y = load i32* %y.ld.addr ; 1 46 %r = add i32 %y, %x 47 store i32 %r, i32* %x.st.addr ; 2 48 ; CHECK: 0,2: dep 49 ; CHECK: 1,2: ind 50 %exitcond = icmp eq i64 %i.next, 256 51 br i1 %exitcond, label %for.end, label %for.body 52 53 for.end: 54 ret void 55 } 56 57 ;; for (i = 0; i < 10; i++) 58 ;; x[i+20] = x[i] + y[i] 59 60 define void @f3(...) nounwind { 61 entry: 62 br label %for.body 63 64 for.body: 65 %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ] 66 %y.ld.addr = getelementptr [256 x i32]* @y, i64 0, i64 %i 67 %x.ld.addr = getelementptr [256 x i32]* @x, i64 0, i64 %i 68 %i.20 = add i64 %i, 20 69 %x.st.addr = getelementptr [256 x i32]* @x, i64 0, i64 %i.20 70 %x = load i32* %x.ld.addr ; 0 71 %y = load i32* %y.ld.addr ; 1 72 %r = add i32 %y, %x 73 store i32 %r, i32* %x.st.addr ; 2 74 ; CHECK: 0,2: dep 75 ; CHECK: 1,2: ind 76 %i.next = add i64 %i, 1 77 %exitcond = icmp eq i64 %i.next, 10 78 br i1 %exitcond, label %for.end, label %for.body 79 80 for.end: 81 ret void 82 } 83 84 ;; for (i = 0; i < 10; i++) 85 ;; x[10*i+1] = x[10*i] + y[i] 86 87 define void @f4(...) nounwind { 88 entry: 89 br label %for.body 90 91 for.body: 92 %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ] 93 %i.10 = mul i64 %i, 10 94 %y.ld.addr = getelementptr [256 x i32]* @y, i64 0, i64 %i.10 95 %x.ld.addr = getelementptr [256 x i32]* @x, i64 0, i64 %i.10 96 %i.10.1 = add i64 %i.10, 1 97 %x.st.addr = getelementptr [256 x i32]* @x, i64 0, i64 %i.10.1 98 %x = load i32* %x.ld.addr ; 0 99 %y = load i32* %y.ld.addr ; 1 100 %r = add i32 %y, %x 101 store i32 %r, i32* %x.st.addr ; 2 102 ; CHECK: 0,2: dep 103 ; CHECK: 1,2: ind 104 %i.next = add i64 %i, 1 105 %exitcond = icmp eq i64 %i.next, 10 106 br i1 %exitcond, label %for.end, label %for.body 107 108 for.end: 109 ret void 110 } 111