1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -x86-speculative-load-hardening -data-sections | FileCheck %s --check-prefix=X64
3 ; FIXME: Fix machine verifier issues and remove -verify-machineinstrs=0. PR39451.
4 ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -x86-speculative-load-hardening -relocation-model pic -data-sections -verify-machineinstrs=0 | FileCheck %s --check-prefix=X64-PIC
5 ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -x86-speculative-load-hardening -data-sections -mattr=+retpoline | FileCheck %s --check-prefix=X64-RETPOLINE
7 ; FIXME: Add support for 32-bit.
9 @global_fnptr = external global i32 ()*
11 @global_blockaddrs = constant [4 x i8*] [
12 i8* blockaddress(@test_indirectbr_global, %bb0),
13 i8* blockaddress(@test_indirectbr_global, %bb1),
14 i8* blockaddress(@test_indirectbr_global, %bb2),
15 i8* blockaddress(@test_indirectbr_global, %bb3)
18 define i32 @test_indirect_call(i32 ()** %ptr) nounwind {
19 ; X64-LABEL: test_indirect_call:
20 ; X64: # %bb.0: # %entry
21 ; X64-NEXT: pushq %rbx
22 ; X64-NEXT: movq %rsp, %rax
23 ; X64-NEXT: movq $-1, %rbx
24 ; X64-NEXT: sarq $63, %rax
25 ; X64-NEXT: movq (%rdi), %rcx
26 ; X64-NEXT: orq %rax, %rcx
27 ; X64-NEXT: shlq $47, %rax
28 ; X64-NEXT: orq %rax, %rsp
29 ; X64-NEXT: callq *%rcx
30 ; X64-NEXT: .Lslh_ret_addr0:
31 ; X64-NEXT: movq %rsp, %rcx
32 ; X64-NEXT: movq -{{[0-9]+}}(%rsp), %rdx
33 ; X64-NEXT: sarq $63, %rcx
34 ; X64-NEXT: cmpq $.Lslh_ret_addr0, %rdx
35 ; X64-NEXT: cmovneq %rbx, %rcx
36 ; X64-NEXT: shlq $47, %rcx
37 ; X64-NEXT: orq %rcx, %rsp
41 ; X64-PIC-LABEL: test_indirect_call:
42 ; X64-PIC: # %bb.0: # %entry
43 ; X64-PIC-NEXT: pushq %rbx
44 ; X64-PIC-NEXT: movq %rsp, %rax
45 ; X64-PIC-NEXT: movq $-1, %rbx
46 ; X64-PIC-NEXT: sarq $63, %rax
47 ; X64-PIC-NEXT: movq (%rdi), %rcx
48 ; X64-PIC-NEXT: orq %rax, %rcx
49 ; X64-PIC-NEXT: shlq $47, %rax
50 ; X64-PIC-NEXT: orq %rax, %rsp
51 ; X64-PIC-NEXT: callq *%rcx
52 ; X64-PIC-NEXT: .Lslh_ret_addr0:
53 ; X64-PIC-NEXT: movq %rsp, %rcx
54 ; X64-PIC-NEXT: movq -{{[0-9]+}}(%rsp), %rdx
55 ; X64-PIC-NEXT: sarq $63, %rcx
56 ; X64-PIC-NEXT: leaq {{.*}}(%rip), %rsi
57 ; X64-PIC-NEXT: cmpq %rsi, %rdx
58 ; X64-PIC-NEXT: cmovneq %rbx, %rcx
59 ; X64-PIC-NEXT: shlq $47, %rcx
60 ; X64-PIC-NEXT: orq %rcx, %rsp
61 ; X64-PIC-NEXT: popq %rbx
64 ; X64-RETPOLINE-LABEL: test_indirect_call:
65 ; X64-RETPOLINE: # %bb.0: # %entry
66 ; X64-RETPOLINE-NEXT: pushq %rbx
67 ; X64-RETPOLINE-NEXT: movq %rsp, %rax
68 ; X64-RETPOLINE-NEXT: movq $-1, %rbx
69 ; X64-RETPOLINE-NEXT: sarq $63, %rax
70 ; X64-RETPOLINE-NEXT: movq (%rdi), %r11
71 ; X64-RETPOLINE-NEXT: orq %rax, %r11
72 ; X64-RETPOLINE-NEXT: shlq $47, %rax
73 ; X64-RETPOLINE-NEXT: orq %rax, %rsp
74 ; X64-RETPOLINE-NEXT: callq __llvm_retpoline_r11
75 ; X64-RETPOLINE-NEXT: .Lslh_ret_addr0:
76 ; X64-RETPOLINE-NEXT: movq %rsp, %rcx
77 ; X64-RETPOLINE-NEXT: movq -{{[0-9]+}}(%rsp), %rdx
78 ; X64-RETPOLINE-NEXT: sarq $63, %rcx
79 ; X64-RETPOLINE-NEXT: cmpq $.Lslh_ret_addr0, %rdx
80 ; X64-RETPOLINE-NEXT: cmovneq %rbx, %rcx
81 ; X64-RETPOLINE-NEXT: shlq $47, %rcx
82 ; X64-RETPOLINE-NEXT: orq %rcx, %rsp
83 ; X64-RETPOLINE-NEXT: popq %rbx
84 ; X64-RETPOLINE-NEXT: retq
86 %fp = load i32 ()*, i32 ()** %ptr
91 define i32 @test_indirect_tail_call(i32 ()** %ptr) nounwind {
92 ; X64-LABEL: test_indirect_tail_call:
93 ; X64: # %bb.0: # %entry
94 ; X64-NEXT: movq %rsp, %rax
95 ; X64-NEXT: movq $-1, %rcx
96 ; X64-NEXT: sarq $63, %rax
97 ; X64-NEXT: movq (%rdi), %rcx
98 ; X64-NEXT: orq %rax, %rcx
99 ; X64-NEXT: shlq $47, %rax
100 ; X64-NEXT: orq %rax, %rsp
101 ; X64-NEXT: jmpq *%rcx # TAILCALL
103 ; X64-PIC-LABEL: test_indirect_tail_call:
104 ; X64-PIC: # %bb.0: # %entry
105 ; X64-PIC-NEXT: movq %rsp, %rax
106 ; X64-PIC-NEXT: movq $-1, %rcx
107 ; X64-PIC-NEXT: sarq $63, %rax
108 ; X64-PIC-NEXT: movq (%rdi), %rcx
109 ; X64-PIC-NEXT: orq %rax, %rcx
110 ; X64-PIC-NEXT: shlq $47, %rax
111 ; X64-PIC-NEXT: orq %rax, %rsp
112 ; X64-PIC-NEXT: jmpq *%rcx # TAILCALL
114 ; X64-RETPOLINE-LABEL: test_indirect_tail_call:
115 ; X64-RETPOLINE: # %bb.0: # %entry
116 ; X64-RETPOLINE-NEXT: movq %rsp, %rax
117 ; X64-RETPOLINE-NEXT: movq $-1, %rcx
118 ; X64-RETPOLINE-NEXT: sarq $63, %rax
119 ; X64-RETPOLINE-NEXT: movq (%rdi), %r11
120 ; X64-RETPOLINE-NEXT: orq %rax, %r11
121 ; X64-RETPOLINE-NEXT: shlq $47, %rax
122 ; X64-RETPOLINE-NEXT: orq %rax, %rsp
123 ; X64-RETPOLINE-NEXT: jmp __llvm_retpoline_r11 # TAILCALL
125 %fp = load i32 ()*, i32 ()** %ptr
126 %v = tail call i32 %fp()
130 define i32 @test_indirect_call_global() nounwind {
131 ; X64-LABEL: test_indirect_call_global:
132 ; X64: # %bb.0: # %entry
133 ; X64-NEXT: pushq %rbx
134 ; X64-NEXT: movq %rsp, %rax
135 ; X64-NEXT: movq $-1, %rbx
136 ; X64-NEXT: sarq $63, %rax
137 ; X64-NEXT: movq {{.*}}(%rip), %rcx
138 ; X64-NEXT: orq %rax, %rcx
139 ; X64-NEXT: shlq $47, %rax
140 ; X64-NEXT: orq %rax, %rsp
141 ; X64-NEXT: callq *%rcx
142 ; X64-NEXT: .Lslh_ret_addr1:
143 ; X64-NEXT: movq %rsp, %rcx
144 ; X64-NEXT: movq -{{[0-9]+}}(%rsp), %rdx
145 ; X64-NEXT: sarq $63, %rcx
146 ; X64-NEXT: cmpq $.Lslh_ret_addr1, %rdx
147 ; X64-NEXT: cmovneq %rbx, %rcx
148 ; X64-NEXT: shlq $47, %rcx
149 ; X64-NEXT: orq %rcx, %rsp
150 ; X64-NEXT: popq %rbx
153 ; X64-PIC-LABEL: test_indirect_call_global:
154 ; X64-PIC: # %bb.0: # %entry
155 ; X64-PIC-NEXT: pushq %rbx
156 ; X64-PIC-NEXT: movq %rsp, %rax
157 ; X64-PIC-NEXT: movq $-1, %rbx
158 ; X64-PIC-NEXT: sarq $63, %rax
159 ; X64-PIC-NEXT: movq global_fnptr@{{.*}}(%rip), %rcx
160 ; X64-PIC-NEXT: movq (%rcx), %rcx
161 ; X64-PIC-NEXT: orq %rax, %rcx
162 ; X64-PIC-NEXT: shlq $47, %rax
163 ; X64-PIC-NEXT: orq %rax, %rsp
164 ; X64-PIC-NEXT: callq *%rcx
165 ; X64-PIC-NEXT: .Lslh_ret_addr1:
166 ; X64-PIC-NEXT: movq %rsp, %rcx
167 ; X64-PIC-NEXT: movq -{{[0-9]+}}(%rsp), %rdx
168 ; X64-PIC-NEXT: sarq $63, %rcx
169 ; X64-PIC-NEXT: leaq {{.*}}(%rip), %rsi
170 ; X64-PIC-NEXT: cmpq %rsi, %rdx
171 ; X64-PIC-NEXT: cmovneq %rbx, %rcx
172 ; X64-PIC-NEXT: shlq $47, %rcx
173 ; X64-PIC-NEXT: orq %rcx, %rsp
174 ; X64-PIC-NEXT: popq %rbx
177 ; X64-RETPOLINE-LABEL: test_indirect_call_global:
178 ; X64-RETPOLINE: # %bb.0: # %entry
179 ; X64-RETPOLINE-NEXT: pushq %rbx
180 ; X64-RETPOLINE-NEXT: movq %rsp, %rax
181 ; X64-RETPOLINE-NEXT: movq $-1, %rbx
182 ; X64-RETPOLINE-NEXT: sarq $63, %rax
183 ; X64-RETPOLINE-NEXT: movq {{.*}}(%rip), %r11
184 ; X64-RETPOLINE-NEXT: shlq $47, %rax
185 ; X64-RETPOLINE-NEXT: orq %rax, %rsp
186 ; X64-RETPOLINE-NEXT: callq __llvm_retpoline_r11
187 ; X64-RETPOLINE-NEXT: .Lslh_ret_addr1:
188 ; X64-RETPOLINE-NEXT: movq %rsp, %rcx
189 ; X64-RETPOLINE-NEXT: movq -{{[0-9]+}}(%rsp), %rdx
190 ; X64-RETPOLINE-NEXT: sarq $63, %rcx
191 ; X64-RETPOLINE-NEXT: cmpq $.Lslh_ret_addr1, %rdx
192 ; X64-RETPOLINE-NEXT: cmovneq %rbx, %rcx
193 ; X64-RETPOLINE-NEXT: shlq $47, %rcx
194 ; X64-RETPOLINE-NEXT: orq %rcx, %rsp
195 ; X64-RETPOLINE-NEXT: popq %rbx
196 ; X64-RETPOLINE-NEXT: retq
198 %fp = load i32 ()*, i32 ()** @global_fnptr
203 define i32 @test_indirect_tail_call_global() nounwind {
204 ; X64-LABEL: test_indirect_tail_call_global:
205 ; X64: # %bb.0: # %entry
206 ; X64-NEXT: movq %rsp, %rax
207 ; X64-NEXT: movq $-1, %rcx
208 ; X64-NEXT: sarq $63, %rax
209 ; X64-NEXT: movq {{.*}}(%rip), %rcx
210 ; X64-NEXT: orq %rax, %rcx
211 ; X64-NEXT: shlq $47, %rax
212 ; X64-NEXT: orq %rax, %rsp
213 ; X64-NEXT: jmpq *%rcx # TAILCALL
215 ; X64-PIC-LABEL: test_indirect_tail_call_global:
216 ; X64-PIC: # %bb.0: # %entry
217 ; X64-PIC-NEXT: movq %rsp, %rax
218 ; X64-PIC-NEXT: movq $-1, %rcx
219 ; X64-PIC-NEXT: sarq $63, %rax
220 ; X64-PIC-NEXT: movq global_fnptr@{{.*}}(%rip), %rcx
221 ; X64-PIC-NEXT: movq (%rcx), %rcx
222 ; X64-PIC-NEXT: orq %rax, %rcx
223 ; X64-PIC-NEXT: shlq $47, %rax
224 ; X64-PIC-NEXT: orq %rax, %rsp
225 ; X64-PIC-NEXT: jmpq *%rcx # TAILCALL
227 ; X64-RETPOLINE-LABEL: test_indirect_tail_call_global:
228 ; X64-RETPOLINE: # %bb.0: # %entry
229 ; X64-RETPOLINE-NEXT: movq %rsp, %rax
230 ; X64-RETPOLINE-NEXT: movq $-1, %rcx
231 ; X64-RETPOLINE-NEXT: sarq $63, %rax
232 ; X64-RETPOLINE-NEXT: movq {{.*}}(%rip), %r11
233 ; X64-RETPOLINE-NEXT: shlq $47, %rax
234 ; X64-RETPOLINE-NEXT: orq %rax, %rsp
235 ; X64-RETPOLINE-NEXT: jmp __llvm_retpoline_r11 # TAILCALL
237 %fp = load i32 ()*, i32 ()** @global_fnptr
238 %v = tail call i32 %fp()
242 define i32 @test_indirectbr(i8** %ptr) nounwind {
243 ; X64-LABEL: test_indirectbr:
244 ; X64: # %bb.0: # %entry
245 ; X64-NEXT: movq %rsp, %rcx
246 ; X64-NEXT: movq $-1, %rax
247 ; X64-NEXT: sarq $63, %rcx
248 ; X64-NEXT: movq (%rdi), %rdx
249 ; X64-NEXT: orq %rcx, %rdx
250 ; X64-NEXT: jmpq *%rdx
251 ; X64-NEXT: .LBB4_1: # Block address taken
253 ; X64-NEXT: cmpq $.LBB4_1, %rdx
254 ; X64-NEXT: cmovneq %rax, %rcx
255 ; X64-NEXT: shlq $47, %rcx
256 ; X64-NEXT: movl $2, %eax
257 ; X64-NEXT: orq %rcx, %rsp
259 ; X64-NEXT: .LBB4_3: # Block address taken
261 ; X64-NEXT: cmpq $.LBB4_3, %rdx
262 ; X64-NEXT: cmovneq %rax, %rcx
263 ; X64-NEXT: shlq $47, %rcx
264 ; X64-NEXT: movl $13, %eax
265 ; X64-NEXT: orq %rcx, %rsp
267 ; X64-NEXT: .LBB4_4: # Block address taken
269 ; X64-NEXT: cmpq $.LBB4_4, %rdx
270 ; X64-NEXT: cmovneq %rax, %rcx
271 ; X64-NEXT: shlq $47, %rcx
272 ; X64-NEXT: movl $42, %eax
273 ; X64-NEXT: orq %rcx, %rsp
275 ; X64-NEXT: .LBB4_2: # Block address taken
277 ; X64-NEXT: cmpq $.LBB4_2, %rdx
278 ; X64-NEXT: cmovneq %rax, %rcx
279 ; X64-NEXT: shlq $47, %rcx
280 ; X64-NEXT: movl $7, %eax
281 ; X64-NEXT: orq %rcx, %rsp
284 ; X64-PIC-LABEL: test_indirectbr:
285 ; X64-PIC: # %bb.0: # %entry
286 ; X64-PIC-NEXT: movq %rsp, %rcx
287 ; X64-PIC-NEXT: movq $-1, %rax
288 ; X64-PIC-NEXT: sarq $63, %rcx
289 ; X64-PIC-NEXT: movq (%rdi), %rdx
290 ; X64-PIC-NEXT: orq %rcx, %rdx
291 ; X64-PIC-NEXT: jmpq *%rdx
292 ; X64-PIC-NEXT: .LBB4_1: # Block address taken
293 ; X64-PIC-NEXT: # %bb0
294 ; X64-PIC-NEXT: leaq {{.*}}(%rip), %rsi
295 ; X64-PIC-NEXT: cmpq %rsi, %rdx
296 ; X64-PIC-NEXT: cmovneq %rax, %rcx
297 ; X64-PIC-NEXT: shlq $47, %rcx
298 ; X64-PIC-NEXT: movl $2, %eax
299 ; X64-PIC-NEXT: orq %rcx, %rsp
301 ; X64-PIC-NEXT: .LBB4_3: # Block address taken
302 ; X64-PIC-NEXT: # %bb2
303 ; X64-PIC-NEXT: leaq {{.*}}(%rip), %rsi
304 ; X64-PIC-NEXT: cmpq %rsi, %rdx
305 ; X64-PIC-NEXT: cmovneq %rax, %rcx
306 ; X64-PIC-NEXT: shlq $47, %rcx
307 ; X64-PIC-NEXT: movl $13, %eax
308 ; X64-PIC-NEXT: orq %rcx, %rsp
310 ; X64-PIC-NEXT: .LBB4_4: # Block address taken
311 ; X64-PIC-NEXT: # %bb3
312 ; X64-PIC-NEXT: leaq {{.*}}(%rip), %rsi
313 ; X64-PIC-NEXT: cmpq %rsi, %rdx
314 ; X64-PIC-NEXT: cmovneq %rax, %rcx
315 ; X64-PIC-NEXT: shlq $47, %rcx
316 ; X64-PIC-NEXT: movl $42, %eax
317 ; X64-PIC-NEXT: orq %rcx, %rsp
319 ; X64-PIC-NEXT: .LBB4_2: # Block address taken
320 ; X64-PIC-NEXT: # %bb1
321 ; X64-PIC-NEXT: leaq {{.*}}(%rip), %rsi
322 ; X64-PIC-NEXT: cmpq %rsi, %rdx
323 ; X64-PIC-NEXT: cmovneq %rax, %rcx
324 ; X64-PIC-NEXT: shlq $47, %rcx
325 ; X64-PIC-NEXT: movl $7, %eax
326 ; X64-PIC-NEXT: orq %rcx, %rsp
329 ; X64-RETPOLINE-LABEL: test_indirectbr:
330 ; X64-RETPOLINE: # %bb.0: # %entry
332 %a = load i8*, i8** %ptr
333 indirectbr i8* %a, [ label %bb0, label %bb1, label %bb2, label %bb3 ]
348 define i32 @test_indirectbr_global(i32 %idx) nounwind {
349 ; X64-LABEL: test_indirectbr_global:
350 ; X64: # %bb.0: # %entry
351 ; X64-NEXT: movq %rsp, %rcx
352 ; X64-NEXT: movq $-1, %rax
353 ; X64-NEXT: sarq $63, %rcx
354 ; X64-NEXT: movslq %edi, %rdx
355 ; X64-NEXT: movq global_blockaddrs(,%rdx,8), %rdx
356 ; X64-NEXT: orq %rcx, %rdx
357 ; X64-NEXT: jmpq *%rdx
358 ; X64-NEXT: .Ltmp0: # Block address taken
359 ; X64-NEXT: .LBB5_1: # %bb0
360 ; X64-NEXT: cmpq $.LBB5_1, %rdx
361 ; X64-NEXT: cmovneq %rax, %rcx
362 ; X64-NEXT: shlq $47, %rcx
363 ; X64-NEXT: movl $2, %eax
364 ; X64-NEXT: orq %rcx, %rsp
366 ; X64-NEXT: .Ltmp1: # Block address taken
367 ; X64-NEXT: .LBB5_3: # %bb2
368 ; X64-NEXT: cmpq $.LBB5_3, %rdx
369 ; X64-NEXT: cmovneq %rax, %rcx
370 ; X64-NEXT: shlq $47, %rcx
371 ; X64-NEXT: movl $13, %eax
372 ; X64-NEXT: orq %rcx, %rsp
374 ; X64-NEXT: .Ltmp2: # Block address taken
375 ; X64-NEXT: .LBB5_4: # %bb3
376 ; X64-NEXT: cmpq $.LBB5_4, %rdx
377 ; X64-NEXT: cmovneq %rax, %rcx
378 ; X64-NEXT: shlq $47, %rcx
379 ; X64-NEXT: movl $42, %eax
380 ; X64-NEXT: orq %rcx, %rsp
382 ; X64-NEXT: .Ltmp3: # Block address taken
383 ; X64-NEXT: .LBB5_2: # %bb1
384 ; X64-NEXT: cmpq $.LBB5_2, %rdx
385 ; X64-NEXT: cmovneq %rax, %rcx
386 ; X64-NEXT: shlq $47, %rcx
387 ; X64-NEXT: movl $7, %eax
388 ; X64-NEXT: orq %rcx, %rsp
391 ; X64-PIC-LABEL: test_indirectbr_global:
392 ; X64-PIC: # %bb.0: # %entry
393 ; X64-PIC-NEXT: movq %rsp, %rcx
394 ; X64-PIC-NEXT: movq $-1, %rax
395 ; X64-PIC-NEXT: sarq $63, %rcx
396 ; X64-PIC-NEXT: movslq %edi, %rdx
397 ; X64-PIC-NEXT: movq global_blockaddrs@{{.*}}(%rip), %rsi
398 ; X64-PIC-NEXT: movq (%rsi,%rdx,8), %rdx
399 ; X64-PIC-NEXT: orq %rcx, %rdx
400 ; X64-PIC-NEXT: jmpq *%rdx
401 ; X64-PIC-NEXT: .Ltmp0: # Block address taken
402 ; X64-PIC-NEXT: .LBB5_1: # %bb0
403 ; X64-PIC-NEXT: leaq {{.*}}(%rip), %rsi
404 ; X64-PIC-NEXT: cmpq %rsi, %rdx
405 ; X64-PIC-NEXT: cmovneq %rax, %rcx
406 ; X64-PIC-NEXT: shlq $47, %rcx
407 ; X64-PIC-NEXT: movl $2, %eax
408 ; X64-PIC-NEXT: orq %rcx, %rsp
410 ; X64-PIC-NEXT: .Ltmp1: # Block address taken
411 ; X64-PIC-NEXT: .LBB5_3: # %bb2
412 ; X64-PIC-NEXT: leaq {{.*}}(%rip), %rsi
413 ; X64-PIC-NEXT: cmpq %rsi, %rdx
414 ; X64-PIC-NEXT: cmovneq %rax, %rcx
415 ; X64-PIC-NEXT: shlq $47, %rcx
416 ; X64-PIC-NEXT: movl $13, %eax
417 ; X64-PIC-NEXT: orq %rcx, %rsp
419 ; X64-PIC-NEXT: .Ltmp2: # Block address taken
420 ; X64-PIC-NEXT: .LBB5_4: # %bb3
421 ; X64-PIC-NEXT: leaq {{.*}}(%rip), %rsi
422 ; X64-PIC-NEXT: cmpq %rsi, %rdx
423 ; X64-PIC-NEXT: cmovneq %rax, %rcx
424 ; X64-PIC-NEXT: shlq $47, %rcx
425 ; X64-PIC-NEXT: movl $42, %eax
426 ; X64-PIC-NEXT: orq %rcx, %rsp
428 ; X64-PIC-NEXT: .Ltmp3: # Block address taken
429 ; X64-PIC-NEXT: .LBB5_2: # %bb1
430 ; X64-PIC-NEXT: leaq {{.*}}(%rip), %rsi
431 ; X64-PIC-NEXT: cmpq %rsi, %rdx
432 ; X64-PIC-NEXT: cmovneq %rax, %rcx
433 ; X64-PIC-NEXT: shlq $47, %rcx
434 ; X64-PIC-NEXT: movl $7, %eax
435 ; X64-PIC-NEXT: orq %rcx, %rsp
438 ; X64-RETPOLINE-LABEL: test_indirectbr_global:
439 ; X64-RETPOLINE: # %bb.0: # %entry
440 ; X64-RETPOLINE-NEXT: movq %rsp, %rcx
441 ; X64-RETPOLINE-NEXT: movq $-1, %rax
442 ; X64-RETPOLINE-NEXT: sarq $63, %rcx
443 ; X64-RETPOLINE-NEXT: movslq %edi, %rdx
444 ; X64-RETPOLINE-NEXT: movq global_blockaddrs(,%rdx,8), %rdx
445 ; X64-RETPOLINE-NEXT: orq %rcx, %rdx
446 ; X64-RETPOLINE-NEXT: cmpq $2, %rdx
447 ; X64-RETPOLINE-NEXT: je .LBB6_4
448 ; X64-RETPOLINE-NEXT: # %bb.1: # %entry
449 ; X64-RETPOLINE-NEXT: cmoveq %rax, %rcx
450 ; X64-RETPOLINE-NEXT: cmpq $3, %rdx
451 ; X64-RETPOLINE-NEXT: je .LBB6_5
452 ; X64-RETPOLINE-NEXT: # %bb.2: # %entry
453 ; X64-RETPOLINE-NEXT: cmoveq %rax, %rcx
454 ; X64-RETPOLINE-NEXT: cmpq $4, %rdx
455 ; X64-RETPOLINE-NEXT: jne .LBB6_3
456 ; X64-RETPOLINE-NEXT: .Ltmp0: # Block address taken
457 ; X64-RETPOLINE-NEXT: # %bb.6: # %bb3
458 ; X64-RETPOLINE-NEXT: cmovneq %rax, %rcx
459 ; X64-RETPOLINE-NEXT: shlq $47, %rcx
460 ; X64-RETPOLINE-NEXT: movl $42, %eax
461 ; X64-RETPOLINE-NEXT: orq %rcx, %rsp
462 ; X64-RETPOLINE-NEXT: retq
463 ; X64-RETPOLINE-NEXT: .Ltmp1: # Block address taken
464 ; X64-RETPOLINE-NEXT: .LBB6_4: # %bb1
465 ; X64-RETPOLINE-NEXT: cmovneq %rax, %rcx
466 ; X64-RETPOLINE-NEXT: shlq $47, %rcx
467 ; X64-RETPOLINE-NEXT: movl $7, %eax
468 ; X64-RETPOLINE-NEXT: orq %rcx, %rsp
469 ; X64-RETPOLINE-NEXT: retq
470 ; X64-RETPOLINE-NEXT: .Ltmp2: # Block address taken
471 ; X64-RETPOLINE-NEXT: .LBB6_5: # %bb2
472 ; X64-RETPOLINE-NEXT: cmovneq %rax, %rcx
473 ; X64-RETPOLINE-NEXT: shlq $47, %rcx
474 ; X64-RETPOLINE-NEXT: movl $13, %eax
475 ; X64-RETPOLINE-NEXT: orq %rcx, %rsp
476 ; X64-RETPOLINE-NEXT: retq
477 ; X64-RETPOLINE-NEXT: .Ltmp3: # Block address taken
478 ; X64-RETPOLINE-NEXT: .LBB6_3: # %bb0
479 ; X64-RETPOLINE-NEXT: cmoveq %rax, %rcx
480 ; X64-RETPOLINE-NEXT: shlq $47, %rcx
481 ; X64-RETPOLINE-NEXT: movl $2, %eax
482 ; X64-RETPOLINE-NEXT: orq %rcx, %rsp
483 ; X64-RETPOLINE-NEXT: retq
485 %ptr = getelementptr [4 x i8*], [4 x i8*]* @global_blockaddrs, i32 0, i32 %idx
486 %a = load i8*, i8** %ptr
487 indirectbr i8* %a, [ label %bb0, label %bb1, label %bb2, label %bb3 ]
502 ; This function's switch is crafted to trigger jump-table lowering in the x86
503 ; backend so that we can test how the exact jump table lowering behaves.
504 define i32 @test_switch_jumptable(i32 %idx) nounwind {
505 ; X64-LABEL: test_switch_jumptable:
506 ; X64: # %bb.0: # %entry
507 ; X64-NEXT: movq %rsp, %rcx
508 ; X64-NEXT: movq $-1, %rax
509 ; X64-NEXT: sarq $63, %rcx
510 ; X64-NEXT: cmpl $3, %edi
511 ; X64-NEXT: ja .LBB6_2
512 ; X64-NEXT: # %bb.1: # %entry
513 ; X64-NEXT: cmovaq %rax, %rcx
514 ; X64-NEXT: movl %edi, %edx
515 ; X64-NEXT: movq .LJTI6_0(,%rdx,8), %rdx
516 ; X64-NEXT: orq %rcx, %rdx
517 ; X64-NEXT: jmpq *%rdx
518 ; X64-NEXT: .LBB6_3: # Block address taken
520 ; X64-NEXT: cmpq $.LBB6_3, %rdx
521 ; X64-NEXT: cmovneq %rax, %rcx
522 ; X64-NEXT: shlq $47, %rcx
523 ; X64-NEXT: movl $7, %eax
524 ; X64-NEXT: orq %rcx, %rsp
526 ; X64-NEXT: .LBB6_2: # %bb0
527 ; X64-NEXT: cmovbeq %rax, %rcx
528 ; X64-NEXT: shlq $47, %rcx
529 ; X64-NEXT: movl $2, %eax
530 ; X64-NEXT: orq %rcx, %rsp
532 ; X64-NEXT: .LBB6_4: # Block address taken
534 ; X64-NEXT: cmpq $.LBB6_4, %rdx
535 ; X64-NEXT: cmovneq %rax, %rcx
536 ; X64-NEXT: shlq $47, %rcx
537 ; X64-NEXT: movl $13, %eax
538 ; X64-NEXT: orq %rcx, %rsp
540 ; X64-NEXT: .LBB6_5: # Block address taken
542 ; X64-NEXT: cmpq $.LBB6_5, %rdx
543 ; X64-NEXT: cmovneq %rax, %rcx
544 ; X64-NEXT: shlq $47, %rcx
545 ; X64-NEXT: movl $42, %eax
546 ; X64-NEXT: orq %rcx, %rsp
548 ; X64-NEXT: .LBB6_6: # Block address taken
550 ; X64-NEXT: cmpq $.LBB6_6, %rdx
551 ; X64-NEXT: cmovneq %rax, %rcx
552 ; X64-NEXT: shlq $47, %rcx
553 ; X64-NEXT: movl $11, %eax
554 ; X64-NEXT: orq %rcx, %rsp
557 ; X64-PIC-LABEL: test_switch_jumptable:
558 ; X64-PIC: # %bb.0: # %entry
559 ; X64-PIC-NEXT: movq %rsp, %rcx
560 ; X64-PIC-NEXT: movq $-1, %rax
561 ; X64-PIC-NEXT: sarq $63, %rcx
562 ; X64-PIC-NEXT: cmpl $3, %edi
563 ; X64-PIC-NEXT: ja .LBB6_2
564 ; X64-PIC-NEXT: # %bb.1: # %entry
565 ; X64-PIC-NEXT: cmovaq %rax, %rcx
566 ; X64-PIC-NEXT: movl %edi, %edx
567 ; X64-PIC-NEXT: leaq {{.*}}(%rip), %rsi
568 ; X64-PIC-NEXT: movslq (%rsi,%rdx,4), %rdx
569 ; X64-PIC-NEXT: addq %rsi, %rdx
570 ; X64-PIC-NEXT: orq %rcx, %rdx
571 ; X64-PIC-NEXT: jmpq *%rdx
572 ; X64-PIC-NEXT: .LBB6_3: # Block address taken
573 ; X64-PIC-NEXT: # %bb1
574 ; X64-PIC-NEXT: leaq {{.*}}(%rip), %rsi
575 ; X64-PIC-NEXT: cmpq %rsi, %rdx
576 ; X64-PIC-NEXT: cmovneq %rax, %rcx
577 ; X64-PIC-NEXT: shlq $47, %rcx
578 ; X64-PIC-NEXT: movl $7, %eax
579 ; X64-PIC-NEXT: orq %rcx, %rsp
581 ; X64-PIC-NEXT: .LBB6_2: # %bb0
582 ; X64-PIC-NEXT: cmovbeq %rax, %rcx
583 ; X64-PIC-NEXT: shlq $47, %rcx
584 ; X64-PIC-NEXT: movl $2, %eax
585 ; X64-PIC-NEXT: orq %rcx, %rsp
587 ; X64-PIC-NEXT: .LBB6_4: # Block address taken
588 ; X64-PIC-NEXT: # %bb2
589 ; X64-PIC-NEXT: leaq {{.*}}(%rip), %rsi
590 ; X64-PIC-NEXT: cmpq %rsi, %rdx
591 ; X64-PIC-NEXT: cmovneq %rax, %rcx
592 ; X64-PIC-NEXT: shlq $47, %rcx
593 ; X64-PIC-NEXT: movl $13, %eax
594 ; X64-PIC-NEXT: orq %rcx, %rsp
596 ; X64-PIC-NEXT: .LBB6_5: # Block address taken
597 ; X64-PIC-NEXT: # %bb3
598 ; X64-PIC-NEXT: leaq {{.*}}(%rip), %rsi
599 ; X64-PIC-NEXT: cmpq %rsi, %rdx
600 ; X64-PIC-NEXT: cmovneq %rax, %rcx
601 ; X64-PIC-NEXT: shlq $47, %rcx
602 ; X64-PIC-NEXT: movl $42, %eax
603 ; X64-PIC-NEXT: orq %rcx, %rsp
605 ; X64-PIC-NEXT: .LBB6_6: # Block address taken
606 ; X64-PIC-NEXT: # %bb5
607 ; X64-PIC-NEXT: leaq {{.*}}(%rip), %rsi
608 ; X64-PIC-NEXT: cmpq %rsi, %rdx
609 ; X64-PIC-NEXT: cmovneq %rax, %rcx
610 ; X64-PIC-NEXT: shlq $47, %rcx
611 ; X64-PIC-NEXT: movl $11, %eax
612 ; X64-PIC-NEXT: orq %rcx, %rsp
615 ; X64-RETPOLINE-LABEL: test_switch_jumptable:
616 ; X64-RETPOLINE: # %bb.0: # %entry
617 ; X64-RETPOLINE-NEXT: movq %rsp, %rcx
618 ; X64-RETPOLINE-NEXT: movq $-1, %rax
619 ; X64-RETPOLINE-NEXT: sarq $63, %rcx
620 ; X64-RETPOLINE-NEXT: cmpl $1, %edi
621 ; X64-RETPOLINE-NEXT: jg .LBB7_4
622 ; X64-RETPOLINE-NEXT: # %bb.1: # %entry
623 ; X64-RETPOLINE-NEXT: cmovgq %rax, %rcx
624 ; X64-RETPOLINE-NEXT: testl %edi, %edi
625 ; X64-RETPOLINE-NEXT: je .LBB7_7
626 ; X64-RETPOLINE-NEXT: # %bb.2: # %entry
627 ; X64-RETPOLINE-NEXT: cmoveq %rax, %rcx
628 ; X64-RETPOLINE-NEXT: cmpl $1, %edi
629 ; X64-RETPOLINE-NEXT: jne .LBB7_6
630 ; X64-RETPOLINE-NEXT: # %bb.3: # %bb2
631 ; X64-RETPOLINE-NEXT: cmovneq %rax, %rcx
632 ; X64-RETPOLINE-NEXT: shlq $47, %rcx
633 ; X64-RETPOLINE-NEXT: movl $13, %eax
634 ; X64-RETPOLINE-NEXT: orq %rcx, %rsp
635 ; X64-RETPOLINE-NEXT: retq
636 ; X64-RETPOLINE-NEXT: .LBB7_4: # %entry
637 ; X64-RETPOLINE-NEXT: cmovleq %rax, %rcx
638 ; X64-RETPOLINE-NEXT: cmpl $2, %edi
639 ; X64-RETPOLINE-NEXT: je .LBB7_8
640 ; X64-RETPOLINE-NEXT: # %bb.5: # %entry
641 ; X64-RETPOLINE-NEXT: cmoveq %rax, %rcx
642 ; X64-RETPOLINE-NEXT: cmpl $3, %edi
643 ; X64-RETPOLINE-NEXT: jne .LBB7_6
644 ; X64-RETPOLINE-NEXT: # %bb.9: # %bb5
645 ; X64-RETPOLINE-NEXT: cmovneq %rax, %rcx
646 ; X64-RETPOLINE-NEXT: shlq $47, %rcx
647 ; X64-RETPOLINE-NEXT: movl $11, %eax
648 ; X64-RETPOLINE-NEXT: orq %rcx, %rsp
649 ; X64-RETPOLINE-NEXT: retq
650 ; X64-RETPOLINE-NEXT: .LBB7_6:
651 ; X64-RETPOLINE-NEXT: cmoveq %rax, %rcx
652 ; X64-RETPOLINE-NEXT: shlq $47, %rcx
653 ; X64-RETPOLINE-NEXT: movl $2, %eax
654 ; X64-RETPOLINE-NEXT: orq %rcx, %rsp
655 ; X64-RETPOLINE-NEXT: retq
656 ; X64-RETPOLINE-NEXT: .LBB7_7: # %bb1
657 ; X64-RETPOLINE-NEXT: cmovneq %rax, %rcx
658 ; X64-RETPOLINE-NEXT: shlq $47, %rcx
659 ; X64-RETPOLINE-NEXT: movl $7, %eax
660 ; X64-RETPOLINE-NEXT: orq %rcx, %rsp
661 ; X64-RETPOLINE-NEXT: retq
662 ; X64-RETPOLINE-NEXT: .LBB7_8: # %bb3
663 ; X64-RETPOLINE-NEXT: cmovneq %rax, %rcx
664 ; X64-RETPOLINE-NEXT: shlq $47, %rcx
665 ; X64-RETPOLINE-NEXT: movl $42, %eax
666 ; X64-RETPOLINE-NEXT: orq %rcx, %rsp
667 ; X64-RETPOLINE-NEXT: retq
669 switch i32 %idx, label %bb0 [
692 ; This function's switch is crafted to trigger jump-table lowering in the x86
693 ; backend so that we can test how the exact jump table lowering behaves, but
694 ; also arranges for fallthroughs from case to case to ensure that this pattern
695 ; too can be handled.
696 define i32 @test_switch_jumptable_fallthrough(i32 %idx, i32* %a.ptr, i32* %b.ptr, i32* %c.ptr, i32* %d.ptr) nounwind {
697 ; X64-LABEL: test_switch_jumptable_fallthrough:
698 ; X64: # %bb.0: # %entry
699 ; X64-NEXT: movq %rsp, %r9
700 ; X64-NEXT: movq $-1, %r10
701 ; X64-NEXT: sarq $63, %r9
702 ; X64-NEXT: cmpl $3, %edi
703 ; X64-NEXT: ja .LBB7_2
704 ; X64-NEXT: # %bb.1: # %entry
705 ; X64-NEXT: cmovaq %r10, %r9
706 ; X64-NEXT: xorl %eax, %eax
707 ; X64-NEXT: movl %edi, %esi
708 ; X64-NEXT: movq .LJTI7_0(,%rsi,8), %rsi
709 ; X64-NEXT: orq %r9, %rsi
710 ; X64-NEXT: jmpq *%rsi
711 ; X64-NEXT: .LBB7_2: # %bb0
712 ; X64-NEXT: cmovbeq %r10, %r9
713 ; X64-NEXT: movl (%rsi), %eax
714 ; X64-NEXT: orl %r9d, %eax
715 ; X64-NEXT: movq $.LBB7_3, %rsi
716 ; X64-NEXT: .LBB7_3: # Block address taken
718 ; X64-NEXT: cmpq $.LBB7_3, %rsi
719 ; X64-NEXT: cmovneq %r10, %r9
720 ; X64-NEXT: addl (%rdx), %eax
721 ; X64-NEXT: orl %r9d, %eax
722 ; X64-NEXT: movq $.LBB7_4, %rsi
723 ; X64-NEXT: .LBB7_4: # Block address taken
725 ; X64-NEXT: cmpq $.LBB7_4, %rsi
726 ; X64-NEXT: cmovneq %r10, %r9
727 ; X64-NEXT: addl (%rcx), %eax
728 ; X64-NEXT: orl %r9d, %eax
729 ; X64-NEXT: movq $.LBB7_5, %rsi
730 ; X64-NEXT: .LBB7_5: # Block address taken
732 ; X64-NEXT: cmpq $.LBB7_5, %rsi
733 ; X64-NEXT: cmovneq %r10, %r9
734 ; X64-NEXT: addl (%r8), %eax
735 ; X64-NEXT: orl %r9d, %eax
736 ; X64-NEXT: movq $.LBB7_6, %rsi
737 ; X64-NEXT: .LBB7_6: # Block address taken
739 ; X64-NEXT: cmpq $.LBB7_6, %rsi
740 ; X64-NEXT: cmovneq %r10, %r9
741 ; X64-NEXT: shlq $47, %r9
742 ; X64-NEXT: orq %r9, %rsp
745 ; X64-PIC-LABEL: test_switch_jumptable_fallthrough:
746 ; X64-PIC: # %bb.0: # %entry
747 ; X64-PIC-NEXT: movq %rsp, %r9
748 ; X64-PIC-NEXT: movq $-1, %r10
749 ; X64-PIC-NEXT: sarq $63, %r9
750 ; X64-PIC-NEXT: cmpl $3, %edi
751 ; X64-PIC-NEXT: ja .LBB7_2
752 ; X64-PIC-NEXT: # %bb.1: # %entry
753 ; X64-PIC-NEXT: cmovaq %r10, %r9
754 ; X64-PIC-NEXT: xorl %eax, %eax
755 ; X64-PIC-NEXT: movl %edi, %esi
756 ; X64-PIC-NEXT: leaq {{.*}}(%rip), %rdi
757 ; X64-PIC-NEXT: movslq (%rdi,%rsi,4), %rsi
758 ; X64-PIC-NEXT: addq %rdi, %rsi
759 ; X64-PIC-NEXT: orq %r9, %rsi
760 ; X64-PIC-NEXT: jmpq *%rsi
761 ; X64-PIC-NEXT: .LBB7_2: # %bb0
762 ; X64-PIC-NEXT: cmovbeq %r10, %r9
763 ; X64-PIC-NEXT: movl (%rsi), %eax
764 ; X64-PIC-NEXT: orl %r9d, %eax
765 ; X64-PIC-NEXT: leaq {{.*}}(%rip), %rsi
766 ; X64-PIC-NEXT: .LBB7_3: # Block address taken
767 ; X64-PIC-NEXT: # %bb1
768 ; X64-PIC-NEXT: leaq {{.*}}(%rip), %rdi
769 ; X64-PIC-NEXT: cmpq %rdi, %rsi
770 ; X64-PIC-NEXT: cmovneq %r10, %r9
771 ; X64-PIC-NEXT: addl (%rdx), %eax
772 ; X64-PIC-NEXT: orl %r9d, %eax
773 ; X64-PIC-NEXT: leaq {{.*}}(%rip), %rsi
774 ; X64-PIC-NEXT: .LBB7_4: # Block address taken
775 ; X64-PIC-NEXT: # %bb2
776 ; X64-PIC-NEXT: leaq {{.*}}(%rip), %rdx
777 ; X64-PIC-NEXT: cmpq %rdx, %rsi
778 ; X64-PIC-NEXT: cmovneq %r10, %r9
779 ; X64-PIC-NEXT: addl (%rcx), %eax
780 ; X64-PIC-NEXT: orl %r9d, %eax
781 ; X64-PIC-NEXT: leaq {{.*}}(%rip), %rsi
782 ; X64-PIC-NEXT: .LBB7_5: # Block address taken
783 ; X64-PIC-NEXT: # %bb3
784 ; X64-PIC-NEXT: leaq {{.*}}(%rip), %rcx
785 ; X64-PIC-NEXT: cmpq %rcx, %rsi
786 ; X64-PIC-NEXT: cmovneq %r10, %r9
787 ; X64-PIC-NEXT: addl (%r8), %eax
788 ; X64-PIC-NEXT: orl %r9d, %eax
789 ; X64-PIC-NEXT: leaq {{.*}}(%rip), %rsi
790 ; X64-PIC-NEXT: .LBB7_6: # Block address taken
791 ; X64-PIC-NEXT: # %bb4
792 ; X64-PIC-NEXT: leaq {{.*}}(%rip), %rcx
793 ; X64-PIC-NEXT: cmpq %rcx, %rsi
794 ; X64-PIC-NEXT: cmovneq %r10, %r9
795 ; X64-PIC-NEXT: shlq $47, %r9
796 ; X64-PIC-NEXT: orq %r9, %rsp
799 ; X64-RETPOLINE-LABEL: test_switch_jumptable_fallthrough:
800 ; X64-RETPOLINE: # %bb.0: # %entry
801 ; X64-RETPOLINE-NEXT: movq %rsp, %r9
802 ; X64-RETPOLINE-NEXT: movq $-1, %r10
803 ; X64-RETPOLINE-NEXT: sarq $63, %r9
804 ; X64-RETPOLINE-NEXT: xorl %eax, %eax
805 ; X64-RETPOLINE-NEXT: cmpl $1, %edi
806 ; X64-RETPOLINE-NEXT: jg .LBB8_5
807 ; X64-RETPOLINE-NEXT: # %bb.1: # %entry
808 ; X64-RETPOLINE-NEXT: cmovgq %r10, %r9
809 ; X64-RETPOLINE-NEXT: testl %edi, %edi
810 ; X64-RETPOLINE-NEXT: je .LBB8_2
811 ; X64-RETPOLINE-NEXT: # %bb.3: # %entry
812 ; X64-RETPOLINE-NEXT: cmoveq %r10, %r9
813 ; X64-RETPOLINE-NEXT: cmpl $1, %edi
814 ; X64-RETPOLINE-NEXT: jne .LBB8_8
815 ; X64-RETPOLINE-NEXT: # %bb.4:
816 ; X64-RETPOLINE-NEXT: cmovneq %r10, %r9
817 ; X64-RETPOLINE-NEXT: jmp .LBB8_10
818 ; X64-RETPOLINE-NEXT: .LBB8_5: # %entry
819 ; X64-RETPOLINE-NEXT: cmovleq %r10, %r9
820 ; X64-RETPOLINE-NEXT: cmpl $2, %edi
821 ; X64-RETPOLINE-NEXT: je .LBB8_6
822 ; X64-RETPOLINE-NEXT: # %bb.7: # %entry
823 ; X64-RETPOLINE-NEXT: cmoveq %r10, %r9
824 ; X64-RETPOLINE-NEXT: cmpl $3, %edi
825 ; X64-RETPOLINE-NEXT: jne .LBB8_8
826 ; X64-RETPOLINE-NEXT: # %bb.13:
827 ; X64-RETPOLINE-NEXT: cmovneq %r10, %r9
828 ; X64-RETPOLINE-NEXT: jmp .LBB8_12
829 ; X64-RETPOLINE-NEXT: .LBB8_8:
830 ; X64-RETPOLINE-NEXT: cmoveq %r10, %r9
831 ; X64-RETPOLINE-NEXT: movl (%rsi), %eax
832 ; X64-RETPOLINE-NEXT: orl %r9d, %eax
833 ; X64-RETPOLINE-NEXT: jmp .LBB8_9
834 ; X64-RETPOLINE-NEXT: .LBB8_2:
835 ; X64-RETPOLINE-NEXT: cmovneq %r10, %r9
836 ; X64-RETPOLINE-NEXT: .LBB8_9: # %bb1
837 ; X64-RETPOLINE-NEXT: addl (%rdx), %eax
838 ; X64-RETPOLINE-NEXT: orl %r9d, %eax
839 ; X64-RETPOLINE-NEXT: .LBB8_10: # %bb2
840 ; X64-RETPOLINE-NEXT: addl (%rcx), %eax
841 ; X64-RETPOLINE-NEXT: orl %r9d, %eax
842 ; X64-RETPOLINE-NEXT: jmp .LBB8_11
843 ; X64-RETPOLINE-NEXT: .LBB8_6:
844 ; X64-RETPOLINE-NEXT: cmovneq %r10, %r9
845 ; X64-RETPOLINE-NEXT: .LBB8_11: # %bb3
846 ; X64-RETPOLINE-NEXT: addl (%r8), %eax
847 ; X64-RETPOLINE-NEXT: orl %r9d, %eax
848 ; X64-RETPOLINE-NEXT: .LBB8_12: # %bb4
849 ; X64-RETPOLINE-NEXT: shlq $47, %r9
850 ; X64-RETPOLINE-NEXT: orq %r9, %rsp
851 ; X64-RETPOLINE-NEXT: retq
853 switch i32 %idx, label %bb0 [
861 %a = load i32, i32* %a.ptr
865 %b.phi = phi i32 [ 0, %entry ], [ %a, %bb0 ]
866 %b = load i32, i32* %b.ptr
867 %b.sum = add i32 %b.phi, %b
871 %c.phi = phi i32 [ 0, %entry ], [ %b.sum, %bb1 ]
872 %c = load i32, i32* %c.ptr
873 %c.sum = add i32 %c.phi, %c
877 %d.phi = phi i32 [ 0, %entry ], [ %c.sum, %bb2 ]
878 %d = load i32, i32* %d.ptr
879 %d.sum = add i32 %d.phi, %d
883 %e.phi = phi i32 [ 0, %entry ], [ %d.sum, %bb3 ]