1 ; RUN: opt -S -licm -loop-guard-widening -licm -verify-memoryssa -debug-pass=Structure -enable-new-pm=0 < %s 2>&1 | FileCheck %s --check-prefixes=LPM,CHECK
2 ; RUN: opt -S -passes='licm,guard-widening,licm' -verify-memoryssa -debug-pass-manager < %s 2>&1 | FileCheck %s --check-prefixes=NPM,CHECK
4 ; Main point of this test is to check the scheduling -- there should be
5 ; no analysis passes needed between LICM and LoopGuardWidening
7 ; LPM: Loop Pass Manager
8 ; LPM: Loop Invariant Code Motion
9 ; LPM-NEXT: Widen guards (within a single loop, as a loop pass)
10 ; LPM-NEXT: Loop Invariant Code Motion
13 ; NPM-NEXT: GuardWideningPass
16 declare void @llvm.experimental.guard(i1,...)
18 define void @iter(i32 %a, i32 %b, i1* %c_p) {
20 ; CHECK: %cond_0 = icmp ult i32 %a, 10
21 ; CHECK: %cond_1 = icmp ult i32 %b, 10
22 ; CHECK: %wide.chk = and i1 %cond_0, %cond_1
23 ; CHECK: call void (i1, ...) @llvm.experimental.guard(i1 %wide.chk) [ "deopt"() ]
27 %cond_0 = icmp ult i32 %a, 10
28 call void (i1, ...) @llvm.experimental.guard(i1 %cond_0) [ "deopt"() ]
31 loop: ; preds = %loop.preheader, %loop
32 %cond_1 = icmp ult i32 %b, 10
33 call void (i1, ...) @llvm.experimental.guard(i1 %cond_1) [ "deopt"() ]
34 %cnd = load i1, i1* %c_p
35 br i1 %cnd, label %loop, label %leave.loopexit
37 leave.loopexit: ; preds = %loop
40 leave: ; preds = %leave.loopexit, %entry
44 define void @within_loop(i32 %a, i32 %b, i1* %c_p) {
45 ; CHECK-LABEL: @within_loop
46 ; CHECK: %cond_0 = icmp ult i32 %a, 10
47 ; CHECK: %cond_1 = icmp ult i32 %b, 10
48 ; CHECK: %wide.chk = and i1 %cond_0, %cond_1
49 ; CHECK: call void (i1, ...) @llvm.experimental.guard(i1 %wide.chk) [ "deopt"() ]
55 loop: ; preds = %loop.preheader, %loop
56 %cond_0 = icmp ult i32 %a, 10
57 call void (i1, ...) @llvm.experimental.guard(i1 %cond_0) [ "deopt"() ]
58 %cond_1 = icmp ult i32 %b, 10
59 call void (i1, ...) @llvm.experimental.guard(i1 %cond_1) [ "deopt"() ]
60 %cnd = load i1, i1* %c_p
61 br i1 %cnd, label %loop, label %leave.loopexit
63 leave.loopexit: ; preds = %loop
66 leave: ; preds = %leave.loopexit, %entry