• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=SI %s
2; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=SI %s
3
4; SI-LABEL: {{^}}s_addk_i32_k0:
5; SI: s_load_dword [[VAL:s[0-9]+]]
6; SI: s_addk_i32 [[VAL]], 0x41
7; SI: v_mov_b32_e32 [[VRESULT:v[0-9]+]], [[VAL]]
8; SI: buffer_store_dword [[VRESULT]]
9; SI: s_endpgm
10define void @s_addk_i32_k0(i32 addrspace(1)* %out, i32 %b) {
11  %add = add i32 %b, 65
12  store i32 %add, i32 addrspace(1)* %out
13  ret void
14}
15
16; FIXME: This should be folded with any number of uses.
17; SI-LABEL: {{^}}s_addk_i32_k0_x2:
18; SI: s_movk_i32 [[K:s[0-9]+]], 0x41
19; SI-DAG: s_add_i32 {{s[0-9]+}}, {{s[0-9]+}}, [[K]]
20; SI-DAG: s_add_i32 {{s[0-9]+}}, {{s[0-9]+}}, [[K]]
21; SI: s_endpgm
22define void @s_addk_i32_k0_x2(i32 addrspace(1)* %out0, i32 addrspace(1)* %out1, i32 %a, i32 %b) {
23  %add0 = add i32 %a, 65
24  %add1 = add i32 %b, 65
25  store i32 %add0, i32 addrspace(1)* %out0
26  store i32 %add1, i32 addrspace(1)* %out1
27  ret void
28}
29
30; SI-LABEL: {{^}}s_addk_i32_k1:
31; SI: s_addk_i32 {{s[0-9]+}}, 0x7fff{{$}}
32; SI: s_endpgm
33define void @s_addk_i32_k1(i32 addrspace(1)* %out, i32 %b) {
34  %add = add i32 %b, 32767 ; (1 << 15) - 1
35  store i32 %add, i32 addrspace(1)* %out
36  ret void
37}
38
39; SI-LABEL: {{^}}s_addk_i32_k2:
40; SI: s_addk_i32 {{s[0-9]+}}, 0xffef{{$}}
41; SI: s_endpgm
42define void @s_addk_i32_k2(i32 addrspace(1)* %out, i32 %b) {
43  %add = add i32 %b, -17
44  store i32 %add, i32 addrspace(1)* %out
45  ret void
46}
47
48; SI-LABEL: {{^}}s_addk_v2i32_k0:
49; SI-DAG: s_addk_i32 {{s[0-9]+}}, 0x41
50; SI-DAG: s_addk_i32 {{s[0-9]+}}, 0x42
51; SI: s_endpgm
52define void @s_addk_v2i32_k0(<2 x i32> addrspace(1)* %out, <2 x i32> %b) {
53  %add = add <2 x i32> %b, <i32 65, i32 66>
54  store <2 x i32> %add, <2 x i32> addrspace(1)* %out
55  ret void
56}
57
58; SI-LABEL: {{^}}s_addk_v4i32_k0:
59; SI-DAG: s_addk_i32 {{s[0-9]+}}, 0x41
60; SI-DAG: s_addk_i32 {{s[0-9]+}}, 0x42
61; SI-DAG: s_addk_i32 {{s[0-9]+}}, 0x43
62; SI-DAG: s_addk_i32 {{s[0-9]+}}, 0x44
63; SI: s_endpgm
64define void @s_addk_v4i32_k0(<4 x i32> addrspace(1)* %out, <4 x i32> %b) {
65  %add = add <4 x i32> %b, <i32 65, i32 66, i32 67, i32 68>
66  store <4 x i32> %add, <4 x i32> addrspace(1)* %out
67  ret void
68}
69
70; SI-LABEL: {{^}}s_addk_v8i32_k0:
71; SI-DAG: s_addk_i32 {{s[0-9]+}}, 0x41
72; SI-DAG: s_addk_i32 {{s[0-9]+}}, 0x42
73; SI-DAG: s_addk_i32 {{s[0-9]+}}, 0x43
74; SI-DAG: s_addk_i32 {{s[0-9]+}}, 0x44
75; SI-DAG: s_addk_i32 {{s[0-9]+}}, 0x45
76; SI-DAG: s_addk_i32 {{s[0-9]+}}, 0x46
77; SI-DAG: s_addk_i32 {{s[0-9]+}}, 0x47
78; SI-DAG: s_addk_i32 {{s[0-9]+}}, 0x48
79; SI: s_endpgm
80define void @s_addk_v8i32_k0(<8 x i32> addrspace(1)* %out, <8 x i32> %b) {
81  %add = add <8 x i32> %b, <i32 65, i32 66, i32 67, i32 68, i32 69, i32 70, i32 71, i32 72>
82  store <8 x i32> %add, <8 x i32> addrspace(1)* %out
83  ret void
84}
85
86; SI-LABEL: {{^}}no_s_addk_i32_k0:
87; SI: s_add_i32 {{s[0-9]+}}, {{s[0-9]+}}, 0x8000{{$}}
88; SI: s_endpgm
89define void @no_s_addk_i32_k0(i32 addrspace(1)* %out, i32 %b) {
90  %add = add i32 %b, 32768 ; 1 << 15
91  store i32 %add, i32 addrspace(1)* %out
92  ret void
93}
94