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(i8* %ptr) {
12 ; CHECK-LABEL: {{^}}cast_alloca:
13 ; CHECK: s_getreg_b32 [[GETREG:s[0-9]+]], hwreg(HW_REG_SH_MEM_BASES, 0, 16)
14 ; CHECK: s_lshl_b32 [[APERTURE:s[0-9]+]], [[GETREG]], 16
15 ; CHECK: v_lshrrev_b32_e64 v0, 6, s33
16 ; CHECK-NEXT: v_mov_b32_e32 v1, [[APERTURE]]
19 define void @cast_alloca() {
20 %alloca = alloca i8, addrspace(5)
21 %cast = addrspacecast i8 addrspace(5)* %alloca to i8*
22 call void @flat_user(i8* %cast)
26 @lds = internal unnamed_addr addrspace(3) global i8 undef, align 4
28 ; CHECK-LABEL: {{^}}cast_lds_gv:
29 ; CHECK: s_getreg_b32 [[GETREG:s[0-9]+]], hwreg(HW_REG_SH_MEM_BASES, 16, 16)
30 ; CHECK: s_lshl_b32 [[APERTURE:s[0-9]+]], [[GETREG]], 16
31 ; CHECK: v_mov_b32_e32 v0, 0
32 ; CHECK: v_mov_b32_e32 v1, [[APERTURE]]
35 define void @cast_lds_gv() {
36 %cast = addrspacecast i8 addrspace(3)* @lds to i8*
37 call void @flat_user(i8* %cast)
41 ; CHECK-LABEL: {{^}}cast_constant_lds_neg1_gv:
42 ; CHECK: v_mov_b32_e32 v0, 0
43 ; CHECK: v_mov_b32_e32 v1, 0
44 define void @cast_constant_lds_neg1_gv() {
45 call void @flat_user(i8* addrspacecast (i8 addrspace(3)* inttoptr (i32 -1 to i8 addrspace(3)*) to i8*))
49 ; CHECK-LABEL: {{^}}cast_constant_private_neg1_gv:
50 ; CHECK: v_mov_b32_e32 v0, 0
51 ; CHECK: v_mov_b32_e32 v1, 0
52 define void @cast_constant_private_neg1_gv() {
53 call void @flat_user(i8* addrspacecast (i8 addrspace(5)* inttoptr (i32 -1 to i8 addrspace(5)*) to i8*))
57 ; CHECK-LABEL: {{^}}cast_constant_lds_other_gv:
58 ; CHECK: s_getreg_b32 [[GETREG:s[0-9]+]], hwreg(HW_REG_SH_MEM_BASES, 16, 16)
59 ; CHECK: s_lshl_b32 [[APERTURE:s[0-9]+]], [[GETREG]], 16
60 ; CHECK: v_mov_b32_e32 v0, 0x7b
61 ; CHECK: v_mov_b32_e32 v1, [[APERTURE]]
62 define void @cast_constant_lds_other_gv() {
63 call void @flat_user(i8* addrspacecast (i8 addrspace(3)* inttoptr (i32 123 to i8 addrspace(3)*) to i8*))
67 ; CHECK-LABEL: {{^}}cast_constant_private_other_gv:
68 ; CHECK: s_getreg_b32 [[GETREG:s[0-9]+]], hwreg(HW_REG_SH_MEM_BASES, 0, 16)
69 ; CHECK: s_lshl_b32 [[APERTURE:s[0-9]+]], [[GETREG]], 16
70 ; CHECK: v_mov_b32_e32 v0, 0x7b
71 ; CHECK: v_mov_b32_e32 v1, [[APERTURE]]
72 define void @cast_constant_private_other_gv() {
73 call void @flat_user(i8* addrspacecast (i8 addrspace(5)* inttoptr (i32 123 to i8 addrspace(5)*) to i8*))