• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -loop-unroll -S < %s | FileCheck %s
3
4define i32 @test(i32 %a, i32 %b, i32 %c) optsize {
5; CHECK-LABEL: @test(
6; CHECK-NEXT:  entry:
7; CHECK-NEXT:    [[REF_TMP:%.*]] = alloca [3 x i32], align 4
8; CHECK-NEXT:    [[TMP0:%.*]] = bitcast [3 x i32]* [[REF_TMP]] to i8*
9; CHECK-NEXT:    [[ARRAYINIT_BEGIN:%.*]] = getelementptr inbounds [3 x i32], [3 x i32]* [[REF_TMP]], i64 0, i64 0
10; CHECK-NEXT:    store i32 [[A:%.*]], i32* [[ARRAYINIT_BEGIN]], align 4
11; CHECK-NEXT:    [[ARRAYINIT_ELEMENT:%.*]] = getelementptr inbounds [3 x i32], [3 x i32]* [[REF_TMP]], i64 0, i64 1
12; CHECK-NEXT:    store i32 [[B:%.*]], i32* [[ARRAYINIT_ELEMENT]], align 4
13; CHECK-NEXT:    [[ARRAYINIT_ELEMENT1:%.*]] = getelementptr inbounds [3 x i32], [3 x i32]* [[REF_TMP]], i64 0, i64 2
14; CHECK-NEXT:    store i32 [[C:%.*]], i32* [[ARRAYINIT_ELEMENT1]], align 4
15; CHECK-NEXT:    [[ADD_PTR_I_I:%.*]] = getelementptr inbounds [3 x i32], [3 x i32]* [[REF_TMP]], i64 0, i64 3
16; CHECK-NEXT:    [[CMP_I_I_I3:%.*]] = icmp slt i32 [[A]], [[B]]
17; CHECK-NEXT:    [[SPEC_SELECT_I_I4:%.*]] = select i1 [[CMP_I_I_I3]], i32* [[ARRAYINIT_ELEMENT]], i32* [[ARRAYINIT_BEGIN]]
18; CHECK-NEXT:    [[INCDEC_PTR_I_I5:%.*]] = getelementptr inbounds [3 x i32], [3 x i32]* [[REF_TMP]], i64 0, i64 2
19; CHECK-NEXT:    br label [[LOOP:%.*]]
20; CHECK:       loop:
21; CHECK-NEXT:    [[DOTPRE:%.*]] = load i32, i32* [[SPEC_SELECT_I_I4]], align 4
22; CHECK-NEXT:    [[DOTPRE2:%.*]] = load i32, i32* [[INCDEC_PTR_I_I5]], align 4
23; CHECK-NEXT:    [[CMP_I_I_I:%.*]] = icmp slt i32 [[DOTPRE]], [[DOTPRE2]]
24; CHECK-NEXT:    [[SPEC_SELECT_I_I:%.*]] = select i1 [[CMP_I_I_I]], i32* [[INCDEC_PTR_I_I5]], i32* [[SPEC_SELECT_I_I4]]
25; CHECK-NEXT:    [[INCDEC_PTR_I_I:%.*]] = getelementptr inbounds i32, i32* [[INCDEC_PTR_I_I5]], i64 1
26; CHECK-NEXT:    [[TMP1:%.*]] = load i32, i32* [[SPEC_SELECT_I_I]], align 4
27; CHECK-NEXT:    ret i32 [[TMP1]]
28;
29entry:
30  %ref.tmp = alloca [3 x i32], align 4
31  %0 = bitcast [3 x i32]* %ref.tmp to i8*
32  %arrayinit.begin = getelementptr inbounds [3 x i32], [3 x i32]* %ref.tmp, i64 0, i64 0
33  store i32 %a, i32* %arrayinit.begin, align 4
34  %arrayinit.element = getelementptr inbounds [3 x i32], [3 x i32]* %ref.tmp, i64 0, i64 1
35  store i32 %b, i32* %arrayinit.element, align 4
36  %arrayinit.element1 = getelementptr inbounds [3 x i32], [3 x i32]* %ref.tmp, i64 0, i64 2
37  store i32 %c, i32* %arrayinit.element1, align 4
38  %add.ptr.i.i = getelementptr inbounds [3 x i32], [3 x i32]* %ref.tmp, i64 0, i64 3
39  %cmp.i.i.i3 = icmp slt i32 %a, %b
40  %spec.select.i.i4 = select i1 %cmp.i.i.i3, i32* %arrayinit.element, i32* %arrayinit.begin
41  %incdec.ptr.i.i5 = getelementptr inbounds [3 x i32], [3 x i32]* %ref.tmp, i64 0, i64 2
42  br label %loop
43
44loop:          ; preds = %entry, %loop
45  %incdec.ptr.i.i7 = phi i32* [ %incdec.ptr.i.i5, %entry ], [ %incdec.ptr.i.i, %loop ]
46  %spec.select.i.i6 = phi i32* [ %spec.select.i.i4, %entry ], [ %spec.select.i.i, %loop ]
47  %.pre = load i32, i32* %spec.select.i.i6, align 4
48  %.pre2 = load i32, i32* %incdec.ptr.i.i7, align 4
49  %cmp.i.i.i = icmp slt i32 %.pre, %.pre2
50  %spec.select.i.i = select i1 %cmp.i.i.i, i32* %incdec.ptr.i.i7, i32* %spec.select.i.i6
51  %incdec.ptr.i.i = getelementptr inbounds i32, i32* %incdec.ptr.i.i7, i64 1
52  %cmp1.i.i = icmp eq i32* %incdec.ptr.i.i, %add.ptr.i.i
53  br i1 %cmp1.i.i, label %exit, label %loop
54
55exit:           ; preds = %loop
56  %1 = load i32, i32* %spec.select.i.i, align 4
57  ret i32 %1
58}
59