1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -simplifycfg < %s | FileCheck %s
4 declare void @llvm.experimental.guard(i1, ...)
6 define i32 @f_0(i1 %c) {
9 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 false) [ "deopt"() ]
10 ; CHECK-NEXT: unreachable
13 call void(i1, ...) @llvm.experimental.guard(i1 false) [ "deopt"() ]
17 define i32 @f_1(i1 %c) {
18 ; Demonstrate that we (intentionally) do not simplify a guard on undef
21 ; CHECK-NEXT: br i1 [[C:%.*]], label [[TRUE:%.*]], label [[FALSE:%.*]]
23 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 undef) [ "deopt"() ]
24 ; CHECK-NEXT: ret i32 10
26 ; CHECK-NEXT: ret i32 20
30 br i1 %c, label %true, label %false
33 call void(i1, ...) @llvm.experimental.guard(i1 undef) [ "deopt"() ]
40 define i32 @f_2(i1 %c, i32* %buf) {
43 ; CHECK-NEXT: br i1 [[C:%.*]], label [[GUARD_BLOCK:%.*]], label [[MERGE_BLOCK:%.*]]
45 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 false) [ "deopt"() ]
46 ; CHECK-NEXT: unreachable
48 ; CHECK-NEXT: ret i32 50
51 br i1 %c, label %guard_block, label %merge_block
54 call void(i1, ...) @llvm.experimental.guard(i1 false) [ "deopt"() ]
55 %val = load i32, i32* %buf
59 %to.return = phi i32 [ %val, %guard_block ], [ 50, %entry ]
64 define i32 @f_3(i1* %c, i32* %buf) {
67 ; CHECK-NEXT: [[C0:%.*]] = load volatile i1, i1* [[C:%.*]]
68 ; CHECK-NEXT: br i1 [[C0]], label [[GUARD_BLOCK:%.*]], label [[MERGE_BLOCK:%.*]]
70 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 false) [ "deopt"() ]
71 ; CHECK-NEXT: unreachable
73 ; CHECK-NEXT: [[C1:%.*]] = load volatile i1, i1* [[C]]
74 ; CHECK-NEXT: [[DOT:%.*]] = select i1 [[C1]], i32 50, i32 100
75 ; CHECK-NEXT: ret i32 [[DOT]]
78 %c0 = load volatile i1, i1* %c
79 br i1 %c0, label %guard_block, label %merge_block
82 call void(i1, ...) @llvm.experimental.guard(i1 false) [ "deopt"() ]
83 %val = load i32, i32* %buf
84 %c2 = load volatile i1, i1* %c
85 br i1 %c2, label %left, label %right
88 %c1 = load volatile i1, i1* %c
89 br i1 %c1, label %left, label %right
92 %val.left = phi i32 [ %val, %guard_block ], [ 50, %merge_block ]
96 %val.right = phi i32 [ %val, %guard_block ], [ 100, %merge_block ]