xref: /llvm-project/llvm/test/Transforms/IRCE/bug-loop-varying-upper-limit.ll (revision 0ec421d024fe47fb43afdaa625309b0f799e9a59)
1*0ec421d0SRoman Lebedev; RUN: opt -irce-print-changed-loops -S -verify-loop-info -passes=irce,verify < %s 2>&1 | FileCheck %s
29c56e94aSArthur Eubanks; RUN: opt -irce-print-changed-loops -S -verify-loop-info -passes='require<branch-prob>,irce,verify' < %s 2>&1 | FileCheck %s
3cee313d2SEric Christopher
4cee313d2SEric Christopher; CHECK-NOT: constrained loop
5cee313d2SEric Christopher
6631432a3SMatt Arsenaultdefine void @single_access_no_preloop_no_offset(ptr %arr, ptr %a_len_ptr, i32 %n) {
7cee313d2SEric Christopher entry:
8cee313d2SEric Christopher  %first.itr.check = icmp sgt i32 %n, 0
9cee313d2SEric Christopher  br i1 %first.itr.check, label %loop, label %exit
10cee313d2SEric Christopher
11cee313d2SEric Christopher loop:
12cee313d2SEric Christopher  %idx = phi i32 [ 0, %entry ] , [ %idx.next, %in.bounds ]
13cee313d2SEric Christopher  %idx.next = add i32 %idx, 1
14631432a3SMatt Arsenault  %len = load i32, ptr %a_len_ptr, !range !0
15cee313d2SEric Christopher  %abc = icmp slt i32 %idx, %len
16cee313d2SEric Christopher  br i1 %abc, label %in.bounds, label %out.of.bounds, !prof !1
17cee313d2SEric Christopher
18cee313d2SEric Christopher in.bounds:
19631432a3SMatt Arsenault  %addr = getelementptr i32, ptr %arr, i32 %idx
20631432a3SMatt Arsenault  store i32 0, ptr %addr
21cee313d2SEric Christopher  %next = icmp slt i32 %idx.next, %n
22cee313d2SEric Christopher  br i1 %next, label %loop, label %exit
23cee313d2SEric Christopher
24cee313d2SEric Christopher out.of.bounds:
25cee313d2SEric Christopher  ret void
26cee313d2SEric Christopher
27cee313d2SEric Christopher exit:
28cee313d2SEric Christopher  ret void
29cee313d2SEric Christopher}
30cee313d2SEric Christopher
31cee313d2SEric Christopher!0 = !{i32 0, i32 2147483647}
32cee313d2SEric Christopher!1 = !{!"branch_weights", i32 64, i32 4}
33