1*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=amdgcn -mcpu=SI -verify-machineinstrs< %s | FileCheck --check-prefix=SI --check-prefix=BOTH %s 2*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=amdgcn -mcpu=bonaire -verify-machineinstrs< %s | FileCheck --check-prefix=CI --check-prefix=BOTH %s 3*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs< %s | FileCheck --check-prefix=CI --check-prefix=BOTH %s 4*9880d681SAndroid Build Coastguard Worker 5*9880d681SAndroid Build Coastguard Worker; BOTH-LABEL: {{^}}local_i32_load 6*9880d681SAndroid Build Coastguard Worker; BOTH: ds_read_b32 [[REG:v[0-9]+]], v{{[0-9]+}} offset:28 7*9880d681SAndroid Build Coastguard Worker; BOTH: buffer_store_dword [[REG]], 8*9880d681SAndroid Build Coastguard Workerdefine void @local_i32_load(i32 addrspace(1)* %out, i32 addrspace(3)* %in) nounwind { 9*9880d681SAndroid Build Coastguard Worker %gep = getelementptr i32, i32 addrspace(3)* %in, i32 7 10*9880d681SAndroid Build Coastguard Worker %val = load i32, i32 addrspace(3)* %gep, align 4 11*9880d681SAndroid Build Coastguard Worker store i32 %val, i32 addrspace(1)* %out, align 4 12*9880d681SAndroid Build Coastguard Worker ret void 13*9880d681SAndroid Build Coastguard Worker} 14*9880d681SAndroid Build Coastguard Worker 15*9880d681SAndroid Build Coastguard Worker; BOTH-LABEL: {{^}}local_i32_load_0_offset 16*9880d681SAndroid Build Coastguard Worker; BOTH: ds_read_b32 [[REG:v[0-9]+]], v{{[0-9]+}} 17*9880d681SAndroid Build Coastguard Worker; BOTH: buffer_store_dword [[REG]], 18*9880d681SAndroid Build Coastguard Workerdefine void @local_i32_load_0_offset(i32 addrspace(1)* %out, i32 addrspace(3)* %in) nounwind { 19*9880d681SAndroid Build Coastguard Worker %val = load i32, i32 addrspace(3)* %in, align 4 20*9880d681SAndroid Build Coastguard Worker store i32 %val, i32 addrspace(1)* %out, align 4 21*9880d681SAndroid Build Coastguard Worker ret void 22*9880d681SAndroid Build Coastguard Worker} 23*9880d681SAndroid Build Coastguard Worker 24*9880d681SAndroid Build Coastguard Worker; BOTH-LABEL: {{^}}local_i8_load_i16_max_offset: 25*9880d681SAndroid Build Coastguard Worker; BOTH-NOT: ADD 26*9880d681SAndroid Build Coastguard Worker; BOTH: ds_read_u8 [[REG:v[0-9]+]], {{v[0-9]+}} offset:65535 27*9880d681SAndroid Build Coastguard Worker; BOTH: buffer_store_byte [[REG]], 28*9880d681SAndroid Build Coastguard Workerdefine void @local_i8_load_i16_max_offset(i8 addrspace(1)* %out, i8 addrspace(3)* %in) nounwind { 29*9880d681SAndroid Build Coastguard Worker %gep = getelementptr i8, i8 addrspace(3)* %in, i32 65535 30*9880d681SAndroid Build Coastguard Worker %val = load i8, i8 addrspace(3)* %gep, align 4 31*9880d681SAndroid Build Coastguard Worker store i8 %val, i8 addrspace(1)* %out, align 4 32*9880d681SAndroid Build Coastguard Worker ret void 33*9880d681SAndroid Build Coastguard Worker} 34*9880d681SAndroid Build Coastguard Worker 35*9880d681SAndroid Build Coastguard Worker; BOTH-LABEL: {{^}}local_i8_load_over_i16_max_offset: 36*9880d681SAndroid Build Coastguard Worker; The LDS offset will be 65536 bytes, which is larger than the size of LDS on 37*9880d681SAndroid Build Coastguard Worker; SI, which is why it is being OR'd with the base pointer. 38*9880d681SAndroid Build Coastguard Worker; SI: s_or_b32 [[ADDR:s[0-9]+]], s{{[0-9]+}}, 0x10000 39*9880d681SAndroid Build Coastguard Worker; CI: s_add_i32 [[ADDR:s[0-9]+]], s{{[0-9]+}}, 0x10000 40*9880d681SAndroid Build Coastguard Worker; BOTH: v_mov_b32_e32 [[VREGADDR:v[0-9]+]], [[ADDR]] 41*9880d681SAndroid Build Coastguard Worker; BOTH: ds_read_u8 [[REG:v[0-9]+]], [[VREGADDR]] 42*9880d681SAndroid Build Coastguard Worker; BOTH: buffer_store_byte [[REG]], 43*9880d681SAndroid Build Coastguard Workerdefine void @local_i8_load_over_i16_max_offset(i8 addrspace(1)* %out, i8 addrspace(3)* %in) nounwind { 44*9880d681SAndroid Build Coastguard Worker %gep = getelementptr i8, i8 addrspace(3)* %in, i32 65536 45*9880d681SAndroid Build Coastguard Worker %val = load i8, i8 addrspace(3)* %gep, align 4 46*9880d681SAndroid Build Coastguard Worker store i8 %val, i8 addrspace(1)* %out, align 4 47*9880d681SAndroid Build Coastguard Worker ret void 48*9880d681SAndroid Build Coastguard Worker} 49*9880d681SAndroid Build Coastguard Worker 50*9880d681SAndroid Build Coastguard Worker; BOTH-LABEL: {{^}}local_i64_load: 51*9880d681SAndroid Build Coastguard Worker; BOTH-NOT: ADD 52*9880d681SAndroid Build Coastguard Worker; BOTH: ds_read_b64 [[REG:v[[0-9]+:[0-9]+]]], v{{[0-9]+}} offset:56 53*9880d681SAndroid Build Coastguard Worker; BOTH: buffer_store_dwordx2 [[REG]], 54*9880d681SAndroid Build Coastguard Workerdefine void @local_i64_load(i64 addrspace(1)* %out, i64 addrspace(3)* %in) nounwind { 55*9880d681SAndroid Build Coastguard Worker %gep = getelementptr i64, i64 addrspace(3)* %in, i32 7 56*9880d681SAndroid Build Coastguard Worker %val = load i64, i64 addrspace(3)* %gep, align 8 57*9880d681SAndroid Build Coastguard Worker store i64 %val, i64 addrspace(1)* %out, align 8 58*9880d681SAndroid Build Coastguard Worker ret void 59*9880d681SAndroid Build Coastguard Worker} 60*9880d681SAndroid Build Coastguard Worker 61*9880d681SAndroid Build Coastguard Worker; BOTH-LABEL: {{^}}local_i64_load_0_offset 62*9880d681SAndroid Build Coastguard Worker; BOTH: ds_read_b64 [[REG:v\[[0-9]+:[0-9]+\]]], v{{[0-9]+}} 63*9880d681SAndroid Build Coastguard Worker; BOTH: buffer_store_dwordx2 [[REG]], 64*9880d681SAndroid Build Coastguard Workerdefine void @local_i64_load_0_offset(i64 addrspace(1)* %out, i64 addrspace(3)* %in) nounwind { 65*9880d681SAndroid Build Coastguard Worker %val = load i64, i64 addrspace(3)* %in, align 8 66*9880d681SAndroid Build Coastguard Worker store i64 %val, i64 addrspace(1)* %out, align 8 67*9880d681SAndroid Build Coastguard Worker ret void 68*9880d681SAndroid Build Coastguard Worker} 69*9880d681SAndroid Build Coastguard Worker 70*9880d681SAndroid Build Coastguard Worker; BOTH-LABEL: {{^}}local_f64_load: 71*9880d681SAndroid Build Coastguard Worker; BOTH-NOT: ADD 72*9880d681SAndroid Build Coastguard Worker; BOTH: ds_read_b64 [[REG:v[[0-9]+:[0-9]+]]], v{{[0-9]+}} offset:56 73*9880d681SAndroid Build Coastguard Worker; BOTH: buffer_store_dwordx2 [[REG]], 74*9880d681SAndroid Build Coastguard Workerdefine void @local_f64_load(double addrspace(1)* %out, double addrspace(3)* %in) nounwind { 75*9880d681SAndroid Build Coastguard Worker %gep = getelementptr double, double addrspace(3)* %in, i32 7 76*9880d681SAndroid Build Coastguard Worker %val = load double, double addrspace(3)* %gep, align 8 77*9880d681SAndroid Build Coastguard Worker store double %val, double addrspace(1)* %out, align 8 78*9880d681SAndroid Build Coastguard Worker ret void 79*9880d681SAndroid Build Coastguard Worker} 80*9880d681SAndroid Build Coastguard Worker 81*9880d681SAndroid Build Coastguard Worker; BOTH-LABEL: {{^}}local_f64_load_0_offset 82*9880d681SAndroid Build Coastguard Worker; BOTH: ds_read_b64 [[REG:v\[[0-9]+:[0-9]+\]]], v{{[0-9]+}} 83*9880d681SAndroid Build Coastguard Worker; BOTH: buffer_store_dwordx2 [[REG]], 84*9880d681SAndroid Build Coastguard Workerdefine void @local_f64_load_0_offset(double addrspace(1)* %out, double addrspace(3)* %in) nounwind { 85*9880d681SAndroid Build Coastguard Worker %val = load double, double addrspace(3)* %in, align 8 86*9880d681SAndroid Build Coastguard Worker store double %val, double addrspace(1)* %out, align 8 87*9880d681SAndroid Build Coastguard Worker ret void 88*9880d681SAndroid Build Coastguard Worker} 89*9880d681SAndroid Build Coastguard Worker 90*9880d681SAndroid Build Coastguard Worker; BOTH-LABEL: {{^}}local_i64_store: 91*9880d681SAndroid Build Coastguard Worker; BOTH-NOT: ADD 92*9880d681SAndroid Build Coastguard Worker; BOTH: ds_write_b64 v{{[0-9]+}}, {{v\[[0-9]+:[0-9]+\]}} offset:56 93*9880d681SAndroid Build Coastguard Workerdefine void @local_i64_store(i64 addrspace(3)* %out) nounwind { 94*9880d681SAndroid Build Coastguard Worker %gep = getelementptr i64, i64 addrspace(3)* %out, i32 7 95*9880d681SAndroid Build Coastguard Worker store i64 5678, i64 addrspace(3)* %gep, align 8 96*9880d681SAndroid Build Coastguard Worker ret void 97*9880d681SAndroid Build Coastguard Worker} 98*9880d681SAndroid Build Coastguard Worker 99*9880d681SAndroid Build Coastguard Worker; BOTH-LABEL: {{^}}local_i64_store_0_offset: 100*9880d681SAndroid Build Coastguard Worker; BOTH-NOT: ADD 101*9880d681SAndroid Build Coastguard Worker; BOTH: ds_write_b64 v{{[0-9]+}}, {{v\[[0-9]+:[0-9]+\]}} 102*9880d681SAndroid Build Coastguard Workerdefine void @local_i64_store_0_offset(i64 addrspace(3)* %out) nounwind { 103*9880d681SAndroid Build Coastguard Worker store i64 1234, i64 addrspace(3)* %out, align 8 104*9880d681SAndroid Build Coastguard Worker ret void 105*9880d681SAndroid Build Coastguard Worker} 106*9880d681SAndroid Build Coastguard Worker 107*9880d681SAndroid Build Coastguard Worker; BOTH-LABEL: {{^}}local_f64_store: 108*9880d681SAndroid Build Coastguard Worker; BOTH-NOT: ADD 109*9880d681SAndroid Build Coastguard Worker; BOTH: ds_write_b64 v{{[0-9]+}}, {{v\[[0-9]+:[0-9]+\]}} offset:56 110*9880d681SAndroid Build Coastguard Workerdefine void @local_f64_store(double addrspace(3)* %out) nounwind { 111*9880d681SAndroid Build Coastguard Worker %gep = getelementptr double, double addrspace(3)* %out, i32 7 112*9880d681SAndroid Build Coastguard Worker store double 16.0, double addrspace(3)* %gep, align 8 113*9880d681SAndroid Build Coastguard Worker ret void 114*9880d681SAndroid Build Coastguard Worker} 115*9880d681SAndroid Build Coastguard Worker 116*9880d681SAndroid Build Coastguard Worker; BOTH-LABEL: {{^}}local_f64_store_0_offset 117*9880d681SAndroid Build Coastguard Worker; BOTH: ds_write_b64 v{{[0-9]+}}, {{v\[[0-9]+:[0-9]+\]}} 118*9880d681SAndroid Build Coastguard Workerdefine void @local_f64_store_0_offset(double addrspace(3)* %out) nounwind { 119*9880d681SAndroid Build Coastguard Worker store double 20.0, double addrspace(3)* %out, align 8 120*9880d681SAndroid Build Coastguard Worker ret void 121*9880d681SAndroid Build Coastguard Worker} 122*9880d681SAndroid Build Coastguard Worker 123*9880d681SAndroid Build Coastguard Worker; BOTH-LABEL: {{^}}local_v2i64_store: 124*9880d681SAndroid Build Coastguard Worker; BOTH-NOT: ADD 125*9880d681SAndroid Build Coastguard Worker; BOTH: ds_write2_b64 v{{[0-9]+}}, {{v\[[0-9]+:[0-9]+\]}}, {{v\[[0-9]+:[0-9]+\]}} offset0:15 offset1:14 126*9880d681SAndroid Build Coastguard Worker; BOTH: s_endpgm 127*9880d681SAndroid Build Coastguard Workerdefine void @local_v2i64_store(<2 x i64> addrspace(3)* %out) nounwind { 128*9880d681SAndroid Build Coastguard Worker %gep = getelementptr <2 x i64>, <2 x i64> addrspace(3)* %out, i32 7 129*9880d681SAndroid Build Coastguard Worker store <2 x i64> <i64 5678, i64 5678>, <2 x i64> addrspace(3)* %gep, align 16 130*9880d681SAndroid Build Coastguard Worker ret void 131*9880d681SAndroid Build Coastguard Worker} 132*9880d681SAndroid Build Coastguard Worker 133*9880d681SAndroid Build Coastguard Worker; BOTH-LABEL: {{^}}local_v2i64_store_0_offset: 134*9880d681SAndroid Build Coastguard Worker; BOTH-NOT: ADD 135*9880d681SAndroid Build Coastguard Worker; BOTH: ds_write2_b64 v{{[0-9]+}}, {{v\[[0-9]+:[0-9]+\]}}, {{v\[[0-9]+:[0-9]+\]}} offset0:1 136*9880d681SAndroid Build Coastguard Worker; BOTH: s_endpgm 137*9880d681SAndroid Build Coastguard Workerdefine void @local_v2i64_store_0_offset(<2 x i64> addrspace(3)* %out) nounwind { 138*9880d681SAndroid Build Coastguard Worker store <2 x i64> <i64 1234, i64 1234>, <2 x i64> addrspace(3)* %out, align 16 139*9880d681SAndroid Build Coastguard Worker ret void 140*9880d681SAndroid Build Coastguard Worker} 141*9880d681SAndroid Build Coastguard Worker 142*9880d681SAndroid Build Coastguard Worker; BOTH-LABEL: {{^}}local_v4i64_store: 143*9880d681SAndroid Build Coastguard Worker; BOTH-NOT: ADD 144*9880d681SAndroid Build Coastguard Worker; BOTH-DAG: ds_write2_b64 v{{[0-9]+}}, {{v\[[0-9]+:[0-9]+\]}}, {{v\[[0-9]+:[0-9]+\]}} offset0:31 offset1:30 145*9880d681SAndroid Build Coastguard Worker; BOTH-DAG: ds_write2_b64 v{{[0-9]+}}, {{v\[[0-9]+:[0-9]+\]}}, {{v\[[0-9]+:[0-9]+\]}} offset0:29 offset1:28 146*9880d681SAndroid Build Coastguard Worker; BOTH: s_endpgm 147*9880d681SAndroid Build Coastguard Workerdefine void @local_v4i64_store(<4 x i64> addrspace(3)* %out) nounwind { 148*9880d681SAndroid Build Coastguard Worker %gep = getelementptr <4 x i64>, <4 x i64> addrspace(3)* %out, i32 7 149*9880d681SAndroid Build Coastguard Worker store <4 x i64> <i64 5678, i64 5678, i64 5678, i64 5678>, <4 x i64> addrspace(3)* %gep, align 16 150*9880d681SAndroid Build Coastguard Worker ret void 151*9880d681SAndroid Build Coastguard Worker} 152*9880d681SAndroid Build Coastguard Worker 153*9880d681SAndroid Build Coastguard Worker; BOTH-LABEL: {{^}}local_v4i64_store_0_offset: 154*9880d681SAndroid Build Coastguard Worker; BOTH-NOT: ADD 155*9880d681SAndroid Build Coastguard Worker; BOTH-DAG: ds_write2_b64 v{{[0-9]+}}, {{v\[[0-9]+:[0-9]+\]}}, {{v\[[0-9]+:[0-9]+\]}} offset0:3 offset1:2 156*9880d681SAndroid Build Coastguard Worker; BOTH-DAG: ds_write2_b64 v{{[0-9]+}}, {{v\[[0-9]+:[0-9]+\]}}, {{v\[[0-9]+:[0-9]+\]}} offset0:1 157*9880d681SAndroid Build Coastguard Worker; BOTH: s_endpgm 158*9880d681SAndroid Build Coastguard Workerdefine void @local_v4i64_store_0_offset(<4 x i64> addrspace(3)* %out) nounwind { 159*9880d681SAndroid Build Coastguard Worker store <4 x i64> <i64 1234, i64 1234, i64 1234, i64 1234>, <4 x i64> addrspace(3)* %out, align 16 160*9880d681SAndroid Build Coastguard Worker ret void 161*9880d681SAndroid Build Coastguard Worker} 162