1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -sroa -S | FileCheck %s
3 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-n8:16:32:64"
5 @a = external global i16, align 1
7 declare void @maybe_writes()
12 ; CHECK-NEXT: br i1 undef, label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
14 ; CHECK-NEXT: br label [[CLEANUP:%.*]]
16 ; CHECK-NEXT: [[G_0_SROA_SPECULATE_LOAD_CLEANUP:%.*]] = load i16, i16* @a, align 1
17 ; CHECK-NEXT: switch i32 2, label [[CLEANUP7:%.*]] [
18 ; CHECK-NEXT: i32 0, label [[LBL1:%.*]]
19 ; CHECK-NEXT: i32 2, label [[LBL1]]
22 ; CHECK-NEXT: br label [[LBL1]]
24 ; CHECK-NEXT: [[G_0_SROA_SPECULATED:%.*]] = phi i16 [ [[G_0_SROA_SPECULATE_LOAD_CLEANUP]], [[CLEANUP]] ], [ [[G_0_SROA_SPECULATE_LOAD_CLEANUP]], [[CLEANUP]] ], [ undef, [[IF_ELSE]] ]
25 ; CHECK-NEXT: unreachable
27 ; CHECK-NEXT: ret void
30 %e = alloca i16, align 1
31 br i1 undef, label %if.then, label %if.else
33 if.then: ; preds = %entry
36 cleanup: ; preds = %if.then
37 switch i32 2, label %cleanup7 [
42 if.else: ; preds = %entry
45 lbl1: ; preds = %if.else, %cleanup, %cleanup
46 %g.0 = phi i16* [ @a, %cleanup ], [ @a, %cleanup ], [ %e, %if.else ]
47 %0 = load i16, i16* %g.0, align 1
50 cleanup7: ; preds = %cleanup
57 ; CHECK-NEXT: [[E:%.*]] = alloca i16, align 1
58 ; CHECK-NEXT: br i1 undef, label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
60 ; CHECK-NEXT: br label [[CLEANUP:%.*]]
62 ; CHECK-NEXT: switch i32 2, label [[CLEANUP7:%.*]] [
63 ; CHECK-NEXT: i32 0, label [[LBL1:%.*]]
64 ; CHECK-NEXT: i32 2, label [[LBL1]]
67 ; CHECK-NEXT: br label [[LBL1]]
69 ; CHECK-NEXT: [[G_0:%.*]] = phi i16* [ @a, [[CLEANUP]] ], [ @a, [[CLEANUP]] ], [ [[E]], [[IF_ELSE]] ]
70 ; CHECK-NEXT: br label [[FINAL:%.*]]
72 ; CHECK-NEXT: [[TMP0:%.*]] = load i16, i16* [[G_0]], align 1
73 ; CHECK-NEXT: unreachable
75 ; CHECK-NEXT: ret void
78 %e = alloca i16, align 1
79 br i1 undef, label %if.then, label %if.else
81 if.then: ; preds = %entry
84 cleanup: ; preds = %if.then
85 switch i32 2, label %cleanup7 [
90 if.else: ; preds = %entry
93 lbl1: ; preds = %if.else, %cleanup, %cleanup
94 %g.0 = phi i16* [ @a, %cleanup ], [ @a, %cleanup ], [ %e, %if.else ]
98 %0 = load i16, i16* %g.0, align 1
101 cleanup7: ; preds = %cleanup
108 ; CHECK-NEXT: [[E:%.*]] = alloca i16, align 1
109 ; CHECK-NEXT: br i1 undef, label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
111 ; CHECK-NEXT: br label [[CLEANUP:%.*]]
113 ; CHECK-NEXT: switch i32 2, label [[CLEANUP7:%.*]] [
114 ; CHECK-NEXT: i32 0, label [[LBL1:%.*]]
115 ; CHECK-NEXT: i32 2, label [[LBL1]]
118 ; CHECK-NEXT: br label [[LBL1]]
120 ; CHECK-NEXT: [[G_0:%.*]] = phi i16* [ @a, [[CLEANUP]] ], [ @a, [[CLEANUP]] ], [ [[E]], [[IF_ELSE]] ]
121 ; CHECK-NEXT: br label [[FINAL:%.*]]
123 ; CHECK-NEXT: call void @maybe_writes()
124 ; CHECK-NEXT: [[TMP0:%.*]] = load i16, i16* [[G_0]], align 1
125 ; CHECK-NEXT: unreachable
127 ; CHECK-NEXT: ret void
130 %e = alloca i16, align 1
131 br i1 undef, label %if.then, label %if.else
133 if.then: ; preds = %entry
136 cleanup: ; preds = %if.then
137 switch i32 2, label %cleanup7 [
142 if.else: ; preds = %entry
145 lbl1: ; preds = %if.else, %cleanup, %cleanup
146 %g.0 = phi i16* [ @a, %cleanup ], [ @a, %cleanup ], [ %e, %if.else ]
150 call void @maybe_writes()
151 %0 = load i16, i16* %g.0, align 1
154 cleanup7: ; preds = %cleanup
161 ; CHECK-NEXT: [[E:%.*]] = alloca i16, align 1
162 ; CHECK-NEXT: br i1 undef, label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
164 ; CHECK-NEXT: br label [[CLEANUP:%.*]]
166 ; CHECK-NEXT: switch i32 2, label [[CLEANUP7:%.*]] [
167 ; CHECK-NEXT: i32 0, label [[LBL1:%.*]]
168 ; CHECK-NEXT: i32 2, label [[LBL1]]
171 ; CHECK-NEXT: br label [[LBL1]]
173 ; CHECK-NEXT: [[G_0:%.*]] = phi i16* [ @a, [[CLEANUP]] ], [ @a, [[CLEANUP]] ], [ [[E]], [[IF_ELSE]] ]
174 ; CHECK-NEXT: br i1 undef, label [[FINAL:%.*]], label [[CLEANUP7]]
176 ; CHECK-NEXT: [[TMP0:%.*]] = load i16, i16* [[G_0]], align 1
177 ; CHECK-NEXT: unreachable
179 ; CHECK-NEXT: ret void
182 %e = alloca i16, align 1
183 br i1 undef, label %if.then, label %if.else
185 if.then: ; preds = %entry
188 cleanup: ; preds = %if.then
189 switch i32 2, label %cleanup7 [
194 if.else: ; preds = %entry
197 lbl1: ; preds = %if.else, %cleanup, %cleanup
198 %g.0 = phi i16* [ @a, %cleanup ], [ @a, %cleanup ], [ %e, %if.else ]
199 br i1 undef, label %final, label %cleanup7
202 %0 = load i16, i16* %g.0, align 1
205 cleanup7: ; preds = %cleanup
212 ; CHECK-NEXT: [[E:%.*]] = alloca i16, align 1
213 ; CHECK-NEXT: br i1 undef, label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
215 ; CHECK-NEXT: br label [[CLEANUP:%.*]]
217 ; CHECK-NEXT: switch i32 2, label [[CLEANUP7:%.*]] [
218 ; CHECK-NEXT: i32 0, label [[LBL1:%.*]]
219 ; CHECK-NEXT: i32 2, label [[LBL1]]
222 ; CHECK-NEXT: br label [[LBL1]]
224 ; CHECK-NEXT: [[G_0:%.*]] = phi i16* [ @a, [[CLEANUP]] ], [ @a, [[CLEANUP]] ], [ [[E]], [[IF_ELSE]] ]
225 ; CHECK-NEXT: br label [[FINAL:%.*]]
226 ; CHECK: unreachable_pred:
227 ; CHECK-NEXT: br label [[FINAL]]
229 ; CHECK-NEXT: call void @maybe_writes()
230 ; CHECK-NEXT: [[TMP0:%.*]] = load i16, i16* [[G_0]], align 1
231 ; CHECK-NEXT: unreachable
233 ; CHECK-NEXT: ret void
236 %e = alloca i16, align 1
237 br i1 undef, label %if.then, label %if.else
239 if.then: ; preds = %entry
242 cleanup: ; preds = %if.then
243 switch i32 2, label %cleanup7 [
248 if.else: ; preds = %entry
251 lbl1: ; preds = %if.else, %cleanup, %cleanup
252 %g.0 = phi i16* [ @a, %cleanup ], [ @a, %cleanup ], [ %e, %if.else ]
259 call void @maybe_writes()
260 %0 = load i16, i16* %g.0, align 1
263 cleanup7: ; preds = %cleanup