1 ; RUN: opt -S -licm -loop-guard-widening -licm -debug-pass=Structure < %s 2>&1 | FileCheck %s
3 ; Main point of this test is to check the scheduling -- there should be
4 ; no analysis passes needed between LICM and LoopGuardWidening
6 ; CHECK: Loop Pass Manager
7 ; CHECK: Loop Invariant Code Motion
8 ; CHECK: Widen guards (within a single loop, as a loop pass)
9 ; CHECK: Loop Invariant Code Motion
11 declare void @llvm.experimental.guard(i1,...)
13 define void @iter(i32 %a, i32 %b, i1* %c_p) {
15 ; CHECK: %cond_0 = icmp ult i32 %a, 10
16 ; CHECK: %cond_1 = icmp ult i32 %b, 10
17 ; CHECK: %wide.chk = and i1 %cond_0, %cond_1
18 ; CHECK: call void (i1, ...) @llvm.experimental.guard(i1 %wide.chk) [ "deopt"() ]
22 %cond_0 = icmp ult i32 %a, 10
23 call void (i1, ...) @llvm.experimental.guard(i1 %cond_0) [ "deopt"() ]
26 loop: ; preds = %loop.preheader, %loop
27 %cond_1 = icmp ult i32 %b, 10
28 call void (i1, ...) @llvm.experimental.guard(i1 %cond_1) [ "deopt"() ]
29 %cnd = load i1, i1* %c_p
30 br i1 %cnd, label %loop, label %leave.loopexit
32 leave.loopexit: ; preds = %loop
35 leave: ; preds = %leave.loopexit, %entry
39 define void @within_loop(i32 %a, i32 %b, i1* %c_p) {
40 ; CHECK-LABEL @within_loop
41 ; CHECK: %cond_0 = icmp ult i32 %a, 10
42 ; CHECK: %cond_1 = icmp ult i32 %b, 10
43 ; CHECK: %wide.chk = and i1 %cond_0, %cond_1
44 ; CHECK: call void (i1, ...) @llvm.experimental.guard(i1 %wide.chk) [ "deopt"() ]
50 loop: ; preds = %loop.preheader, %loop
51 %cond_0 = icmp ult i32 %a, 10
52 call void (i1, ...) @llvm.experimental.guard(i1 %cond_0) [ "deopt"() ]
53 %cond_1 = icmp ult i32 %b, 10
54 call void (i1, ...) @llvm.experimental.guard(i1 %cond_1) [ "deopt"() ]
55 %cnd = load i1, i1* %c_p
56 br i1 %cnd, label %loop, label %leave.loopexit
58 leave.loopexit: ; preds = %loop
61 leave: ; preds = %leave.loopexit, %entry