1; RUN: opt < %s -disable-output "-passes=print<da>" -aa-pipeline=basic-aa 2>&1 \ 2; RUN: | FileCheck %s 3; RUN: opt < %s -analyze -basicaa -da | FileCheck %s 4 5; Test that the dependence analysis generates the correct results when using 6; an aliased object that points to a different element in the same array. 7; PR33567 - https://bugs.llvm.org/show_bug.cgi?id=33567 8 9; void test1(int *A, int *B, int N) { 10; int *top = A; 11; int *bot = A + N/2; 12; for (int i = 0; i < N; i++) 13; B[i] = top[i] + bot[i]; 14; } 15 16; CHECK-LABEL: test1 17; CHECK: da analyze - input [*|<]! 18 19define void @test1(i32* nocapture %A, i32* nocapture %B, i32 %N) #0 { 20entry: 21 %cmp9 = icmp sgt i32 %N, 0 22 br i1 %cmp9, label %for.body.lr.ph, label %for.end 23 24for.body.lr.ph: 25 %div = sdiv i32 %N, 2 26 %bot.gep = getelementptr i32, i32* %A, i32 %div 27 br label %for.body 28 29for.body: 30 %i = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ] 31 %gep.0 = getelementptr i32, i32* %A, i32 %i 32 %gep.1 = getelementptr i32, i32* %bot.gep, i32 %i 33 %gep.B = getelementptr i32, i32* %B, i32 %i 34 %0 = load i32, i32* %gep.0, align 4 35 %1 = load i32, i32* %gep.1, align 4 36 %add = add nsw i32 %1, %0 37 store i32 %add, i32* %gep.B, align 4 38 %inc = add nsw i32 %i, 1 39 %exitcond = icmp eq i32 %inc, %N 40 br i1 %exitcond, label %for.end, label %for.body 41 42for.end: 43 ret void 44} 45 46 47; void test2(int *A, unsigned n) { 48; int *B = A + 1; 49; for (unsigned i = 0; i < n; ++i) { 50; A[i] = B[i]; 51; } 52; } 53 54; CHECK-LABEL: test2 55; CHECK: da analyze - consistent anti [1]! 56 57define void @test2(i32*, i32) #3 { 58 %3 = getelementptr inbounds i32, i32* %0, i64 1 59 br label %4 60 61; <label>:4: 62 %.0 = phi i32 [ 0, %2 ], [ %14, %13 ] 63 %5 = sub i32 %1, 1 64 %6 = icmp ult i32 %.0, %5 65 br i1 %6, label %7, label %15 66 67; <label>:7: 68 %8 = zext i32 %.0 to i64 69 %9 = getelementptr inbounds i32, i32* %3, i64 %8 70 %10 = load i32, i32* %9, align 4 71 %11 = zext i32 %.0 to i64 72 %12 = getelementptr inbounds i32, i32* %0, i64 %11 73 store i32 %10, i32* %12, align 4 74 br label %13 75 76; <label>:13: 77 %14 = add i32 %.0, 1 78 br label %4 79 80; <label>:15: 81 ret void 82} 83