brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.9 KiB · afb289b Raw
216 lines · plain
1; RUN:  llc -amdgpu-scalarize-global-loads=false  -mtriple=amdgcn < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s2 3declare i32 @llvm.amdgcn.workitem.id.x() nounwind readnone4 5; Make sure we don't turn the 32-bit argument load into a 16-bit6; load. There aren't extending scalar lods, so that would require7; using a buffer_load instruction.8 9; FUNC-LABEL: {{^}}truncate_kernarg_i32_to_i16:10; SI: s_load_dword s11; SI: buffer_store_short v12define amdgpu_kernel void @truncate_kernarg_i32_to_i16(ptr addrspace(1) %out, i32 %arg) nounwind {13  %trunc = trunc i32 %arg to i1614  store i16 %trunc, ptr addrspace(1) %out15  ret void16}17 18; It should be OK (and probably performance neutral) to reduce this,19; but we don't know if the load is uniform yet.20 21; FUNC-LABEL: {{^}}truncate_buffer_load_i32_to_i16:22; SI: buffer_load_dword v23; SI: buffer_store_short v24define amdgpu_kernel void @truncate_buffer_load_i32_to_i16(ptr addrspace(1) %out, ptr addrspace(1) %in) nounwind {25  %tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone26  %gep.in = getelementptr i32, ptr addrspace(1) %in, i32 %tid27  %gep.out = getelementptr i16, ptr addrspace(1) %out, i32 %tid28  %load = load i32, ptr addrspace(1) %gep.in29  %trunc = trunc i32 %load to i1630  store i16 %trunc, ptr addrspace(1) %gep.out31  ret void32}33 34; FUNC-LABEL: {{^}}truncate_kernarg_i32_to_i8:35; SI: s_load_dword s36; SI: buffer_store_byte v37define amdgpu_kernel void @truncate_kernarg_i32_to_i8(ptr addrspace(1) %out, i32 %arg) nounwind {38  %trunc = trunc i32 %arg to i839  store i8 %trunc, ptr addrspace(1) %out40  ret void41}42 43; FUNC-LABEL: {{^}}truncate_buffer_load_i32_to_i8:44; SI: buffer_load_dword v45; SI: buffer_store_byte v46define amdgpu_kernel void @truncate_buffer_load_i32_to_i8(ptr addrspace(1) %out, ptr addrspace(1) %in) nounwind {47  %tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone48  %gep.in = getelementptr i32, ptr addrspace(1) %in, i32 %tid49  %gep.out = getelementptr i8, ptr addrspace(1) %out, i32 %tid50  %load = load i32, ptr addrspace(1) %gep.in51  %trunc = trunc i32 %load to i852  store i8 %trunc, ptr addrspace(1) %gep.out53  ret void54}55 56; FUNC-LABEL: {{^}}truncate_kernarg_i32_to_i1:57; SI: s_load_dword s58; SI: buffer_store_byte v59define amdgpu_kernel void @truncate_kernarg_i32_to_i1(ptr addrspace(1) %out, i32 %arg) nounwind {60  %trunc = trunc i32 %arg to i161  store i1 %trunc, ptr addrspace(1) %out62  ret void63}64 65; FUNC-LABEL: {{^}}truncate_buffer_load_i32_to_i1:66; SI: buffer_load_dword v67; SI: buffer_store_byte v68define amdgpu_kernel void @truncate_buffer_load_i32_to_i1(ptr addrspace(1) %out, ptr addrspace(1) %in) nounwind {69  %tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone70  %gep.in = getelementptr i32, ptr addrspace(1) %in, i32 %tid71  %gep.out = getelementptr i1, ptr addrspace(1) %out, i32 %tid72  %load = load i32, ptr addrspace(1) %gep.in73  %trunc = trunc i32 %load to i174  store i1 %trunc, ptr addrspace(1) %gep.out75  ret void76}77 78; FUNC-LABEL: {{^}}truncate_kernarg_i64_to_i32:79; SI: s_load_dword s80; SI: buffer_store_dword v81define amdgpu_kernel void @truncate_kernarg_i64_to_i32(ptr addrspace(1) %out, [8 x i32], i64 %arg) nounwind {82  %trunc = trunc i64 %arg to i3283  store i32 %trunc, ptr addrspace(1) %out84  ret void85}86 87; FUNC-LABEL: {{^}}truncate_buffer_load_i64_to_i32:88; SI: buffer_load_dword v89; SI: buffer_store_dword v90define amdgpu_kernel void @truncate_buffer_load_i64_to_i32(ptr addrspace(1) %out, ptr addrspace(1) %in) nounwind {91  %tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone92  %gep.in = getelementptr i64, ptr addrspace(1) %in, i32 %tid93  %gep.out = getelementptr i32, ptr addrspace(1) %out, i32 %tid94  %load = load i64, ptr addrspace(1) %gep.in95  %trunc = trunc i64 %load to i3296  store i32 %trunc, ptr addrspace(1) %gep.out97  ret void98}99 100; FUNC-LABEL: {{^}}srl_kernarg_i64_to_i32:101; SI: s_load_dword s102; SI: buffer_store_dword v103define amdgpu_kernel void @srl_kernarg_i64_to_i32(ptr addrspace(1) %out, [8 x i32], i64 %arg) nounwind {104  %srl = lshr i64 %arg, 32105  %trunc = trunc i64 %srl to i32106  store i32 %trunc, ptr addrspace(1) %out107  ret void108}109 110; FUNC-LABEL: {{^}}srl_buffer_load_i64_to_i32:111; SI: buffer_load_dword v112; SI: buffer_store_dword v113define amdgpu_kernel void @srl_buffer_load_i64_to_i32(ptr addrspace(1) %out, ptr addrspace(1) %in) nounwind {114  %tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone115  %gep.in = getelementptr i64, ptr addrspace(1) %in, i32 %tid116  %gep.out = getelementptr i32, ptr addrspace(1) %out, i32 %tid117  %load = load i64, ptr addrspace(1) %gep.in118  %srl = lshr i64 %load, 32119  %trunc = trunc i64 %srl to i32120  store i32 %trunc, ptr addrspace(1) %gep.out121  ret void122}123 124; Might as well reduce to 8-bit loads.125; FUNC-LABEL: {{^}}truncate_kernarg_i16_to_i8:126; SI: s_load_dword s127; SI: buffer_store_byte v128define amdgpu_kernel void @truncate_kernarg_i16_to_i8(ptr addrspace(1) %out, i16 %arg) nounwind {129  %trunc = trunc i16 %arg to i8130  store i8 %trunc, ptr addrspace(1) %out131  ret void132}133 134; FUNC-LABEL: {{^}}truncate_buffer_load_i16_to_i8:135; SI: buffer_load_ubyte v136; SI: buffer_store_byte v137define amdgpu_kernel void @truncate_buffer_load_i16_to_i8(ptr addrspace(1) %out, ptr addrspace(1) %in) nounwind {138  %tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone139  %gep.in = getelementptr i16, ptr addrspace(1) %in, i32 %tid140  %gep.out = getelementptr i8, ptr addrspace(1) %out, i32 %tid141  %load = load i16, ptr addrspace(1) %gep.in142  %trunc = trunc i16 %load to i8143  store i8 %trunc, ptr addrspace(1) %gep.out144  ret void145}146 147; FUNC-LABEL: {{^}}srl_kernarg_i64_to_i8:148; SI: s_load_dword s149; SI: buffer_store_byte v150define amdgpu_kernel void @srl_kernarg_i64_to_i8(ptr addrspace(1) %out, [8 x i32], i64 %arg) nounwind {151  %srl = lshr i64 %arg, 32152  %trunc = trunc i64 %srl to i8153  store i8 %trunc, ptr addrspace(1) %out154  ret void155}156 157; FUNC-LABEL: {{^}}srl_buffer_load_i64_to_i8:158; SI: buffer_load_dword v159; SI: buffer_store_byte v160define amdgpu_kernel void @srl_buffer_load_i64_to_i8(ptr addrspace(1) %out, ptr addrspace(1) %in) nounwind {161  %tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone162  %gep.in = getelementptr i64, ptr addrspace(1) %in, i32 %tid163  %gep.out = getelementptr i8, ptr addrspace(1) %out, i32 %tid164  %load = load i64, ptr addrspace(1) %gep.in165  %srl = lshr i64 %load, 32166  %trunc = trunc i64 %srl to i8167  store i8 %trunc, ptr addrspace(1) %gep.out168  ret void169}170 171; FUNC-LABEL: {{^}}truncate_kernarg_i64_to_i8:172; SI: s_load_dword s173; SI: buffer_store_byte v174define amdgpu_kernel void @truncate_kernarg_i64_to_i8(ptr addrspace(1) %out, [8 x i32], i64 %arg) nounwind {175  %trunc = trunc i64 %arg to i8176  store i8 %trunc, ptr addrspace(1) %out177  ret void178}179 180; FUNC-LABEL: {{^}}truncate_buffer_load_i64_to_i8:181; SI: buffer_load_dword v182; SI: buffer_store_byte v183define amdgpu_kernel void @truncate_buffer_load_i64_to_i8(ptr addrspace(1) %out, ptr addrspace(1) %in) nounwind {184  %tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone185  %gep.in = getelementptr i64, ptr addrspace(1) %in, i32 %tid186  %gep.out = getelementptr i8, ptr addrspace(1) %out, i32 %tid187  %load = load i64, ptr addrspace(1) %gep.in188  %trunc = trunc i64 %load to i8189  store i8 %trunc, ptr addrspace(1) %gep.out190  ret void191}192 193; FUNC-LABEL: {{^}}smrd_mask_i32_to_i16194; SI: s_load_dword [[LOAD:s[0-9]+]], s[{{[0-9]+}}:{{[0-9]+}}], 0x0195; SI: s_waitcnt lgkmcnt(0)196; SI: s_and_b32 s{{[0-9]+}}, [[LOAD]], 0xffff197define amdgpu_kernel void @smrd_mask_i32_to_i16(ptr addrspace(1) %out, ptr addrspace(4) %in) {198entry:199  %val = load i32, ptr addrspace(4) %in200  %mask = and i32 %val, 65535201  store i32 %mask, ptr addrspace(1) %out202  ret void203}204 205; FUNC-LABEL: {{^}}extract_hi_i64_bitcast_v2i32:206; SI: buffer_load_dword v207; SI: buffer_store_dword v208define amdgpu_kernel void @extract_hi_i64_bitcast_v2i32(ptr addrspace(1) %out, ptr addrspace(1) %in) nounwind {209  %ld = load <2 x i32>, ptr addrspace(1) %in210  %bc = bitcast <2 x i32> %ld to i64211  %hi = lshr i64 %bc, 32212  %trunc = trunc i64 %hi to i32213  store i32 %trunc, ptr addrspace(1) %out214  ret void215}216