diff options
author | Stephen Hines <srhines@google.com> | 2015-04-01 18:49:24 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-04-01 18:49:26 +0000 |
commit | 3fa16bd6062e23bcdb82ed4dd965674792e6b761 (patch) | |
tree | 9348fc507292f7e8715d22d64ce5a32131b4f875 /test/Transforms/LoopReroll/basic.ll | |
parent | beed47390a60f6f0c77532b3d3f76bb47ef49423 (diff) | |
parent | ebe69fe11e48d322045d5949c83283927a0d790b (diff) | |
download | external_llvm-3fa16bd6062e23bcdb82ed4dd965674792e6b761.zip external_llvm-3fa16bd6062e23bcdb82ed4dd965674792e6b761.tar.gz external_llvm-3fa16bd6062e23bcdb82ed4dd965674792e6b761.tar.bz2 |
Merge "Update aosp/master LLVM for rebase to r230699."
Diffstat (limited to 'test/Transforms/LoopReroll/basic.ll')
-rw-r--r-- | test/Transforms/LoopReroll/basic.ll | 254 |
1 files changed, 254 insertions, 0 deletions
diff --git a/test/Transforms/LoopReroll/basic.ll b/test/Transforms/LoopReroll/basic.ll index 3bd6d7a..7533461 100644 --- a/test/Transforms/LoopReroll/basic.ll +++ b/test/Transforms/LoopReroll/basic.ll @@ -322,6 +322,260 @@ for.end: ; preds = %for.body ret void } +; void multi1(int *x) { +; y = foo(0) +; for (int i = 0; i < 500; ++i) { +; x[3*i] = y; +; x[3*i+1] = y; +; x[3*i+2] = y; +; x[3*i+6] = y; +; x[3*i+7] = y; +; x[3*i+8] = y; +; } +; } + +; Function Attrs: nounwind uwtable +define void @multi1(i32* nocapture %x) #0 { +entry: + %call = tail call i32 @foo(i32 0) #1 + br label %for.body + +for.body: ; preds = %for.body, %entry + %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] + %0 = mul nsw i64 %indvars.iv, 3 + %arrayidx = getelementptr inbounds i32* %x, i64 %0 + store i32 %call, i32* %arrayidx, align 4 + %1 = add nsw i64 %0, 1 + %arrayidx4 = getelementptr inbounds i32* %x, i64 %1 + store i32 %call, i32* %arrayidx4, align 4 + %2 = add nsw i64 %0, 2 + %arrayidx9 = getelementptr inbounds i32* %x, i64 %2 + store i32 %call, i32* %arrayidx9, align 4 + %3 = add nsw i64 %0, 6 + %arrayidx6 = getelementptr inbounds i32* %x, i64 %3 + store i32 %call, i32* %arrayidx6, align 4 + %4 = add nsw i64 %0, 7 + %arrayidx7 = getelementptr inbounds i32* %x, i64 %4 + store i32 %call, i32* %arrayidx7, align 4 + %5 = add nsw i64 %0, 8 + %arrayidx8 = getelementptr inbounds i32* %x, i64 %5 + store i32 %call, i32* %arrayidx8, align 4 + %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 + %exitcond = icmp eq i64 %indvars.iv.next, 500 + br i1 %exitcond, label %for.end, label %for.body + +; CHECK-LABEL: @multi1 + +; CHECK:for.body: +; CHECK: %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] +; CHECK: %0 = add i64 %indvars.iv, 6 +; CHECK: %arrayidx = getelementptr inbounds i32* %x, i64 %indvars.iv +; CHECK: store i32 %call, i32* %arrayidx, align 4 +; CHECK: %arrayidx6 = getelementptr inbounds i32* %x, i64 %0 +; CHECK: store i32 %call, i32* %arrayidx6, align 4 +; CHECK: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 +; CHECK: %exitcond2 = icmp eq i64 %0, 1505 +; CHECK: br i1 %exitcond2, label %for.end, label %for.body + +for.end: ; preds = %for.body + ret void +} + +; void multi2(int *x) { +; y = foo(0) +; for (int i = 0; i < 500; ++i) { +; x[3*i] = y; +; x[3*i+1] = y; +; x[3*i+2] = y; +; x[3*(i+1)] = y; +; x[3*(i+1)+1] = y; +; x[3*(i+1)+2] = y; +; } +; } + +; Function Attrs: nounwind uwtable +define void @multi2(i32* nocapture %x) #0 { +entry: + %call = tail call i32 @foo(i32 0) #1 + br label %for.body + +for.body: ; preds = %for.body, %entry + %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] + %0 = mul nsw i64 %indvars.iv, 3 + %add = add nsw i64 %indvars.iv, 1 + %newmul = mul nsw i64 %add, 3 + %arrayidx = getelementptr inbounds i32* %x, i64 %0 + store i32 %call, i32* %arrayidx, align 4 + %1 = add nsw i64 %0, 1 + %arrayidx4 = getelementptr inbounds i32* %x, i64 %1 + store i32 %call, i32* %arrayidx4, align 4 + %2 = add nsw i64 %0, 2 + %arrayidx9 = getelementptr inbounds i32* %x, i64 %2 + store i32 %call, i32* %arrayidx9, align 4 + %arrayidx6 = getelementptr inbounds i32* %x, i64 %newmul + store i32 %call, i32* %arrayidx6, align 4 + %3 = add nsw i64 %newmul, 1 + %arrayidx7 = getelementptr inbounds i32* %x, i64 %3 + store i32 %call, i32* %arrayidx7, align 4 + %4 = add nsw i64 %newmul, 2 + %arrayidx8 = getelementptr inbounds i32* %x, i64 %4 + store i32 %call, i32* %arrayidx8, align 4 + %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 + %exitcond = icmp eq i64 %indvars.iv.next, 500 + br i1 %exitcond, label %for.end, label %for.body + +; CHECK-LABEL: @multi2 + +; CHECK:for.body: +; CHECK: %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] +; CHECK: %0 = add i64 %indvars.iv, 3 +; CHECK: %arrayidx = getelementptr inbounds i32* %x, i64 %indvars.iv +; CHECK: store i32 %call, i32* %arrayidx, align 4 +; CHECK: %arrayidx6 = getelementptr inbounds i32* %x, i64 %0 +; CHECK: store i32 %call, i32* %arrayidx6, align 4 +; CHECK: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 +; CHECK: %exitcond2 = icmp eq i64 %indvars.iv, 1499 +; CHECK: br i1 %exitcond2, label %for.end, label %for.body + +for.end: ; preds = %for.body + ret void +} + +; void multi3(int *x) { +; y = foo(0) +; for (int i = 0; i < 500; ++i) { +; // Note: No zero index +; x[3*i+3] = y; +; x[3*i+4] = y; +; x[3*i+5] = y; +; } +; } + +; Function Attrs: nounwind uwtable +define void @multi3(i32* nocapture %x) #0 { +entry: + %call = tail call i32 @foo(i32 0) #1 + br label %for.body + +for.body: ; preds = %for.body, %entry + %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] + %0 = mul nsw i64 %indvars.iv, 3 + %x0 = add nsw i64 %0, 3 + %add = add nsw i64 %indvars.iv, 1 + %arrayidx = getelementptr inbounds i32* %x, i64 %x0 + store i32 %call, i32* %arrayidx, align 4 + %1 = add nsw i64 %0, 4 + %arrayidx4 = getelementptr inbounds i32* %x, i64 %1 + store i32 %call, i32* %arrayidx4, align 4 + %2 = add nsw i64 %0, 5 + %arrayidx9 = getelementptr inbounds i32* %x, i64 %2 + store i32 %call, i32* %arrayidx9, align 4 + %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 + %exitcond = icmp eq i64 %indvars.iv.next, 500 + br i1 %exitcond, label %for.end, label %for.body + +; CHECK-LABEL: @multi3 +; CHECK: for.body: +; CHECK: %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] +; CHECK: %0 = add i64 %indvars.iv, 3 +; CHECK: %arrayidx = getelementptr inbounds i32* %x, i64 %0 +; CHECK: store i32 %call, i32* %arrayidx, align 4 +; CHECK: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 +; CHECK: %exitcond1 = icmp eq i64 %0, 1502 +; CHECK: br i1 %exitcond1, label %for.end, label %for.body + +for.end: ; preds = %for.body + ret void +} + +; int foo(int a); +; void bar2(int *x, int y, int z) { +; for (int i = 0; i < 500; i += 3) { +; foo(i+y+i*z); // Slightly reordered instruction order +; foo(i+1+y+(i+1)*z); +; foo(i+2+y+(i+2)*z); +; } +; } + +; Function Attrs: nounwind uwtable +define void @bar2(i32* nocapture readnone %x, i32 %y, i32 %z) #0 { +entry: + br label %for.body + +for.body: ; preds = %for.body, %entry + %i.08 = phi i32 [ 0, %entry ], [ %add3, %for.body ] + + %tmp1 = add i32 %i.08, %y + %tmp2 = mul i32 %i.08, %z + %tmp3 = add i32 %tmp2, %tmp1 + %call = tail call i32 @foo(i32 %tmp3) #1 + + %add = add nsw i32 %i.08, 1 + %tmp2a = mul i32 %add, %z + %tmp1a = add i32 %add, %y + %tmp3a = add i32 %tmp2a, %tmp1a + %calla = tail call i32 @foo(i32 %tmp3a) #1 + + %add2 = add nsw i32 %i.08, 2 + %tmp2b = mul i32 %add2, %z + %tmp1b = add i32 %add2, %y + %tmp3b = add i32 %tmp2b, %tmp1b + %callb = tail call i32 @foo(i32 %tmp3b) #1 + + %add3 = add nsw i32 %i.08, 3 + + %exitcond = icmp eq i32 %add3, 500 + br i1 %exitcond, label %for.end, label %for.body + +; CHECK-LABEL: @bar2 + +; CHECK: for.body: +; CHECK: %indvar = phi i32 [ %indvar.next, %for.body ], [ 0, %entry ] +; CHECK: %tmp1 = add i32 %indvar, %y +; CHECK: %tmp2 = mul i32 %indvar, %z +; CHECK: %tmp3 = add i32 %tmp2, %tmp1 +; CHECK: %call = tail call i32 @foo(i32 %tmp3) #1 +; CHECK: %indvar.next = add i32 %indvar, 1 +; CHECK: %exitcond1 = icmp eq i32 %indvar, 497 +; CHECK: br i1 %exitcond1, label %for.end, label %for.body + +; CHECK: ret + +for.end: ; preds = %for.body + ret void +} + +%struct.s = type { i32, i32 } + +; Function Attrs: nounwind uwtable +define void @gep1(%struct.s* nocapture %x) #0 { +entry: + %call = tail call i32 @foo(i32 0) #1 + br label %for.body + +for.body: ; preds = %for.body, %entry + %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] + %0 = mul nsw i64 %indvars.iv, 3 + %arrayidx = getelementptr inbounds %struct.s* %x, i64 %0, i32 0 + store i32 %call, i32* %arrayidx, align 4 + %1 = add nsw i64 %0, 1 + %arrayidx4 = getelementptr inbounds %struct.s* %x, i64 %1, i32 0 + store i32 %call, i32* %arrayidx4, align 4 + %2 = add nsw i64 %0, 2 + %arrayidx9 = getelementptr inbounds %struct.s* %x, i64 %2, i32 0 + store i32 %call, i32* %arrayidx9, align 4 + %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 + %exitcond = icmp eq i64 %indvars.iv.next, 500 + br i1 %exitcond, label %for.end, label %for.body + +; CHECK-LABEL: @gep1 +; This test is a crash test only. +; CHECK: ret +for.end: ; preds = %for.body + ret void +} + + attributes #0 = { nounwind uwtable } attributes #1 = { nounwind } |