1 ; RUN: llc -mtriple=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=SI %s
4 declare i32 @llvm.amdgcn.workitem.id.x() readnone
6 ; SI-LABEL: {{^}}test_i64_vreg:
9 define amdgpu_kernel void @test_i64_vreg(ptr addrspace(1) noalias %out, ptr addrspace(1) noalias %inA, ptr addrspace(1) noalias %inB) {
10 %tid = call i32 @llvm.amdgcn.workitem.id.x() readnone
11 %a_ptr = getelementptr i64, ptr addrspace(1) %inA, i32 %tid
12 %b_ptr = getelementptr i64, ptr addrspace(1) %inB, i32 %tid
13 %a = load i64, ptr addrspace(1) %a_ptr
14 %b = load i64, ptr addrspace(1) %b_ptr
15 %result = add i64 %a, %b
16 store i64 %result, ptr addrspace(1) %out
20 ; Check that the SGPR add operand is correctly moved to a VGPR.
21 ; SI-LABEL: {{^}}sgpr_operand:
24 define amdgpu_kernel void @sgpr_operand(ptr addrspace(1) noalias %out, ptr addrspace(1) noalias %in, ptr addrspace(1) noalias %in_bar, i64 %a) {
25 %foo = load i64, ptr addrspace(1) %in, align 8
26 %result = add i64 %foo, %a
27 store i64 %result, ptr addrspace(1) %out
31 ; Swap the arguments. Check that the SGPR -> VGPR copy works with the
32 ; SGPR as other operand.
34 ; SI-LABEL: {{^}}sgpr_operand_reversed:
37 define amdgpu_kernel void @sgpr_operand_reversed(ptr addrspace(1) noalias %out, ptr addrspace(1) noalias %in, i64 %a) {
38 %foo = load i64, ptr addrspace(1) %in, align 8
39 %result = add i64 %a, %foo
40 store i64 %result, ptr addrspace(1) %out
45 ; SI-LABEL: {{^}}test_v2i64_sreg:
50 define amdgpu_kernel void @test_v2i64_sreg(ptr addrspace(1) noalias %out, <2 x i64> %a, <2 x i64> %b) {
51 %result = add <2 x i64> %a, %b
52 store <2 x i64> %result, ptr addrspace(1) %out
56 ; SI-LABEL: {{^}}test_v2i64_vreg:
61 define amdgpu_kernel void @test_v2i64_vreg(ptr addrspace(1) noalias %out, ptr addrspace(1) noalias %inA, ptr addrspace(1) noalias %inB) {
62 %tid = call i32 @llvm.amdgcn.workitem.id.x() readnone
63 %a_ptr = getelementptr <2 x i64>, ptr addrspace(1) %inA, i32 %tid
64 %b_ptr = getelementptr <2 x i64>, ptr addrspace(1) %inB, i32 %tid
65 %a = load <2 x i64>, ptr addrspace(1) %a_ptr
66 %b = load <2 x i64>, ptr addrspace(1) %b_ptr
67 %result = add <2 x i64> %a, %b
68 store <2 x i64> %result, ptr addrspace(1) %out
72 ; SI-LABEL: {{^}}trunc_i64_add_to_i32:
73 ; SI: s_load_dword s[[SREG0:[0-9]+]]
74 ; SI: s_load_dword s[[SREG1:[0-9]+]]
75 ; SI: s_add_i32 [[SRESULT:s[0-9]+]], s[[SREG1]], s[[SREG0]]
77 ; SI: v_mov_b32_e32 [[VRESULT:v[0-9]+]], [[SRESULT]]
78 ; SI: buffer_store_dword [[VRESULT]],
79 define amdgpu_kernel void @trunc_i64_add_to_i32(ptr addrspace(1) %out, i32, i64 %a, i32, i64 %b) {
81 %trunc = trunc i64 %add to i32
82 store i32 %trunc, ptr addrspace(1) %out, align 8