1 ; RUN: opt -verify-loop-info -irce -S < %s | FileCheck %s
2 ; RUN: opt -verify-loop-info -passes='require<branch-prob>,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:[^ ]+]] = call i32 @llvm.smin.i32(i32 %len.b, i32 %len.a)
42 ; CHECK: [[upper_limit_loclamp:[^ ]+]] = call i32 @llvm.smin.i32(i32 [[smax_len]], i32 %n)
43 ; CHECK: [[upper_limit:[^ ]+]] = call i32 @llvm.smax.i32(i32 [[upper_limit_loclamp]], i32 0)
46 ; CHECK: br i1 true, label %in.bounds.a, label %out.of.bounds
49 ; CHECK: br i1 true, label %in.bounds.b, label %out.of.bounds
52 ; CHECK: [[main_loop_cond:[^ ]+]] = icmp slt i32 %idx.next, [[upper_limit]]
53 ; CHECK: br i1 [[main_loop_cond]], label %loop, label %main.exit.selector
55 ; CHECK: in.bounds.b.postloop:
56 ; CHECK: %next.postloop = icmp slt i32 %idx.next.postloop, %n
57 ; CHECK: br i1 %next.postloop, label %loop.postloop, label %exit.loopexit
59 !0 = !{i32 0, i32 2147483647}
60 !1 = !{!"branch_weights", i32 128, i32 4}