1 ; RUN: opt -verify-loop-info -irce -S < %s | FileCheck %s
2 ; RUN: opt -verify-loop-info -passes='require<branch-prob>,loop(irce)' -S < %s | FileCheck %s
4 define void @multiple_access_no_preloop(
5 i32* %arr_a, i32* %a_len_ptr, i32* %arr_b, i32* %b_len_ptr, i32 %n) {
8 %len.a = load i32, i32* %a_len_ptr, !range !0
9 %len.b = load i32, i32* %b_len_ptr, !range !0
10 %first.itr.check = icmp sgt i32 %n, 0
11 br i1 %first.itr.check, label %loop, label %exit
14 %idx = phi i32 [ 0, %entry ] , [ %idx.next, %in.bounds.b ]
15 %idx.next = add i32 %idx, 1
16 %abc.a = icmp slt i32 %idx, %len.a
17 br i1 %abc.a, label %in.bounds.a, label %out.of.bounds, !prof !1
20 %addr.a = getelementptr i32, i32* %arr_a, i32 %idx
21 store i32 0, i32* %addr.a
22 %abc.b = icmp slt i32 %idx, %len.b
23 br i1 %abc.b, label %in.bounds.b, label %out.of.bounds, !prof !1
26 %addr.b = getelementptr i32, i32* %arr_b, i32 %idx
27 store i32 -1, i32* %addr.b
28 %next = icmp slt i32 %idx.next, %n
29 br i1 %next, label %loop, label %exit
38 ; CHECK-LABEL: @multiple_access_no_preloop(
40 ; CHECK: loop.preheader:
41 ; CHECK: [[smax_len_cond:[^ ]+]] = icmp slt i32 %len.b, %len.a
42 ; CHECK: [[smax_len:[^ ]+]] = select i1 [[smax_len_cond]], i32 %len.b, i32 %len.a
43 ; CHECK: [[upper_limit_cond_loclamp:[^ ]+]] = icmp slt i32 [[smax_len]], %n
44 ; CHECK: [[upper_limit_loclamp:[^ ]+]] = select i1 [[upper_limit_cond_loclamp]], i32 [[smax_len]], i32 %n
45 ; CHECK: [[upper_limit_cmp:[^ ]+]] = icmp sgt i32 [[upper_limit_loclamp]], 0
46 ; CHECK: [[upper_limit:[^ ]+]] = select i1 [[upper_limit_cmp]], i32 [[upper_limit_loclamp]], i32 0
49 ; CHECK: br i1 true, label %in.bounds.a, label %out.of.bounds
52 ; CHECK: br i1 true, label %in.bounds.b, label %out.of.bounds
55 ; CHECK: [[main_loop_cond:[^ ]+]] = icmp slt i32 %idx.next, [[upper_limit]]
56 ; CHECK: br i1 [[main_loop_cond]], label %loop, label %main.exit.selector
58 ; CHECK: in.bounds.b.postloop:
59 ; CHECK: %next.postloop = icmp slt i32 %idx.next.postloop, %n
60 ; CHECK: br i1 %next.postloop, label %loop.postloop, label %exit.loopexit
62 !0 = !{i32 0, i32 2147483647}
63 !1 = !{!"branch_weights", i32 64, i32 4}