Home | History | Annotate | Download | only in IRCE
      1 ; RUN: opt -irce -S < %s | FileCheck %s
      2 
      3 define void @multiple_access_no_preloop(
      4     i32* %arr_a, i32* %a_len_ptr, i32* %arr_b, i32* %b_len_ptr, i32 %n) {
      5 
      6  entry:
      7   %len.a = load i32, i32* %a_len_ptr, !range !0
      8   %len.b = load i32, i32* %b_len_ptr, !range !0
      9   %first.itr.check = icmp sgt i32 %n, 0
     10   br i1 %first.itr.check, label %loop, label %exit
     11 
     12  loop:
     13   %idx = phi i32 [ 0, %entry ] , [ %idx.next, %in.bounds.b ]
     14   %idx.next = add i32 %idx, 1
     15   %abc.a = icmp slt i32 %idx, %len.a
     16   br i1 %abc.a, label %in.bounds.a, label %out.of.bounds, !prof !1
     17 
     18  in.bounds.a:
     19   %addr.a = getelementptr i32, i32* %arr_a, i32 %idx
     20   store i32 0, i32* %addr.a
     21   %abc.b = icmp slt i32 %idx, %len.b
     22   br i1 %abc.b, label %in.bounds.b, label %out.of.bounds, !prof !1
     23 
     24  in.bounds.b:
     25   %addr.b = getelementptr i32, i32* %arr_b, i32 %idx
     26   store i32 -1, i32* %addr.b
     27   %next = icmp slt i32 %idx.next, %n
     28   br i1 %next, label %loop, label %exit
     29 
     30  out.of.bounds:
     31   ret void
     32 
     33  exit:
     34   ret void
     35 }
     36 
     37 ; CHECK-LABEL: multiple_access_no_preloop
     38 
     39 ; CHECK-LABEL: loop.preheader:
     40 ; CHECK: [[not_len_b:[^ ]+]] = sub i32 -1, %len.b
     41 ; CHECK: [[not_len_a:[^ ]+]] = sub i32 -1, %len.a
     42 ; CHECK: [[smax_not_len_cond:[^ ]+]] = icmp sgt i32 [[not_len_b]], [[not_len_a]]
     43 ; CHECK: [[smax_not_len:[^ ]+]] = select i1 [[smax_not_len_cond]], i32 [[not_len_b]], i32 [[not_len_a]]
     44 ; CHECK: [[not_n:[^ ]+]] = sub i32 -1, %n
     45 ; CHECK: [[not_upper_limit_cond_loclamp:[^ ]+]] = icmp sgt i32 [[smax_not_len]], [[not_n]]
     46 ; CHECK: [[not_upper_limit_loclamp:[^ ]+]] = select i1 [[not_upper_limit_cond_loclamp]], i32 [[smax_not_len]], i32 [[not_n]]
     47 ; CHECK: [[upper_limit_loclamp:[^ ]+]] = sub i32 -1, [[not_upper_limit_loclamp]]
     48 ; CHECK: [[upper_limit_cmp:[^ ]+]] = icmp sgt i32 [[upper_limit_loclamp]], 0
     49 ; CHECK: [[upper_limit:[^ ]+]] = select i1 [[upper_limit_cmp]], i32 [[upper_limit_loclamp]], i32 0
     50 
     51 ; CHECK-LABEL: loop:
     52 ; CHECK: br i1 true, label %in.bounds.a, label %out.of.bounds
     53 
     54 ; CHECK-LABEL: in.bounds.a:
     55 ; CHECK: br i1 true, label %in.bounds.b, label %out.of.bounds
     56 
     57 ; CHECK-LABEL: in.bounds.b:
     58 ; CHECK: [[main_loop_cond:[^ ]+]] = icmp slt i32 %idx.next, [[upper_limit]]
     59 ; CHECK: br i1 [[main_loop_cond]], label %loop, label %main.exit.selector
     60 
     61 ; CHECK-LABEL: in.bounds.b.postloop:
     62 ; CHECK: %next.postloop = icmp slt i32 %idx.next.postloop, %n
     63 ; CHECK: br i1 %next.postloop, label %loop.postloop, label %exit.loopexit
     64 
     65 !0 = !{i32 0, i32 2147483647}
     66 !1 = !{!"branch_weights", i32 64, i32 4}
     67