1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -global-isel=0 -mtriple=amdgcn-amd-amdpal -mcpu=tahiti < %s | FileCheck -check-prefixes=CHECK,SDAG %s
3 ; RUN: llc -global-isel=1 -mtriple=amdgcn-amd-amdpal -mcpu=tahiti < %s | FileCheck -check-prefixes=CHECK,GISEL %s
5 define ptr @global_to_flat_addrspacecast(ptr addrspace(1) %ptr) {
6 ; CHECK-LABEL: global_to_flat_addrspacecast:
8 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
9 ; CHECK-NEXT: s_setpc_b64 s[30:31]
10 %stof = addrspacecast ptr addrspace(1) %ptr to ptr
14 define ptr addrspace(1) @flat_to_gobal_addrspacecast(ptr %ptr) {
15 ; CHECK-LABEL: flat_to_gobal_addrspacecast:
17 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
18 ; CHECK-NEXT: s_setpc_b64 s[30:31]
19 %stof = addrspacecast ptr %ptr to ptr addrspace(1)
20 ret ptr addrspace(1) %stof
23 define ptr @group_to_flat_addrspacecast(ptr addrspace(3) %ptr) {
24 ; CHECK-LABEL: group_to_flat_addrspacecast:
26 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
27 ; CHECK-NEXT: s_load_dword s4, s[6:7], 0x10
28 ; CHECK-NEXT: v_cmp_ne_u32_e32 vcc, -1, v0
29 ; CHECK-NEXT: v_cndmask_b32_e32 v0, 0, v0, vcc
30 ; CHECK-NEXT: s_waitcnt lgkmcnt(0)
31 ; CHECK-NEXT: v_mov_b32_e32 v1, s4
32 ; CHECK-NEXT: v_cndmask_b32_e32 v1, 0, v1, vcc
33 ; CHECK-NEXT: s_setpc_b64 s[30:31]
34 %stof = addrspacecast ptr addrspace(3) %ptr to ptr
38 define ptr addrspace(3) @flat_to_group_addrspacecast(ptr %ptr) {
39 ; CHECK-LABEL: flat_to_group_addrspacecast:
41 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
42 ; CHECK-NEXT: v_cmp_ne_u64_e32 vcc, 0, v[0:1]
43 ; CHECK-NEXT: v_cndmask_b32_e32 v0, -1, v0, vcc
44 ; CHECK-NEXT: s_setpc_b64 s[30:31]
45 %stof = addrspacecast ptr %ptr to ptr addrspace(3)
46 ret ptr addrspace(3) %stof
49 define ptr @private_to_flat_addrspacecast(ptr addrspace(5) %ptr) {
50 ; CHECK-LABEL: private_to_flat_addrspacecast:
52 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
53 ; CHECK-NEXT: s_load_dword s4, s[6:7], 0x11
54 ; CHECK-NEXT: v_cmp_ne_u32_e32 vcc, -1, v0
55 ; CHECK-NEXT: v_cndmask_b32_e32 v0, 0, v0, vcc
56 ; CHECK-NEXT: s_waitcnt lgkmcnt(0)
57 ; CHECK-NEXT: v_mov_b32_e32 v1, s4
58 ; CHECK-NEXT: v_cndmask_b32_e32 v1, 0, v1, vcc
59 ; CHECK-NEXT: s_setpc_b64 s[30:31]
60 %stof = addrspacecast ptr addrspace(5) %ptr to ptr
64 define ptr addrspace(5) @flat_to_private_addrspacecast(ptr %ptr) {
65 ; CHECK-LABEL: flat_to_private_addrspacecast:
67 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
68 ; CHECK-NEXT: v_cmp_ne_u64_e32 vcc, 0, v[0:1]
69 ; CHECK-NEXT: v_cndmask_b32_e32 v0, -1, v0, vcc
70 ; CHECK-NEXT: s_setpc_b64 s[30:31]
71 %stof = addrspacecast ptr %ptr to ptr addrspace(5)
72 ret ptr addrspace(5) %stof
75 define ptr addrspace(6) @constant_to_constant32_addrspacecast(ptr addrspace(4) %ptr, i32 %offset) {
76 ; CHECK-LABEL: constant_to_constant32_addrspacecast:
78 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
79 ; CHECK-NEXT: v_add_i32_e32 v0, vcc, v0, v2
80 ; CHECK-NEXT: s_setpc_b64 s[30:31]
81 %addrspacecast = addrspacecast ptr addrspace(4) %ptr to ptr addrspace(6)
82 %gep = getelementptr i8, ptr addrspace(6) %addrspacecast, i32 %offset
83 ret ptr addrspace(6) %gep
86 define ptr addrspace(6) @global_to_constant32_addrspacecast(ptr addrspace(1) %ptr, i32 %offset) {
87 ; CHECK-LABEL: global_to_constant32_addrspacecast:
89 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
90 ; CHECK-NEXT: v_add_i32_e32 v0, vcc, v0, v2
91 ; CHECK-NEXT: s_setpc_b64 s[30:31]
92 %addrspacecast = addrspacecast ptr addrspace(1) %ptr to ptr addrspace(6)
93 %gep = getelementptr i8, ptr addrspace(6) %addrspacecast, i32 %offset
94 ret ptr addrspace(6) %gep
97 define ptr @constant32bit_to_flat_addrspacecast_0(ptr addrspace(6) %ptr) {
98 ; CHECK-LABEL: constant32bit_to_flat_addrspacecast_0:
100 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
101 ; CHECK-NEXT: v_mov_b32_e32 v1, 0
102 ; CHECK-NEXT: s_setpc_b64 s[30:31]
103 %stof = addrspacecast ptr addrspace(6) %ptr to ptr
107 define ptr @constant32bit_to_flat_addrspacecast_1(ptr addrspace(6) %ptr) #0 {
108 ; CHECK-LABEL: constant32bit_to_flat_addrspacecast_1:
110 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
111 ; CHECK-NEXT: v_mov_b32_e32 v1, 0xffff8000
112 ; CHECK-NEXT: s_setpc_b64 s[30:31]
113 %stof = addrspacecast ptr addrspace(6) %ptr to ptr
117 define ptr @constant32bit_to_flat_addrspacecast_null() {
118 ; CHECK-LABEL: constant32bit_to_flat_addrspacecast_null:
120 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
121 ; CHECK-NEXT: v_mov_b32_e32 v0, 0
122 ; CHECK-NEXT: v_mov_b32_e32 v1, 0
123 ; CHECK-NEXT: s_setpc_b64 s[30:31]
124 %stof = addrspacecast ptr addrspace(6) null to ptr
128 define ptr @constant32bit_to_flat_addrspacecast_undef() #0 {
129 ; SDAG-LABEL: constant32bit_to_flat_addrspacecast_undef:
131 ; SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
132 ; SDAG-NEXT: v_mov_b32_e32 v1, 0
133 ; SDAG-NEXT: s_setpc_b64 s[30:31]
135 ; GISEL-LABEL: constant32bit_to_flat_addrspacecast_undef:
137 ; GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
138 ; GISEL-NEXT: s_setpc_b64 s[30:31]
139 %stof = addrspacecast ptr addrspace(6) undef to ptr
143 define ptr @constant32bit_to_flat_addrspacecast_poison() #0 {
144 ; SDAG-LABEL: constant32bit_to_flat_addrspacecast_poison:
146 ; SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
147 ; SDAG-NEXT: v_mov_b32_e32 v1, 0
148 ; SDAG-NEXT: s_setpc_b64 s[30:31]
150 ; GISEL-LABEL: constant32bit_to_flat_addrspacecast_poison:
152 ; GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
153 ; GISEL-NEXT: s_setpc_b64 s[30:31]
154 %stof = addrspacecast ptr addrspace(6) poison to ptr
158 define ptr @constant32bit_to_flat_addrspacecast_constant() #0 {
159 ; CHECK-LABEL: constant32bit_to_flat_addrspacecast_constant:
161 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
162 ; CHECK-NEXT: v_mov_b32_e32 v0, 0x3039
163 ; CHECK-NEXT: v_mov_b32_e32 v1, 0xffff8000
164 ; CHECK-NEXT: s_setpc_b64 s[30:31]
165 %stof = addrspacecast ptr addrspace(6) inttoptr (i32 12345 to ptr addrspace(6)) to ptr
169 define ptr addrspace(1) @addrspacecast_flat_null_to_global() {
170 ; CHECK-LABEL: addrspacecast_flat_null_to_global:
172 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
173 ; CHECK-NEXT: v_mov_b32_e32 v0, 0
174 ; CHECK-NEXT: v_mov_b32_e32 v1, 0
175 ; CHECK-NEXT: s_setpc_b64 s[30:31]
176 ret ptr addrspace(1) addrspacecast (ptr null to ptr addrspace(1))
179 define ptr addrspace(3) @addrspacecast_flat_null_to_group() {
180 ; CHECK-LABEL: addrspacecast_flat_null_to_group:
182 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
183 ; CHECK-NEXT: v_mov_b32_e32 v0, -1
184 ; CHECK-NEXT: s_setpc_b64 s[30:31]
185 ret ptr addrspace(3) addrspacecast (ptr null to ptr addrspace(3))
188 define ptr addrspace(5) @addrspacecast_flat_null_to_private() {
189 ; CHECK-LABEL: addrspacecast_flat_null_to_private:
191 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
192 ; CHECK-NEXT: v_mov_b32_e32 v0, -1
193 ; CHECK-NEXT: s_setpc_b64 s[30:31]
194 ret ptr addrspace(5) addrspacecast (ptr null to ptr addrspace(5))
197 define ptr addrspace(6) @addrspacecast_flat_null_to_constant32bit() {
198 ; CHECK-LABEL: addrspacecast_flat_null_to_constant32bit:
200 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
201 ; CHECK-NEXT: v_mov_b32_e32 v0, 0
202 ; CHECK-NEXT: s_setpc_b64 s[30:31]
203 ret ptr addrspace(6) addrspacecast (ptr null to ptr addrspace(6))
206 attributes #0 = { "amdgpu-32bit-address-high-bits"="0xffff8000" }