1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -O0 -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -o - %s | FileCheck %s
4 @V1 = protected local_unnamed_addr addrspace(1) global i32 0, align 4
5 @V2 = protected local_unnamed_addr addrspace(1) global i32 0, align 4
6 @Q = internal addrspace(3) global i8 poison, align 16
8 ; Test spill placement of VGPR reload in %bb.194 relative to the SGPR
9 ; reload used for the exec mask. The buffer_load_dword should be after
11 define amdgpu_kernel void @__omp_offloading_16_dd2df_main_l9() {
12 ; CHECK-LABEL: __omp_offloading_16_dd2df_main_l9:
13 ; CHECK: ; %bb.0: ; %bb
14 ; CHECK-NEXT: s_add_u32 s0, s0, s13
15 ; CHECK-NEXT: s_addc_u32 s1, s1, 0
16 ; CHECK-NEXT: ; implicit-def: $vgpr1 : SGPR spill to VGPR lane
17 ; CHECK-NEXT: v_mov_b32_e32 v2, v0
18 ; CHECK-NEXT: s_or_saveexec_b64 s[8:9], -1
19 ; CHECK-NEXT: buffer_load_dword v0, off, s[0:3], 0 ; 4-byte Folded Reload
20 ; CHECK-NEXT: s_mov_b64 exec, s[8:9]
21 ; CHECK-NEXT: v_mov_b32_e32 v1, 0
22 ; CHECK-NEXT: global_load_ushort v3, v1, s[4:5] offset:4
23 ; CHECK-NEXT: s_waitcnt vmcnt(0)
24 ; CHECK-NEXT: buffer_store_dword v3, off, s[0:3], 0 offset:4 ; 4-byte Folded Spill
25 ; CHECK-NEXT: ; implicit-def: $sgpr4
26 ; CHECK-NEXT: s_mov_b32 s4, 0
27 ; CHECK-NEXT: v_cmp_eq_u32_e64 s[6:7], v2, s4
28 ; CHECK-NEXT: s_mov_b32 s4, 0
29 ; CHECK-NEXT: v_mov_b32_e32 v2, s4
30 ; CHECK-NEXT: ds_write_b8 v1, v2
31 ; CHECK-NEXT: s_mov_b64 s[4:5], exec
32 ; CHECK-NEXT: v_writelane_b32 v0, s4, 0
33 ; CHECK-NEXT: v_writelane_b32 v0, s5, 1
34 ; CHECK-NEXT: s_or_saveexec_b64 s[8:9], -1
35 ; CHECK-NEXT: buffer_store_dword v0, off, s[0:3], 0 ; 4-byte Folded Spill
36 ; CHECK-NEXT: s_mov_b64 exec, s[8:9]
37 ; CHECK-NEXT: s_and_b64 s[4:5], s[4:5], s[6:7]
38 ; CHECK-NEXT: s_mov_b64 exec, s[4:5]
39 ; CHECK-NEXT: s_cbranch_execz .LBB0_2
40 ; CHECK-NEXT: ; %bb.1: ; %bb193
41 ; CHECK-NEXT: .LBB0_2: ; %bb194
42 ; CHECK-NEXT: s_or_saveexec_b64 s[8:9], -1
43 ; CHECK-NEXT: buffer_load_dword v1, off, s[0:3], 0 ; 4-byte Folded Reload
44 ; CHECK-NEXT: s_mov_b64 exec, s[8:9]
45 ; CHECK-NEXT: s_waitcnt vmcnt(0)
46 ; CHECK-NEXT: v_readlane_b32 s4, v1, 0
47 ; CHECK-NEXT: v_readlane_b32 s5, v1, 1
48 ; CHECK-NEXT: s_or_b64 exec, exec, s[4:5]
49 ; CHECK-NEXT: buffer_load_dword v0, off, s[0:3], 0 offset:4 ; 4-byte Folded Reload
50 ; CHECK-NEXT: s_mov_b32 s4, 0
51 ; CHECK-NEXT: s_waitcnt vmcnt(0)
52 ; CHECK-NEXT: v_cmp_ne_u16_e64 s[4:5], v0, s4
53 ; CHECK-NEXT: s_and_b64 vcc, exec, s[4:5]
54 ; CHECK-NEXT: s_cbranch_vccnz .LBB0_4
55 ; CHECK-NEXT: ; %bb.3: ; %bb201
56 ; CHECK-NEXT: buffer_load_dword v1, off, s[0:3], 0 offset:4 ; 4-byte Folded Reload
57 ; CHECK-NEXT: s_getpc_b64 s[4:5]
58 ; CHECK-NEXT: s_add_u32 s4, s4, V2@rel32@lo+4
59 ; CHECK-NEXT: s_addc_u32 s5, s5, V2@rel32@hi+12
60 ; CHECK-NEXT: v_mov_b32_e32 v0, 0
61 ; CHECK-NEXT: s_waitcnt vmcnt(0)
62 ; CHECK-NEXT: global_store_short v0, v1, s[4:5]
63 ; CHECK-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
64 ; CHECK-NEXT: s_barrier
65 ; CHECK-NEXT: s_trap 2
66 ; CHECK-NEXT: ; divergent unreachable
67 ; CHECK-NEXT: .LBB0_4: ; %UnifiedReturnBlock
68 ; CHECK-NEXT: s_or_saveexec_b64 s[8:9], -1
69 ; CHECK-NEXT: buffer_load_dword v0, off, s[0:3], 0 ; 4-byte Folded Reload
70 ; CHECK-NEXT: s_mov_b64 exec, s[8:9]
71 ; CHECK-NEXT: ; kill: killed $vgpr0
72 ; CHECK-NEXT: s_endpgm
74 %i10 = tail call i32 @llvm.amdgcn.workitem.id.x()
75 %i13 = tail call align 4 dereferenceable(64) ptr addrspace(4) @llvm.amdgcn.dispatch.ptr()
76 %i14 = getelementptr i8, ptr addrspace(4) %i13, i64 4
77 %i15 = load i16, ptr addrspace(4) %i14, align 4
78 %i22 = icmp eq i32 %i10, 0
79 store i8 0, ptr addrspace(3) @Q
80 br i1 %i22, label %bb193, label %bb194
82 bb193: ; preds = %bb190
85 bb194: ; preds = %bb193, %bb190
86 %i196 = icmp eq i16 %i15, 0
87 br i1 %i196, label %bb201, label %bb202
89 bb201: ; preds = %bb194
90 store i16 %i15, ptr addrspace(1) @V2
91 call void @llvm.amdgcn.s.barrier()
92 tail call void @llvm.trap()
95 bb202: ; preds = %bb194, %bb170, %bb93
99 declare hidden void @__keep_alive()
100 declare i32 @llvm.amdgcn.workitem.id.x()
101 declare align 4 ptr addrspace(4) @llvm.amdgcn.dispatch.ptr()
102 declare void @llvm.assume(i1 noundef)
103 declare void @llvm.amdgcn.s.barrier()
104 declare void @llvm.trap()
106 !llvm.module.flags = !{!0}
107 !0 = !{i32 1, !"amdhsa_code_object_version", i32 500}