|
1 |
| -; RUN: opt -passes='default<O1>' -disable-verify --mtriple x86_64-pc-linux-gnu -disable-loop-unrolling=true \ |
2 |
| -; RUN: -S -o - %s | FileCheck %s |
| 1 | +; RUN: opt -passes='loop-unroll-full' -disable-verify --mtriple x86_64-pc-linux-gnu -S -o - %s | FileCheck %s |
3 | 2 |
|
4 | 3 | ; This checks that the loop full unroller will fire in the new pass manager
|
5 | 4 | ; when forced via #pragma in the source (or annotation in the code).
|
6 |
| -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" |
7 |
| -target triple = "x86_64-unknown-linux-gnu" |
8 | 5 |
|
9 |
| -; We don't end up deleting the loop, merely turning it infinite, but we remove |
10 |
| -; everything inside of it so check for the loop structure and absence of |
11 |
| -; conditional branches. |
12 |
| -; CHECK-LABEL: bb |
13 |
| -; CHECK: br label |
14 |
| -; CHECK-NOT: br i1 |
15 |
| -; CHECK: br label |
| 6 | +; Completely unroll the inner loop |
| 7 | +; CHECK-LABEL: @foo |
| 8 | +; CHECK: br i1 |
16 | 9 | ; CHECK-NOT: br i1
|
17 | 10 |
|
18 | 11 | ; Function Attrs: noinline nounwind optnone uwtable
|
19 |
| -define void @foo() #0 { |
| 12 | +define void @foo() local_unnamed_addr #0 { |
20 | 13 | bb:
|
21 | 14 | %tmp = alloca [5 x i32*], align 16
|
22 |
| - %tmp1 = alloca i32, align 4 |
23 |
| - %tmp2 = alloca i32, align 4 |
24 |
| - store i32 5, i32* %tmp1, align 4 |
25 |
| - br label %bb3 |
26 |
| - |
27 |
| -bb3: ; preds = %bb23, %bb |
28 |
| - %tmp4 = load i32, i32* %tmp1, align 4 |
29 |
| - %tmp5 = icmp ne i32 %tmp4, 0 |
30 |
| - br i1 %tmp5, label %bb6, label %bb24 |
| 15 | + br label %bb7.preheader |
31 | 16 |
|
32 |
| -bb6: ; preds = %bb3 |
33 |
| - store i32 0, i32* %tmp2, align 4 |
34 |
| - br label %bb7 |
| 17 | +bb3.loopexit: ; preds = %bb10 |
| 18 | + %spec.select.lcssa = phi i32 [ %spec.select, %bb10 ] |
| 19 | + %tmp5.not = icmp eq i32 %spec.select.lcssa, 0 |
| 20 | + br i1 %tmp5.not, label %bb24, label %bb7.preheader |
35 | 21 |
|
36 |
| -bb7: ; preds = %bb20, %bb6 |
37 |
| - %tmp8 = load i32, i32* %tmp2, align 4 |
38 |
| - %tmp9 = icmp slt i32 %tmp8, 5 |
39 |
| - br i1 %tmp9, label %bb10, label %bb23 |
| 22 | +bb7.preheader: ; preds = %bb3.loopexit, %bb |
| 23 | + %tmp1.06 = phi i32 [ 5, %bb ], [ %spec.select.lcssa, %bb3.loopexit ] |
| 24 | + br label %bb10 |
40 | 25 |
|
41 |
| -bb10: ; preds = %bb7 |
42 |
| - %tmp11 = load i32, i32* %tmp2, align 4 |
43 |
| - %tmp12 = sext i32 %tmp11 to i64 |
44 |
| - %tmp13 = getelementptr inbounds [5 x i32*], [5 x i32*]* %tmp, i64 0, i64 %tmp12 |
| 26 | +bb10: ; preds = %bb10, %bb7.preheader |
| 27 | + %indvars.iv = phi i64 [ 0, %bb7.preheader ], [ %indvars.iv.next, %bb10 ] |
| 28 | + %tmp1.14 = phi i32 [ %tmp1.06, %bb7.preheader ], [ %spec.select, %bb10 ] |
| 29 | + %tmp13 = getelementptr inbounds [5 x i32*], [5 x i32*]* %tmp, i64 0, i64 %indvars.iv |
45 | 30 | %tmp14 = load i32*, i32** %tmp13, align 8
|
46 |
| - %tmp15 = icmp ne i32* %tmp14, null |
47 |
| - br i1 %tmp15, label %bb16, label %bb19 |
48 |
| - |
49 |
| -bb16: ; preds = %bb10 |
50 |
| - %tmp17 = load i32, i32* %tmp1, align 4 |
51 |
| - %tmp18 = add nsw i32 %tmp17, -1 |
52 |
| - store i32 %tmp18, i32* %tmp1, align 4 |
53 |
| - br label %bb19 |
54 |
| - |
55 |
| -bb19: ; preds = %bb16, %bb10 |
56 |
| - br label %bb20 |
57 |
| - |
58 |
| -bb20: ; preds = %bb19 |
59 |
| - %tmp21 = load i32, i32* %tmp2, align 4 |
60 |
| - %tmp22 = add nsw i32 %tmp21, 1 |
61 |
| - store i32 %tmp22, i32* %tmp2, align 4 |
62 |
| - br label %bb7, !llvm.loop !1 |
63 |
| - |
64 |
| -bb23: ; preds = %bb7 |
65 |
| - br label %bb3 |
66 |
| - |
67 |
| -bb24: ; preds = %bb3 |
| 31 | + %tmp15.not = icmp ne i32* %tmp14, null |
| 32 | + %tmp18 = sext i1 %tmp15.not to i32 |
| 33 | + %spec.select = add nsw i32 %tmp1.14, %tmp18 |
| 34 | + %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 |
| 35 | + %exitcond.not = icmp eq i64 %indvars.iv.next, 5 |
| 36 | + br i1 %exitcond.not, label %bb3.loopexit, label %bb10, !llvm.loop !1 |
| 37 | + |
| 38 | +bb24: ; preds = %bb3.loopexit |
68 | 39 | ret void
|
69 | 40 | }
|
70 | 41 |
|
|
0 commit comments