1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes='licm,guard-widening,licm' -verify-memoryssa -debug-pass-manager < %s 2>&1 | FileCheck %s
4 ; Main point of this test is to check the scheduling -- there should be
5 ; no analysis passes needed between LICM and LoopGuardWidening
8 ; CHECK-NEXT: GuardWideningPass
11 declare void @llvm.experimental.guard(i1,...)
13 define void @iter(i32 %a, i32 %b, i1* %c_p) {
16 ; CHECK-NEXT: [[COND_0:%.*]] = icmp ult i32 [[A:%.*]], 10
17 ; CHECK-NEXT: [[COND_1:%.*]] = icmp ult i32 [[B:%.*]], 10
18 ; CHECK-NEXT: [[WIDE_CHK:%.*]] = and i1 [[COND_0]], [[COND_1]]
19 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[WIDE_CHK]]) [ "deopt"() ]
20 ; CHECK-NEXT: [[CND:%.*]] = load i1, i1* [[C_P:%.*]], align 1
21 ; CHECK-NEXT: br label [[LOOP:%.*]]
23 ; CHECK-NEXT: br i1 [[CND]], label [[LOOP]], label [[LEAVE_LOOPEXIT:%.*]]
24 ; CHECK: leave.loopexit:
25 ; CHECK-NEXT: br label [[LEAVE:%.*]]
27 ; CHECK-NEXT: ret void
31 %cond_0 = icmp ult i32 %a, 10
32 call void (i1, ...) @llvm.experimental.guard(i1 %cond_0) [ "deopt"() ]
35 loop: ; preds = %loop.preheader, %loop
36 %cond_1 = icmp ult i32 %b, 10
37 call void (i1, ...) @llvm.experimental.guard(i1 %cond_1) [ "deopt"() ]
38 %cnd = load i1, i1* %c_p
39 br i1 %cnd, label %loop, label %leave.loopexit
41 leave.loopexit: ; preds = %loop
44 leave: ; preds = %leave.loopexit, %entry
48 define void @within_loop(i32 %a, i32 %b, i1* %c_p) {
49 ; CHECK-LABEL: @within_loop(
51 ; CHECK-NEXT: [[COND_0:%.*]] = icmp ult i32 [[A:%.*]], 10
52 ; CHECK-NEXT: [[COND_1:%.*]] = icmp ult i32 [[B:%.*]], 10
53 ; CHECK-NEXT: [[WIDE_CHK:%.*]] = and i1 [[COND_0]], [[COND_1]]
54 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[WIDE_CHK]]) [ "deopt"() ]
55 ; CHECK-NEXT: [[CND:%.*]] = load i1, i1* [[C_P:%.*]], align 1
56 ; CHECK-NEXT: br label [[LOOP:%.*]]
58 ; CHECK-NEXT: br i1 [[CND]], label [[LOOP]], label [[LEAVE_LOOPEXIT:%.*]]
59 ; CHECK: leave.loopexit:
60 ; CHECK-NEXT: br label [[LEAVE:%.*]]
62 ; CHECK-NEXT: ret void
68 loop: ; preds = %loop.preheader, %loop
69 %cond_0 = icmp ult i32 %a, 10
70 call void (i1, ...) @llvm.experimental.guard(i1 %cond_0) [ "deopt"() ]
71 %cond_1 = icmp ult i32 %b, 10
72 call void (i1, ...) @llvm.experimental.guard(i1 %cond_1) [ "deopt"() ]
73 %cnd = load i1, i1* %c_p
74 br i1 %cnd, label %loop, label %leave.loopexit
76 leave.loopexit: ; preds = %loop
79 leave: ; preds = %leave.loopexit, %entry