1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=loop-unroll -S < %s | FileCheck %s
4 define i32 @test(i32 %a, i32 %b, i32 %c) optsize {
7 ; CHECK-NEXT: [[REF_TMP:%.*]] = alloca [3 x i32], align 4
8 ; CHECK-NEXT: store i32 [[A:%.*]], ptr [[REF_TMP]], align 4
9 ; CHECK-NEXT: [[ARRAYINIT_ELEMENT:%.*]] = getelementptr inbounds [3 x i32], ptr [[REF_TMP]], i64 0, i64 1
10 ; CHECK-NEXT: store i32 [[B:%.*]], ptr [[ARRAYINIT_ELEMENT]], align 4
11 ; CHECK-NEXT: [[ARRAYINIT_ELEMENT1:%.*]] = getelementptr inbounds [3 x i32], ptr [[REF_TMP]], i64 0, i64 2
12 ; CHECK-NEXT: store i32 [[C:%.*]], ptr [[ARRAYINIT_ELEMENT1]], align 4
13 ; CHECK-NEXT: [[CMP_I_I_I3:%.*]] = icmp slt i32 [[A]], [[B]]
14 ; CHECK-NEXT: [[SPEC_SELECT_I_I4:%.*]] = select i1 [[CMP_I_I_I3]], ptr [[ARRAYINIT_ELEMENT]], ptr [[REF_TMP]]
15 ; CHECK-NEXT: [[INCDEC_PTR_I_I5:%.*]] = getelementptr inbounds [3 x i32], ptr [[REF_TMP]], i64 0, i64 2
16 ; CHECK-NEXT: br label [[LOOP:%.*]]
18 ; CHECK-NEXT: [[DOTPRE:%.*]] = load i32, ptr [[SPEC_SELECT_I_I4]], align 4
19 ; CHECK-NEXT: [[DOTPRE2:%.*]] = load i32, ptr [[INCDEC_PTR_I_I5]], align 4
20 ; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp slt i32 [[DOTPRE]], [[DOTPRE2]]
21 ; CHECK-NEXT: [[SPEC_SELECT_I_I:%.*]] = select i1 [[CMP_I_I_I]], ptr [[INCDEC_PTR_I_I5]], ptr [[SPEC_SELECT_I_I4]]
22 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[SPEC_SELECT_I_I]], align 4
23 ; CHECK-NEXT: ret i32 [[TMP1]]
26 %ref.tmp = alloca [3 x i32], align 4
27 store i32 %a, ptr %ref.tmp, align 4
28 %arrayinit.element = getelementptr inbounds [3 x i32], ptr %ref.tmp, i64 0, i64 1
29 store i32 %b, ptr %arrayinit.element, align 4
30 %arrayinit.element1 = getelementptr inbounds [3 x i32], ptr %ref.tmp, i64 0, i64 2
31 store i32 %c, ptr %arrayinit.element1, align 4
32 %add.ptr.i.i = getelementptr inbounds [3 x i32], ptr %ref.tmp, i64 0, i64 3
33 %cmp.i.i.i3 = icmp slt i32 %a, %b
34 %spec.select.i.i4 = select i1 %cmp.i.i.i3, ptr %arrayinit.element, ptr %ref.tmp
35 %incdec.ptr.i.i5 = getelementptr inbounds [3 x i32], ptr %ref.tmp, i64 0, i64 2
38 loop: ; preds = %entry, %loop
39 %incdec.ptr.i.i7 = phi ptr [ %incdec.ptr.i.i5, %entry ], [ %incdec.ptr.i.i, %loop ]
40 %spec.select.i.i6 = phi ptr [ %spec.select.i.i4, %entry ], [ %spec.select.i.i, %loop ]
41 %.pre = load i32, ptr %spec.select.i.i6, align 4
42 %.pre2 = load i32, ptr %incdec.ptr.i.i7, align 4
43 %cmp.i.i.i = icmp slt i32 %.pre, %.pre2
44 %spec.select.i.i = select i1 %cmp.i.i.i, ptr %incdec.ptr.i.i7, ptr %spec.select.i.i6
45 %incdec.ptr.i.i = getelementptr inbounds i32, ptr %incdec.ptr.i.i7, i64 1
46 %cmp1.i.i = icmp eq ptr %incdec.ptr.i.i, %add.ptr.i.i
47 br i1 %cmp1.i.i, label %exit, label %loop
50 %0 = load i32, ptr %spec.select.i.i, align 4