1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -dse -S %s | FileCheck %s
4 target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
6 ; Make sure we do not crash when we encounter unreachable blocks while checking
7 ; if all paths to DomAccess go through a killing block.
8 define void @test(float* %ptr, i1 %c.1, i1 %c.2, i1 %c.3) {
11 ; CHECK-NEXT: br i1 [[C_1:%.*]], label [[BB27:%.*]], label [[BB53:%.*]]
13 ; CHECK-NEXT: br label [[BB43:%.*]]
15 ; CHECK-NEXT: br i1 [[C_2:%.*]], label [[BB22:%.*]], label [[BB53]]
17 ; CHECK-NEXT: br i1 [[C_3:%.*]], label [[BB38:%.*]], label [[BB39:%.*]]
19 ; CHECK-NEXT: store float 0.000000e+00, float* [[PTR:%.*]], align 4
20 ; CHECK-NEXT: br label [[BB38]]
22 ; CHECK-NEXT: br i1 [[C_2]], label [[BB43]], label [[BB38]]
24 ; CHECK-NEXT: store float 0.000000e+00, float* [[PTR]], align 4
25 ; CHECK-NEXT: br label [[BB50:%.*]]
27 ; CHECK-NEXT: br i1 [[C_3]], label [[BB27]], label [[BB53]]
29 ; CHECK-NEXT: br label [[BB53]]
32 br i1 %c.1, label %bb27, label %bb53
34 bb10: ; No predecessors!
38 br i1 %c.2, label %bb22, label %bb53
40 bb27: ; preds = %bb50, %bb
41 br i1 %c.3, label %bb38, label %bb39
43 bb38: ; preds = %bb39, %bb38, %bb27
44 store float 0.000000e+00, float* %ptr, align 4
48 br i1 %c.2, label %bb43, label %bb38
50 bb43: ; preds = %bb39, %bb10
51 store float 0.000000e+00, float* %ptr, align 4
55 br i1 %c.3, label %bb27, label %bb53
57 bb53: ; preds = %bb53, %bb50, %bb22, %bb
63 define void @unreachable_exit_with_no_call(i64* noalias %ptr, i1 %c.1) {
64 ; CHECK-LABEL: @unreachable_exit_with_no_call(
66 ; CHECK-NEXT: br i1 [[C_1:%.*]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
68 ; CHECK-NEXT: unreachable
70 ; CHECK-NEXT: store i64 0, i64* [[PTR:%.*]], align 8
71 ; CHECK-NEXT: ret void
74 store i64 1, i64* %ptr, align 8
75 br i1 %c.1, label %if.then, label %if.end
81 store i64 0, i64* %ptr, align 8
86 define void @unreachable_exit_with_nounwind_call_pr53800(i64* noalias %ptr, i1 %c.1) {
87 ; CHECK-LABEL: @unreachable_exit_with_nounwind_call_pr53800(
89 ; CHECK-NEXT: br i1 [[C_1:%.*]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
91 ; CHECK-NEXT: tail call void @exit() #[[ATTR0:[0-9]+]]
92 ; CHECK-NEXT: unreachable
94 ; CHECK-NEXT: store i64 0, i64* [[PTR:%.*]], align 8
95 ; CHECK-NEXT: ret void
98 store i64 1, i64* %ptr, align 8
99 br i1 %c.1, label %if.then, label %if.end
102 tail call void @exit() nounwind
106 store i64 0, i64* %ptr, align 8
110 ; The call @exit may read %ptr as it is not marked as noalias
111 define void @unreachable_exit_and_call_may_read(i64* %ptr, i1 %c.1) {
112 ; CHECK-LABEL: @unreachable_exit_and_call_may_read(
114 ; CHECK-NEXT: store i64 1, i64* [[PTR:%.*]], align 8
115 ; CHECK-NEXT: br i1 [[C_1:%.*]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
117 ; CHECK-NEXT: tail call void @exit() #[[ATTR0]]
118 ; CHECK-NEXT: unreachable
120 ; CHECK-NEXT: store i64 0, i64* [[PTR]], align 8
121 ; CHECK-NEXT: ret void
124 store i64 1, i64* %ptr, align 8
125 br i1 %c.1, label %if.then, label %if.end
128 tail call void @exit() nounwind
132 store i64 0, i64* %ptr, align 8
136 define void @unreachable_exit_with_may_unwind_call(i64* noalias %ptr, i1 %c.1) {
137 ; CHECK-LABEL: @unreachable_exit_with_may_unwind_call(
139 ; CHECK-NEXT: store i64 1, i64* [[PTR:%.*]], align 8
140 ; CHECK-NEXT: br i1 [[C_1:%.*]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
142 ; CHECK-NEXT: tail call void @exit()
143 ; CHECK-NEXT: unreachable
145 ; CHECK-NEXT: store i64 0, i64* [[PTR]], align 8
146 ; CHECK-NEXT: ret void
149 store i64 1, i64* %ptr, align 8
150 br i1 %c.1, label %if.then, label %if.end
153 tail call void @exit()
157 store i64 0, i64* %ptr, align 8
161 ; Cannot remove the store in entry, because it is not dead on the path to e.1
162 define void @unreachable_exit_but_another_exit(i64* noalias %ptr, i1 %c.1, i32 %s, i1 %c.2) {
163 ; CHECK-LABEL: @unreachable_exit_but_another_exit(
165 ; CHECK-NEXT: store i64 1, i64* [[PTR:%.*]], align 8
166 ; CHECK-NEXT: br i1 [[C_1:%.*]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
168 ; CHECK-NEXT: br i1 [[C_2:%.*]], label [[E_0:%.*]], label [[E_1:%.*]]
170 ; CHECK-NEXT: tail call void @exit() #[[ATTR0]]
171 ; CHECK-NEXT: unreachable
173 ; CHECK-NEXT: ret void
175 ; CHECK-NEXT: store i64 0, i64* [[PTR]], align 8
176 ; CHECK-NEXT: ret void
179 store i64 1, i64* %ptr, align 8
180 br i1 %c.1, label %if.then, label %if.end
183 br i1 %c.2, label %e.0, label %e.1
186 tail call void @exit() nounwind
193 store i64 0, i64* %ptr, align 8