1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt -S -passes=loop-unroll -unroll-allow-partial < %s | FileCheck %s
6 define void @test(i8 %start1, i8 %start2, i8 %start3, i8 %start4) {
7 ; CHECK-LABEL: define void @test
8 ; CHECK-SAME: (i8 [[START1:%.*]], i8 [[START2:%.*]], i8 [[START3:%.*]], i8 [[START4:%.*]]) {
10 ; CHECK-NEXT: br label [[LOOP:%.*]]
12 ; CHECK-NEXT: [[IV:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT_4:%.*]], [[LOOP]] ]
13 ; CHECK-NEXT: [[IV1:%.*]] = phi i8 [ [[START1]], [[ENTRY]] ], [ [[IV1_NEXT_4:%.*]], [[LOOP]] ]
14 ; CHECK-NEXT: [[IV2:%.*]] = phi i8 [ [[START2]], [[ENTRY]] ], [ [[IV2_NEXT_4:%.*]], [[LOOP]] ]
15 ; CHECK-NEXT: [[IV3:%.*]] = phi i8 [ [[START3]], [[ENTRY]] ], [ [[IV3_NEXT_4:%.*]], [[LOOP]] ]
16 ; CHECK-NEXT: [[IV4:%.*]] = phi i8 [ [[START4]], [[ENTRY]] ], [ [[IV4_NEXT_4:%.*]], [[LOOP]] ]
17 ; CHECK-NEXT: [[IV1_NEXT:%.*]] = add i8 [[IV1]], 1
18 ; CHECK-NEXT: call void @use(i8 [[IV1_NEXT]])
19 ; CHECK-NEXT: [[IV2_NEXT:%.*]] = add nuw i8 [[IV2]], 1
20 ; CHECK-NEXT: call void @use(i8 [[IV2_NEXT]])
21 ; CHECK-NEXT: [[IV3_NEXT:%.*]] = add nsw i8 [[IV3]], 1
22 ; CHECK-NEXT: call void @use(i8 [[IV3_NEXT]])
23 ; CHECK-NEXT: [[IV4_NEXT:%.*]] = add nsw i8 [[IV4]], 127
24 ; CHECK-NEXT: call void @use(i8 [[IV4_NEXT]])
25 ; CHECK-NEXT: [[IV1_NEXT_1:%.*]] = add i8 [[IV1]], 2
26 ; CHECK-NEXT: call void @use(i8 [[IV1_NEXT_1]])
27 ; CHECK-NEXT: [[IV2_NEXT_1:%.*]] = add nuw i8 [[IV2]], 2
28 ; CHECK-NEXT: call void @use(i8 [[IV2_NEXT_1]])
29 ; CHECK-NEXT: [[IV3_NEXT_1:%.*]] = add nsw i8 [[IV3]], 2
30 ; CHECK-NEXT: call void @use(i8 [[IV3_NEXT_1]])
31 ; CHECK-NEXT: [[IV4_NEXT_1:%.*]] = add i8 [[IV4]], -2
32 ; CHECK-NEXT: call void @use(i8 [[IV4_NEXT_1]])
33 ; CHECK-NEXT: [[IV1_NEXT_2:%.*]] = add i8 [[IV1]], 3
34 ; CHECK-NEXT: call void @use(i8 [[IV1_NEXT_2]])
35 ; CHECK-NEXT: [[IV2_NEXT_2:%.*]] = add nuw i8 [[IV2]], 3
36 ; CHECK-NEXT: call void @use(i8 [[IV2_NEXT_2]])
37 ; CHECK-NEXT: [[IV3_NEXT_2:%.*]] = add nsw i8 [[IV3]], 3
38 ; CHECK-NEXT: call void @use(i8 [[IV3_NEXT_2]])
39 ; CHECK-NEXT: [[IV4_NEXT_2:%.*]] = add i8 [[IV4]], 125
40 ; CHECK-NEXT: call void @use(i8 [[IV4_NEXT_2]])
41 ; CHECK-NEXT: [[IV1_NEXT_3:%.*]] = add i8 [[IV1]], 4
42 ; CHECK-NEXT: call void @use(i8 [[IV1_NEXT_3]])
43 ; CHECK-NEXT: [[IV2_NEXT_3:%.*]] = add nuw i8 [[IV2]], 4
44 ; CHECK-NEXT: call void @use(i8 [[IV2_NEXT_3]])
45 ; CHECK-NEXT: [[IV3_NEXT_3:%.*]] = add nsw i8 [[IV3]], 4
46 ; CHECK-NEXT: call void @use(i8 [[IV3_NEXT_3]])
47 ; CHECK-NEXT: [[IV4_NEXT_3:%.*]] = add i8 [[IV4]], -4
48 ; CHECK-NEXT: call void @use(i8 [[IV4_NEXT_3]])
49 ; CHECK-NEXT: [[IV_NEXT_3:%.*]] = add nuw nsw i32 [[IV]], 4
50 ; CHECK-NEXT: [[IV1_NEXT_4]] = add i8 [[IV1]], 5
51 ; CHECK-NEXT: call void @use(i8 [[IV1_NEXT_4]])
52 ; CHECK-NEXT: [[IV2_NEXT_4]] = add nuw i8 [[IV2]], 5
53 ; CHECK-NEXT: call void @use(i8 [[IV2_NEXT_4]])
54 ; CHECK-NEXT: [[IV3_NEXT_4]] = add nsw i8 [[IV3]], 5
55 ; CHECK-NEXT: call void @use(i8 [[IV3_NEXT_4]])
56 ; CHECK-NEXT: [[IV4_NEXT_4]] = add i8 [[IV4]], 123
57 ; CHECK-NEXT: call void @use(i8 [[IV4_NEXT_4]])
58 ; CHECK-NEXT: [[IV_NEXT_4]] = add nuw nsw i32 [[IV]], 5
59 ; CHECK-NEXT: [[CMP_4:%.*]] = icmp eq i32 [[IV_NEXT_3]], 1024
60 ; CHECK-NEXT: br i1 [[CMP_4]], label [[EXIT:%.*]], label [[LOOP]]
62 ; CHECK-NEXT: ret void
68 %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
69 %iv1 = phi i8 [ %start1, %entry ], [ %iv1.next, %loop ]
70 %iv2 = phi i8 [ %start2, %entry ], [ %iv2.next, %loop ]
71 %iv3 = phi i8 [ %start3, %entry ], [ %iv3.next, %loop ]
72 %iv4 = phi i8 [ %start4, %entry ], [ %iv4.next, %loop ]
73 %iv1.next = add i8 %iv1, 1
74 call void @use(i8 %iv1.next)
75 %iv2.next = add nuw i8 %iv2, 1
76 call void @use(i8 %iv2.next)
77 %iv3.next = add nsw i8 %iv3, 1
78 call void @use(i8 %iv3.next)
79 %iv4.next = add nsw i8 %iv4, 127
80 call void @use(i8 %iv4.next)
81 %iv.next = add i32 %iv, 1
82 %cmp = icmp eq i32 %iv, 1024
83 br i1 %cmp, label %exit, label %loop