1 ; RUN: opt -irce-print-changed-loops -verify-loop-info -irce -S < %s 2>&1 | FileCheck %s
2 ; RUN: opt -irce-print-changed-loops -verify-loop-info -passes='require<branch-prob>,loop(irce)' -S < %s 2>&1 | FileCheck %s
4 ; CHECK-NOT: constrained Loop at depth
6 ; Demonstrates that we don't currently handle the general expression
9 define void @general_affine_expressions(i32 *%arr, i32 *%a_len_ptr, i32 %n,
10 i32 %scale, i32 %offset) {
12 %len = load i32, i32* %a_len_ptr, !range !0
13 %first.itr.check = icmp sgt i32 %n, 0
14 br i1 %first.itr.check, label %loop, label %exit
17 %idx = phi i32 [ 0, %entry ] , [ %idx.next, %in.bounds ]
18 %idx.next = add i32 %idx, 1
19 %idx.mul = mul i32 %idx, %scale
20 %array.idx = add i32 %idx.mul, %offset
21 %abc.high = icmp slt i32 %array.idx, %len
22 %abc.low = icmp sge i32 %array.idx, 0
23 %abc = and i1 %abc.low, %abc.high
24 br i1 %abc, label %in.bounds, label %out.of.bounds, !prof !1
27 %addr = getelementptr i32, i32* %arr, i32 %array.idx
28 store i32 0, i32* %addr
29 %next = icmp slt i32 %idx.next, %n
30 br i1 %next, label %loop, label %exit
39 ; Check that we do the right thing for a loop that could not be
40 ; simplified due to an indirectbr.
42 define void @multiple_latches(i32 *%arr, i32 *%a_len_ptr, i32 %n) {
44 %len = load i32, i32* %a_len_ptr, !range !0
45 %n.add.1 = add i32 %n, 1
46 %first.itr.check = icmp sgt i32 %n, 0
47 br i1 %first.itr.check, label %loop, label %exit
50 %idx = phi i32 [ 0, %entry ], [ %idx.next, %in.bounds ], [ %idx.next, %continue ]
51 %idx.next = add i32 %idx, 1
52 %idx.next2 = add i32 %idx, 2
53 %abc = icmp slt i32 %idx, %len
54 br i1 %abc, label %in.bounds, label %out.of.bounds, !prof !1
57 %addr = getelementptr i32, i32* %arr, i32 %idx
58 store i32 0, i32* %addr
59 %next = icmp slt i32 %idx.next, %n
60 br i1 %next, label %loop, label %continue
63 %next2 = icmp slt i32 %idx.next, %n.add.1
64 %dest = select i1 %next2, i8* blockaddress(@multiple_latches, %loop), i8* blockaddress(@multiple_latches, %exit)
65 indirectbr i8* %dest, [ label %loop, label %exit]
74 define void @already_cloned(i32 *%arr, i32 *%a_len_ptr, i32 %n) {
76 %len = load i32, i32* %a_len_ptr, !range !0
77 %first.itr.check = icmp sgt i32 %n, 0
78 br i1 %first.itr.check, label %loop, label %exit
81 %idx = phi i32 [ 0, %entry ] , [ %idx.next, %in.bounds ]
82 %idx.next = add i32 %idx, 1
83 %abc = icmp slt i32 %idx, %len
84 br i1 %abc, label %in.bounds, label %out.of.bounds, !prof !1
87 %addr = getelementptr i32, i32* %arr, i32 %idx
88 store i32 0, i32* %addr
89 %next = icmp slt i32 %idx.next, %n
90 br i1 %next, label %loop, label %exit, !irce.loop.clone !{}
99 !0 = !{i32 0, i32 2147483647}
100 !1 = !{!"branch_weights", i32 64, i32 4}