1 ; RUN: opt -S -loop-unswitch < %s | FileCheck %s
2 ; RUN: opt -S -loop-unswitch -enable-mssa-loop-dependency=true -verify-memoryssa < %s | FileCheck %s
4 declare void @llvm.experimental.guard(i1, ...)
6 define void @f_0(i32 %n, i32* %ptr, i1 %c) {
11 ; CHECK: call void (i1, ...) @llvm.experimental.guard(i1 false) [ "deopt"() ]
16 %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ]
17 %iv.inc = add i32 %iv, 1
18 call void(i1, ...) @llvm.experimental.guard(i1 %c) [ "deopt"() ]
19 store volatile i32 0, i32* %ptr
20 %becond = icmp ult i32 %iv.inc, %n
21 br i1 %becond, label %leave, label %loop
27 define void @f_1(i32 %n, i32* %ptr, i1 %c_0, i1 %c_1) {
32 ; CHECK: call void (i1, ...) @llvm.experimental.guard(i1 false) [ "deopt"(i32 2) ]
35 ; CHECK: call void (i1, ...) @llvm.experimental.guard(i1 false) [ "deopt"(i32 1) ]
38 ; CHECK: call void (i1, ...) @llvm.experimental.guard(i1 false) [ "deopt"(i32 1) ]
39 ; CHECK: call void (i1, ...) @llvm.experimental.guard(i1 false) [ "deopt"(i32 2) ]
44 %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ]
45 %iv.inc = add i32 %iv, 1
46 call void(i1, ...) @llvm.experimental.guard(i1 %c_0) [ "deopt"(i32 1) ]
47 store volatile i32 0, i32* %ptr
48 call void(i1, ...) @llvm.experimental.guard(i1 %c_1) [ "deopt"(i32 2) ]
49 %becond = icmp ult i32 %iv.inc, %n
50 br i1 %becond, label %leave, label %loop
58 define void @f_3(i32 %n, i32* %ptr, i1* %c_ptr) {
65 %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ]
66 %iv.inc = add i32 %iv, 1
67 %c = load volatile i1, i1* %c_ptr
68 call void(i1, ...) @llvm.experimental.guard(i1 %c) [ "deopt"() ]
69 store volatile i32 0, i32* %ptr
70 %becond = icmp ult i32 %iv.inc, %n
71 br i1 %becond, label %leave, label %loop
77 define void @f_4(i32 %n, i32* %ptr, i1 %c) {
80 ; Demonstrate that unswitching on one guard can cause another guard to
81 ; be erased (this has implications on what guards we can keep raw
87 %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ]
88 %iv.inc = add i32 %iv, 1
89 call void(i1, ...) @llvm.experimental.guard(i1 %c) [ "deopt"(i32 1) ]
90 store volatile i32 0, i32* %ptr
92 call void(i1, ...) @llvm.experimental.guard(i1 %neg) [ "deopt"(i32 2) ]
93 %becond = icmp ult i32 %iv.inc, %n
94 br i1 %becond, label %leave, label %loop