1 ; RUN: opt -S -loop-unswitch -enable-new-pm=0 -verify-memoryssa < %s | FileCheck %s
3 declare void @llvm.experimental.guard(i1, ...)
5 define void @f_0(i32 %n, i32* %ptr, i1 %c) {
10 ; CHECK: call void (i1, ...) @llvm.experimental.guard(i1 false) [ "deopt"() ]
15 %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ]
16 %iv.inc = add i32 %iv, 1
17 call void(i1, ...) @llvm.experimental.guard(i1 %c) [ "deopt"() ]
18 store volatile i32 0, i32* %ptr
19 %becond = icmp ult i32 %iv.inc, %n
20 br i1 %becond, label %leave, label %loop
26 define void @f_1(i32 %n, i32* %ptr, i1 %c_0, i1 %c_1) {
31 ; CHECK: call void (i1, ...) @llvm.experimental.guard(i1 false) [ "deopt"(i32 2) ]
34 ; CHECK: call void (i1, ...) @llvm.experimental.guard(i1 false) [ "deopt"(i32 1) ]
37 ; CHECK: call void (i1, ...) @llvm.experimental.guard(i1 false) [ "deopt"(i32 1) ]
38 ; CHECK: call void (i1, ...) @llvm.experimental.guard(i1 false) [ "deopt"(i32 2) ]
43 %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ]
44 %iv.inc = add i32 %iv, 1
45 call void(i1, ...) @llvm.experimental.guard(i1 %c_0) [ "deopt"(i32 1) ]
46 store volatile i32 0, i32* %ptr
47 call void(i1, ...) @llvm.experimental.guard(i1 %c_1) [ "deopt"(i32 2) ]
48 %becond = icmp ult i32 %iv.inc, %n
49 br i1 %becond, label %leave, label %loop
57 define void @f_3(i32 %n, i32* %ptr, i1* %c_ptr) {
64 %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ]
65 %iv.inc = add i32 %iv, 1
66 %c = load volatile i1, i1* %c_ptr
67 call void(i1, ...) @llvm.experimental.guard(i1 %c) [ "deopt"() ]
68 store volatile i32 0, i32* %ptr
69 %becond = icmp ult i32 %iv.inc, %n
70 br i1 %becond, label %leave, label %loop
76 define void @f_4(i32 %n, i32* %ptr, i1 %c) {
79 ; Demonstrate that unswitching on one guard can cause another guard to
80 ; be erased (this has implications on what guards we can keep raw
86 %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ]
87 %iv.inc = add i32 %iv, 1
88 call void(i1, ...) @llvm.experimental.guard(i1 %c) [ "deopt"(i32 1) ]
89 store volatile i32 0, i32* %ptr
91 call void(i1, ...) @llvm.experimental.guard(i1 %neg) [ "deopt"(i32 2) ]
92 %becond = icmp ult i32 %iv.inc, %n
93 br i1 %becond, label %leave, label %loop