1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature
2 ; RUN: opt -passes=ipsccp < %s -S | FileCheck --check-prefixes=CHECK,ONCE %s
3 ; RUN: opt -passes='ipsccp,ipsccp' < %s -S | FileCheck --check-prefixes=CHECK,TWICE %s
5 define void @barney() {
6 ; CHECK-LABEL: define {{[^@]+}}@barney() {
8 ; CHECK-NEXT: br label [[BB9:%.*]]
10 ; CHECK-NEXT: unreachable
12 ; CHECK-NEXT: br label [[BB6:%.*]]
24 switch i16 0, label %bb6 [
30 ; CHECK-LABEL: define {{[^@]+}}@blam() {
32 ; CHECK-NEXT: br label [[BB16:%.*]]
34 ; CHECK-NEXT: br label [[BB38:%.*]]
36 ; CHECK-NEXT: unreachable
42 switch i32 0, label %bb38 [
63 ; CHECK-LABEL: define {{[^@]+}}@hoge() {
65 ; CHECK-NEXT: br label [[BB2:%.*]]
67 ; CHECK-NEXT: br label [[BB3:%.*]]
69 ; CHECK-NEXT: unreachable
72 switch i16 undef, label %bb1 [
80 bb2: ; preds = %bb, %bb
81 switch i16 0, label %bb3 [
90 bb4: ; preds = %bb2, %bb2, %bb2
94 ; Test case from PR49573. %default.bb is unfeasible. Make sure it gets replaced
95 ; by an unreachable block.
96 define void @pr49573_main() {
97 ; ONCE-LABEL: define {{[^@]+}}@pr49573_main() {
99 ; ONCE-NEXT: [[TGT:%.*]] = call i16 @pr49573_fn()
100 ; ONCE-NEXT: switch i16 2, label [[DEFAULT_UNREACHABLE:%.*]] [
101 ; ONCE-NEXT: i16 0, label [[CASE_0:%.*]]
102 ; ONCE-NEXT: i16 2, label [[CASE_2:%.*]]
105 ; ONCE-NEXT: unreachable
106 ; ONCE: default.unreachable:
107 ; ONCE-NEXT: unreachable
109 ; ONCE-NEXT: br label [[NEXT:%.*]]
111 ; ONCE-NEXT: [[TGT_2:%.*]] = call i16 @pr49573_fn_2()
112 ; ONCE-NEXT: switch i16 2, label [[DEFAULT_UNREACHABLE]] [
113 ; ONCE-NEXT: i16 0, label [[CASE_0]]
114 ; ONCE-NEXT: i16 2, label [[CASE_2]]
117 ; TWICE-LABEL: define {{[^@]+}}@pr49573_main() {
119 ; TWICE-NEXT: [[TGT:%.*]] = call i16 @pr49573_fn()
120 ; TWICE-NEXT: br label [[CASE_2:%.*]]
122 ; TWICE-NEXT: br label [[NEXT:%.*]]
124 ; TWICE-NEXT: [[TGT_2:%.*]] = call i16 @pr49573_fn_2()
125 ; TWICE-NEXT: br label [[CASE_2]]
128 %tgt = call i16 @pr49573_fn()
129 switch i16 %tgt, label %default.bb [
148 %tgt.2 = call i16 @pr49573_fn_2()
149 switch i16 %tgt.2, label %default.bb [
155 ; Make sure a new unreachable BB is created.
156 define void @pr49573_main_2() {
157 ; ONCE-LABEL: define {{[^@]+}}@pr49573_main_2() {
159 ; ONCE-NEXT: [[TGT:%.*]] = call i16 @pr49573_fn()
160 ; ONCE-NEXT: switch i16 2, label [[DEFAULT_UNREACHABLE:%.*]] [
161 ; ONCE-NEXT: i16 0, label [[CASE_0:%.*]]
162 ; ONCE-NEXT: i16 2, label [[CASE_2:%.*]]
165 ; ONCE-NEXT: unreachable
166 ; ONCE: default.unreachable:
167 ; ONCE-NEXT: unreachable
169 ; ONCE-NEXT: ret void
171 ; TWICE-LABEL: define {{[^@]+}}@pr49573_main_2() {
173 ; TWICE-NEXT: [[TGT:%.*]] = call i16 @pr49573_fn()
174 ; TWICE-NEXT: br label [[CASE_2:%.*]]
176 ; TWICE-NEXT: ret void
179 %tgt = call i16 @pr49573_fn()
180 switch i16 %tgt, label %default.bb [
199 define internal i16 @pr49573_fn() {
200 ; CHECK-LABEL: define {{[^@]+}}@pr49573_fn() {
202 ; CHECK-NEXT: br label [[ELSE:%.*]]
204 ; CHECK-NEXT: ret i16 undef
207 br i1 undef, label %then, label %else
216 define internal i16 @pr49573_fn_2() {
217 ; CHECK-LABEL: define {{[^@]+}}@pr49573_fn_2() {
219 ; CHECK-NEXT: br label [[ELSE:%.*]]
221 ; CHECK-NEXT: ret i16 undef
224 br i1 undef, label %then, label %else