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_mov_b64 s[4:5], 0xc4
28 ; CHECK-NEXT: s_load_dword s4, s[4:5], 0x0
29 ; CHECK-NEXT: v_cmp_ne_u32_e32 vcc, -1, v0
30 ; CHECK-NEXT: v_cndmask_b32_e32 v0, 0, v0, vcc
31 ; CHECK-NEXT: s_waitcnt lgkmcnt(0)
32 ; CHECK-NEXT: v_mov_b32_e32 v1, s4
33 ; CHECK-NEXT: v_cndmask_b32_e32 v1, 0, v1, vcc
34 ; CHECK-NEXT: s_setpc_b64 s[30:31]
35 %stof = addrspacecast ptr addrspace(3) %ptr to ptr
39 define ptr addrspace(3) @flat_to_group_addrspacecast(ptr %ptr) {
40 ; CHECK-LABEL: flat_to_group_addrspacecast:
42 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
43 ; CHECK-NEXT: v_cmp_ne_u64_e32 vcc, 0, v[0:1]
44 ; CHECK-NEXT: v_cndmask_b32_e32 v0, -1, v0, vcc
45 ; CHECK-NEXT: s_setpc_b64 s[30:31]
46 %stof = addrspacecast ptr %ptr to ptr addrspace(3)
47 ret ptr addrspace(3) %stof
50 define ptr @private_to_flat_addrspacecast(ptr addrspace(5) %ptr) {
51 ; CHECK-LABEL: private_to_flat_addrspacecast:
53 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
54 ; CHECK-NEXT: s_mov_b64 s[4:5], 0xc0
55 ; CHECK-NEXT: s_load_dword s4, s[4:5], 0x0
56 ; CHECK-NEXT: v_cmp_ne_u32_e32 vcc, -1, v0
57 ; CHECK-NEXT: v_cndmask_b32_e32 v0, 0, v0, vcc
58 ; CHECK-NEXT: s_waitcnt lgkmcnt(0)
59 ; CHECK-NEXT: v_mov_b32_e32 v1, s4
60 ; CHECK-NEXT: v_cndmask_b32_e32 v1, 0, v1, vcc
61 ; CHECK-NEXT: s_setpc_b64 s[30:31]
62 %stof = addrspacecast ptr addrspace(5) %ptr to ptr
66 define ptr addrspace(5) @flat_to_private_addrspacecast(ptr %ptr) {
67 ; CHECK-LABEL: flat_to_private_addrspacecast:
69 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
70 ; CHECK-NEXT: v_cmp_ne_u64_e32 vcc, 0, v[0:1]
71 ; CHECK-NEXT: v_cndmask_b32_e32 v0, -1, v0, vcc
72 ; CHECK-NEXT: s_setpc_b64 s[30:31]
73 %stof = addrspacecast ptr %ptr to ptr addrspace(5)
74 ret ptr addrspace(5) %stof
77 define ptr addrspace(6) @constant_to_constant32_addrspacecast(ptr addrspace(4) %ptr, i32 %offset) {
78 ; CHECK-LABEL: constant_to_constant32_addrspacecast:
80 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
81 ; CHECK-NEXT: v_add_i32_e32 v0, vcc, v0, v2
82 ; CHECK-NEXT: s_setpc_b64 s[30:31]
83 %addrspacecast = addrspacecast ptr addrspace(4) %ptr to ptr addrspace(6)
84 %gep = getelementptr i8, ptr addrspace(6) %addrspacecast, i32 %offset
85 ret ptr addrspace(6) %gep
88 define ptr addrspace(6) @global_to_constant32_addrspacecast(ptr addrspace(1) %ptr, i32 %offset) {
89 ; CHECK-LABEL: global_to_constant32_addrspacecast:
91 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
92 ; CHECK-NEXT: v_add_i32_e32 v0, vcc, v0, v2
93 ; CHECK-NEXT: s_setpc_b64 s[30:31]
94 %addrspacecast = addrspacecast ptr addrspace(1) %ptr to ptr addrspace(6)
95 %gep = getelementptr i8, ptr addrspace(6) %addrspacecast, i32 %offset
96 ret ptr addrspace(6) %gep
99 define ptr @constant32bit_to_flat_addrspacecast_0(ptr addrspace(6) %ptr) {
100 ; CHECK-LABEL: constant32bit_to_flat_addrspacecast_0:
102 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
103 ; CHECK-NEXT: v_mov_b32_e32 v1, 0
104 ; CHECK-NEXT: s_setpc_b64 s[30:31]
105 %stof = addrspacecast ptr addrspace(6) %ptr to ptr
109 define ptr @constant32bit_to_flat_addrspacecast_1(ptr addrspace(6) %ptr) #0 {
110 ; CHECK-LABEL: constant32bit_to_flat_addrspacecast_1:
112 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
113 ; CHECK-NEXT: v_mov_b32_e32 v1, 0xffff8000
114 ; CHECK-NEXT: s_setpc_b64 s[30:31]
115 %stof = addrspacecast ptr addrspace(6) %ptr to ptr
119 define ptr @constant32bit_to_flat_addrspacecast_null() {
120 ; CHECK-LABEL: constant32bit_to_flat_addrspacecast_null:
122 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
123 ; CHECK-NEXT: v_mov_b32_e32 v0, 0
124 ; CHECK-NEXT: v_mov_b32_e32 v1, 0
125 ; CHECK-NEXT: s_setpc_b64 s[30:31]
126 %stof = addrspacecast ptr addrspace(6) null to ptr
130 define ptr @constant32bit_to_flat_addrspacecast_undef() #0 {
131 ; SDAG-LABEL: constant32bit_to_flat_addrspacecast_undef:
133 ; SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
134 ; SDAG-NEXT: v_mov_b32_e32 v1, 0
135 ; SDAG-NEXT: s_setpc_b64 s[30:31]
137 ; GISEL-LABEL: constant32bit_to_flat_addrspacecast_undef:
139 ; GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
140 ; GISEL-NEXT: s_setpc_b64 s[30:31]
141 %stof = addrspacecast ptr addrspace(6) undef to ptr
145 define ptr @constant32bit_to_flat_addrspacecast_poison() #0 {
146 ; SDAG-LABEL: constant32bit_to_flat_addrspacecast_poison:
148 ; SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
149 ; SDAG-NEXT: v_mov_b32_e32 v1, 0
150 ; SDAG-NEXT: s_setpc_b64 s[30:31]
152 ; GISEL-LABEL: constant32bit_to_flat_addrspacecast_poison:
154 ; GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
155 ; GISEL-NEXT: s_setpc_b64 s[30:31]
156 %stof = addrspacecast ptr addrspace(6) poison to ptr
160 define ptr @constant32bit_to_flat_addrspacecast_constant() #0 {
161 ; CHECK-LABEL: constant32bit_to_flat_addrspacecast_constant:
163 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
164 ; CHECK-NEXT: v_mov_b32_e32 v0, 0x3039
165 ; CHECK-NEXT: v_mov_b32_e32 v1, 0xffff8000
166 ; CHECK-NEXT: s_setpc_b64 s[30:31]
167 %stof = addrspacecast ptr addrspace(6) inttoptr (i32 12345 to ptr addrspace(6)) to ptr
171 define ptr addrspace(1) @addrspacecast_flat_null_to_global() {
172 ; CHECK-LABEL: addrspacecast_flat_null_to_global:
174 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
175 ; CHECK-NEXT: v_mov_b32_e32 v0, 0
176 ; CHECK-NEXT: v_mov_b32_e32 v1, 0
177 ; CHECK-NEXT: s_setpc_b64 s[30:31]
178 ret ptr addrspace(1) addrspacecast (ptr null to ptr addrspace(1))
181 define ptr addrspace(3) @addrspacecast_flat_null_to_group() {
182 ; CHECK-LABEL: addrspacecast_flat_null_to_group:
184 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
185 ; CHECK-NEXT: v_mov_b32_e32 v0, -1
186 ; CHECK-NEXT: s_setpc_b64 s[30:31]
187 ret ptr addrspace(3) addrspacecast (ptr null to ptr addrspace(3))
190 define ptr addrspace(5) @addrspacecast_flat_null_to_private() {
191 ; CHECK-LABEL: addrspacecast_flat_null_to_private:
193 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
194 ; CHECK-NEXT: v_mov_b32_e32 v0, -1
195 ; CHECK-NEXT: s_setpc_b64 s[30:31]
196 ret ptr addrspace(5) addrspacecast (ptr null to ptr addrspace(5))
199 define ptr addrspace(6) @addrspacecast_flat_null_to_constant32bit() {
200 ; CHECK-LABEL: addrspacecast_flat_null_to_constant32bit:
202 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
203 ; CHECK-NEXT: v_mov_b32_e32 v0, 0
204 ; CHECK-NEXT: s_setpc_b64 s[30:31]
205 ret ptr addrspace(6) addrspacecast (ptr null to ptr addrspace(6))
208 attributes #0 = { "amdgpu-32bit-address-high-bits"="0xffff8000" }
210 !llvm.module.flags = !{!0}
211 !0 = !{i32 1, !"amdhsa_code_object_version", i32 500}