1 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -o - %s | FileCheck %s
2 ; RUN: llc -global-isel -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -o - %s | FileCheck %s
4 ; Test that a null check is not emitted for lowered addrspacecast
7 define void @flat_user(ptr %ptr) {
12 ; CHECK-LABEL: {{^}}cast_alloca:
13 ; CHECK: s_mov_b64 s[{{[0-9]+}}:[[HIREG:[0-9]+]]], src_private_base
14 ; CHECK: v_mov_b32_e32 v1, s[[HIREG]]
17 define void @cast_alloca() {
18 %alloca = alloca i8, addrspace(5)
19 %cast = addrspacecast ptr addrspace(5) %alloca to ptr
20 call void @flat_user(ptr %cast)
24 @lds = internal unnamed_addr addrspace(3) global i8 undef, align 4
26 ; CHECK-LABEL: {{^}}cast_lds_gv:
27 ; CHECK: s_mov_b64 s[{{[0-9]+}}:[[HIREG:[0-9]+]]], src_shared_base
28 ; CHECK: v_mov_b32_e32 v0, 0
29 ; CHECK: v_mov_b32_e32 v1, s[[HIREG]]
32 define amdgpu_kernel void @cast_lds_gv() {
33 %cast = addrspacecast ptr addrspace(3) @lds to ptr
34 call void @flat_user(ptr %cast)
38 ; CHECK-LABEL: {{^}}cast_constant_lds_neg1_gv:
39 ; CHECK: v_mov_b32_e32 v0, 0
40 ; CHECK: v_mov_b32_e32 v1, 0
41 define void @cast_constant_lds_neg1_gv() {
42 call void @flat_user(ptr addrspacecast (ptr addrspace(3) inttoptr (i32 -1 to ptr addrspace(3)) to ptr))
46 ; CHECK-LABEL: {{^}}cast_constant_private_neg1_gv:
47 ; CHECK: v_mov_b32_e32 v0, 0
48 ; CHECK: v_mov_b32_e32 v1, 0
49 define void @cast_constant_private_neg1_gv() {
50 call void @flat_user(ptr addrspacecast (ptr addrspace(5) inttoptr (i32 -1 to ptr addrspace(5)) to ptr))
54 ; CHECK-LABEL: {{^}}cast_constant_lds_other_gv:
55 ; CHECK: s_mov_b64 s[{{[0-9]+}}:[[HIREG:[0-9]+]]], src_shared_base
56 ; CHECK: v_mov_b32_e32 v0, 0x7b
57 ; CHECK: v_mov_b32_e32 v1, s[[HIREG]]
58 define void @cast_constant_lds_other_gv() {
59 call void @flat_user(ptr addrspacecast (ptr addrspace(3) inttoptr (i32 123 to ptr addrspace(3)) to ptr))
63 ; CHECK-LABEL: {{^}}cast_constant_private_other_gv:
64 ; CHECK: s_mov_b64 s[{{[0-9]+}}:[[HIREG:[0-9]+]]], src_private_base
65 ; CHECK: v_mov_b32_e32 v0, 0x7b
66 ; CHECK: v_mov_b32_e32 v1, s[[HIREG]]
67 define void @cast_constant_private_other_gv() {
68 call void @flat_user(ptr addrspacecast (ptr addrspace(5) inttoptr (i32 123 to ptr addrspace(5)) to ptr))