1 ; RUN: llc < %s -march=r600 -mcpu=verde -verify-machineinstrs | FileCheck %s 2 3 ; On Southern Islands GPUs the local address space(3) uses 32-bit pointers and 4 ; the global address space(1) uses 64-bit pointers. These tests check to make sure 5 ; the correct pointer size is used for the local address space. 6 7 ; The e{{32|64}} suffix on the instructions refers to the encoding size and not 8 ; the size of the operands. The operand size is denoted in the instruction name. 9 ; Instructions with B32, U32, and I32 in their name take 32-bit operands, while 10 ; instructions with B64, U64, and I64 take 64-bit operands. 11 12 ; CHECK-LABEL: @local_address_load 13 ; CHECK: V_MOV_B32_e{{32|64}} [[PTR:v[0-9]]] 14 ; CHECK: DS_READ_B32 v{{[0-9]+}}, [[PTR]] 15 define void @local_address_load(i32 addrspace(1)* %out, i32 addrspace(3)* %in) { 16 entry: 17 %0 = load i32 addrspace(3)* %in 18 store i32 %0, i32 addrspace(1)* %out 19 ret void 20 } 21 22 ; CHECK-LABEL: @local_address_gep 23 ; CHECK: S_ADD_I32 [[SPTR:s[0-9]]] 24 ; CHECK: V_MOV_B32_e32 [[VPTR:v[0-9]+]], [[SPTR]] 25 ; CHECK: DS_READ_B32 [[VPTR]] 26 define void @local_address_gep(i32 addrspace(1)* %out, i32 addrspace(3)* %in, i32 %offset) { 27 entry: 28 %0 = getelementptr i32 addrspace(3)* %in, i32 %offset 29 %1 = load i32 addrspace(3)* %0 30 store i32 %1, i32 addrspace(1)* %out 31 ret void 32 } 33 34 ; CHECK-LABEL: @local_address_gep_const_offset 35 ; CHECK: V_MOV_B32_e32 [[VPTR:v[0-9]+]], s{{[0-9]+}} 36 ; CHECK: DS_READ_B32 v{{[0-9]+}}, [[VPTR]], 0x4, 37 define void @local_address_gep_const_offset(i32 addrspace(1)* %out, i32 addrspace(3)* %in) { 38 entry: 39 %0 = getelementptr i32 addrspace(3)* %in, i32 1 40 %1 = load i32 addrspace(3)* %0 41 store i32 %1, i32 addrspace(1)* %out 42 ret void 43 } 44 45 ; Offset too large, can't fold into 16-bit immediate offset. 46 ; CHECK-LABEL: @local_address_gep_large_const_offset 47 ; CHECK: S_ADD_I32 [[SPTR:s[0-9]]], s{{[0-9]+}}, 0x10004 48 ; CHECK: V_MOV_B32_e32 [[VPTR:v[0-9]+]], [[SPTR]] 49 ; CHECK: DS_READ_B32 [[VPTR]] 50 define void @local_address_gep_large_const_offset(i32 addrspace(1)* %out, i32 addrspace(3)* %in) { 51 entry: 52 %0 = getelementptr i32 addrspace(3)* %in, i32 16385 53 %1 = load i32 addrspace(3)* %0 54 store i32 %1, i32 addrspace(1)* %out 55 ret void 56 } 57 58 ; CHECK-LABEL: @null_32bit_lds_ptr: 59 ; CHECK: V_CMP_NE_I32 60 ; CHECK-NOT: V_CMP_NE_I32 61 ; CHECK: V_CNDMASK_B32 62 define void @null_32bit_lds_ptr(i32 addrspace(1)* %out, i32 addrspace(3)* %lds) nounwind { 63 %cmp = icmp ne i32 addrspace(3)* %lds, null 64 %x = select i1 %cmp, i32 123, i32 456 65 store i32 %x, i32 addrspace(1)* %out 66 ret void 67 } 68 69 ; CHECK-LABEL: @mul_32bit_ptr: 70 ; CHECK: V_MUL_LO_I32 71 ; CHECK-NEXT: V_ADD_I32_e32 72 ; CHECK-NEXT: DS_READ_B32 73 define void @mul_32bit_ptr(float addrspace(1)* %out, [3 x float] addrspace(3)* %lds, i32 %tid) { 74 %ptr = getelementptr [3 x float] addrspace(3)* %lds, i32 %tid, i32 0 75 %val = load float addrspace(3)* %ptr 76 store float %val, float addrspace(1)* %out 77 ret void 78 } 79 80 @g_lds = addrspace(3) global float zeroinitializer, align 4 81 82 ; CHECK-LABEL: @infer_ptr_alignment_global_offset: 83 ; CHECK: V_MOV_B32_e32 [[REG:v[0-9]+]], 0 84 ; CHECK: DS_READ_B32 v{{[0-9]+}}, [[REG]] 85 define void @infer_ptr_alignment_global_offset(float addrspace(1)* %out, i32 %tid) { 86 %val = load float addrspace(3)* @g_lds 87 store float %val, float addrspace(1)* %out 88 ret void 89 } 90 91 92 @ptr = addrspace(3) global i32 addrspace(3)* null 93 @dst = addrspace(3) global [16384 x i32] zeroinitializer 94 95 ; CHECK-LABEL: @global_ptr: 96 ; CHECK: DS_WRITE_B32 97 define void @global_ptr() nounwind { 98 store i32 addrspace(3)* getelementptr ([16384 x i32] addrspace(3)* @dst, i32 0, i32 16), i32 addrspace(3)* addrspace(3)* @ptr 99 ret void 100 } 101 102 ; CHECK-LABEL: @local_address_store 103 ; CHECK: DS_WRITE_B32 104 define void @local_address_store(i32 addrspace(3)* %out, i32 %val) { 105 store i32 %val, i32 addrspace(3)* %out 106 ret void 107 } 108 109 ; CHECK-LABEL: @local_address_gep_store 110 ; CHECK: S_ADD_I32 [[SADDR:s[0-9]+]], 111 ; CHECK: V_MOV_B32_e32 [[ADDR:v[0-9]+]], [[SADDR]] 112 ; CHECK: DS_WRITE_B32 [[ADDR]], v{{[0-9]+}}, 113 define void @local_address_gep_store(i32 addrspace(3)* %out, i32, i32 %val, i32 %offset) { 114 %gep = getelementptr i32 addrspace(3)* %out, i32 %offset 115 store i32 %val, i32 addrspace(3)* %gep, align 4 116 ret void 117 } 118 119 ; CHECK-LABEL: @local_address_gep_const_offset_store 120 ; CHECK: V_MOV_B32_e32 [[VPTR:v[0-9]+]], s{{[0-9]+}} 121 ; CHECK: V_MOV_B32_e32 [[VAL:v[0-9]+]], s{{[0-9]+}} 122 ; CHECK: DS_WRITE_B32 [[VPTR]], [[VAL]], 0x4 123 define void @local_address_gep_const_offset_store(i32 addrspace(3)* %out, i32 %val) { 124 %gep = getelementptr i32 addrspace(3)* %out, i32 1 125 store i32 %val, i32 addrspace(3)* %gep, align 4 126 ret void 127 } 128 129 ; Offset too large, can't fold into 16-bit immediate offset. 130 ; CHECK-LABEL: @local_address_gep_large_const_offset_store 131 ; CHECK: S_ADD_I32 [[SPTR:s[0-9]]], s{{[0-9]+}}, 0x10004 132 ; CHECK: V_MOV_B32_e32 [[VPTR:v[0-9]+]], [[SPTR]] 133 ; CHECK: DS_WRITE_B32 [[VPTR]], v{{[0-9]+}}, 0 134 define void @local_address_gep_large_const_offset_store(i32 addrspace(3)* %out, i32 %val) { 135 %gep = getelementptr i32 addrspace(3)* %out, i32 16385 136 store i32 %val, i32 addrspace(3)* %gep, align 4 137 ret void 138 } 139