1 ; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefix=GCN -check-prefix=SI %s
2 ; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefix=GCN -check-prefix=VI %s
4 ; Make sure we don't crash or assert on spir_kernel calling convention.
6 ; GCN-LABEL: {{^}}kernel:
8 define spir_kernel void @kernel(i32 addrspace(1)* %out) {
10 store i32 0, i32 addrspace(1)* %out
14 ; FIXME: This is treated like a kernel
15 ; XGCN-LABEL: {{^}}func:
17 ; define spir_func void @func(i32 addrspace(1)* %out) {
19 ; store i32 0, i32 addrspace(1)* %out
23 ; GCN-LABEL: {{^}}ps_ret_cc_f16:
24 ; SI: v_cvt_f16_f32_e32 v0, v0
25 ; SI: v_cvt_f32_f16_e32 v0, v0
26 ; SI: v_add_f32_e32 v0, 1.0, v0
28 ; VI: v_add_f16_e32 v0, 1.0, v0
30 define amdgpu_ps half @ps_ret_cc_f16(half %arg0) {
31 %add = fadd half %arg0, 1.0
35 ; GCN-LABEL: {{^}}ps_ret_cc_inreg_f16:
36 ; SI: v_cvt_f16_f32_e32 v0, s0
37 ; SI: v_cvt_f32_f16_e32 v0, v0
38 ; SI: v_add_f32_e32 v0, 1.0, v0
40 ; VI: v_add_f16_e64 v0, s0, 1.0
42 define amdgpu_ps half @ps_ret_cc_inreg_f16(half inreg %arg0) {
43 %add = fadd half %arg0, 1.0
47 ; GCN-LABEL: {{^}}fastcc:
48 ; GCN: v_add_f32_e32 v0, 4.0, v0
49 define fastcc float @fastcc(float %arg0) #0 {
50 %add = fadd float %arg0, 4.0
54 ; GCN-LABEL: {{^}}coldcc:
55 ; GCN: v_add_f32_e32 v0, 4.0, v0
56 define coldcc float @coldcc(float %arg0) #0 {
57 %add = fadd float %arg0, 4.0
61 ; GCN-LABEL: {{^}}call_coldcc:
62 ; GCN: v_mov_b32_e32 v0, 1.0
64 define amdgpu_kernel void @call_coldcc() #0 {
65 %val = call float @coldcc(float 1.0)
66 store float %val, float addrspace(1)* undef
70 ; GCN-LABEL: {{^}}call_fastcc:
71 ; GCN: v_mov_b32_e32 v0, 1.0
73 define amdgpu_kernel void @call_fastcc() #0 {
74 %val = call float @fastcc(float 1.0)
75 store float %val, float addrspace(1)* undef
79 ; Mesa compute shader: check for 47176 (COMPUTE_PGM_RSRC1) in .AMDGPU.config
80 ; GCN-LABEL: .AMDGPU.config
82 ; GCN-LABEL: {{^}}cs_mesa:
83 define amdgpu_cs half @cs_mesa(half %arg0) {
84 %add = fadd half %arg0, 1.0
88 ; Mesa pixel shader: check for 45096 (SPI_SHADER_PGM_RSRC1_PS) in .AMDGPU.config
89 ; GCN-LABEL: .AMDGPU.config
91 ; GCN-LABEL: {{^}}ps_mesa_f16:
92 define amdgpu_ps half @ps_mesa_f16(half %arg0) {
93 %add = fadd half %arg0, 1.0
97 ; Mesa vertex shader: check for 45352 (SPI_SHADER_PGM_RSRC1_VS) in .AMDGPU.config
98 ; GCN-LABEL: .AMDGPU.config
100 ; GCN-LABEL: {{^}}vs_mesa:
101 define amdgpu_vs half @vs_mesa(half %arg0) {
102 %add = fadd half %arg0, 1.0
106 ; Mesa geometry shader: check for 45608 (SPI_SHADER_PGM_RSRC1_GS) in .AMDGPU.config
107 ; GCN-LABEL: .AMDGPU.config
109 ; GCN-LABEL: {{^}}gs_mesa:
110 define amdgpu_gs half @gs_mesa(half %arg0) {
111 %add = fadd half %arg0, 1.0
115 ; Mesa hull shader: check for 46120 (SPI_SHADER_PGM_RSRC1_HS) in .AMDGPU.config
116 ; GCN-LABEL: .AMDGPU.config
118 ; GCN-LABEL: {{^}}hs_mesa:
119 define amdgpu_hs half @hs_mesa(half %arg0) {
120 %add = fadd half %arg0, 1.0
124 ; FIXME: Inconsistent ABI between targets
125 ; GCN-LABEL: {{^}}ps_mesa_v2f16:
126 ; VI: v_mov_b32_e32 v1, 0x3c00
127 ; VI-NEXT: v_add_f16_sdwa v1, v0, v1 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:DWORD
128 ; VI-NEXT: v_add_f16_e32 v0, 1.0, v0
129 ; VI-NEXT: v_or_b32_e32 v0, v0, v1
132 ; SI-DAG: v_cvt_f16_f32_e32 [[CVT_ELT0:v[0-9]+]], v0
133 ; SI-DAG: v_cvt_f16_f32_e32 [[CVT_ELT1:v[0-9]+]], v1
134 ; SI-DAG: v_cvt_f32_f16_e32 [[RECVT_ELT0:v[0-9]+]], [[CVT_ELT0]]
135 ; SI-DAG: v_cvt_f32_f16_e32 [[RECVT_ELT1:v[0-9]+]], [[CVT_ELT1]]
136 ; SI-DAG: v_add_f32_e32 v0, 1.0, [[RECVT_ELT0]]
137 ; SI-DAG: v_add_f32_e32 v1, 1.0, [[RECVT_ELT1]]
138 ; SI: ; return to shader part epilog
139 define amdgpu_ps <2 x half> @ps_mesa_v2f16(<2 x half> %arg0) {
140 %add = fadd <2 x half> %arg0, <half 1.0, half 1.0>
144 ; GCN-LABEL: {{^}}ps_mesa_inreg_v2f16:
145 ; VI: s_lshr_b32 s1, s0, 16
146 ; VI-NEXT: v_mov_b32_e32 v0, s1
147 ; VI-NEXT: v_mov_b32_e32 v1, 0x3c00
148 ; VI-NEXT: v_add_f16_sdwa v0, v0, v1 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD
149 ; VI-NEXT: v_add_f16_e64 v1, s0, 1.0
150 ; VI-NEXT: v_or_b32_e32 v0, v1, v0
151 ; VI-NEXT: ; return to shader part epilog
153 ; SI-DAG: v_cvt_f16_f32_e32 [[CVT_ELT0:v[0-9]+]], s0
154 ; SI-DAG: v_cvt_f16_f32_e32 [[CVT_ELT1:v[0-9]+]], s1
155 ; SI-DAG: v_cvt_f32_f16_e32 [[RECVT_ELT0:v[0-9]+]], [[CVT_ELT0]]
156 ; SI-DAG: v_cvt_f32_f16_e32 [[RECVT_ELT1:v[0-9]+]], [[CVT_ELT1]]
157 ; SI-DAG: v_add_f32_e32 v0, 1.0, [[RECVT_ELT0]]
158 ; SI-DAG: v_add_f32_e32 v1, 1.0, [[RECVT_ELT1]]
159 ; SI: ; return to shader part epilog
160 define amdgpu_ps <2 x half> @ps_mesa_inreg_v2f16(<2 x half> inreg %arg0) {
161 %add = fadd <2 x half> %arg0, <half 1.0, half 1.0>
165 ; GCN-LABEL: {{^}}ps_mesa_v2i16:
166 ; VI: v_mov_b32_e32 v2, 1
167 ; VI: v_add_u16_e32 v1, 1, v0
168 ; VI: v_add_u16_sdwa v0, v0, v2 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:DWORD
169 ; VI: v_or_b32_e32 v0, v1, v0
172 ; SI: v_lshlrev_b32_e32 v1, 16, v1
173 ; SI: v_add_i32_e32 v0, vcc, 1, v0
174 ; SI: v_add_i32_e32 v1, vcc, 0x10000, v1
177 define amdgpu_ps void @ps_mesa_v2i16(<2 x i16> %arg0) {
178 %add = add <2 x i16> %arg0, <i16 1, i16 1>
179 store <2 x i16> %add, <2 x i16> addrspace(1)* undef
183 ; GCN-LABEL: {{^}}ps_mesa_inreg_v2i16:
184 ; VI: s_lshr_b32 s1, s0, 16
185 ; VI: s_add_i32 s1, s1, 1
186 ; VI: s_add_i32 s0, s0, 1
187 ; VI: s_and_b32 s0, s0, 0xffff
188 ; VI: s_lshl_b32 s1, s1, 16
189 ; VI: s_or_b32 s0, s0, s1
190 ; VI: v_mov_b32_e32 v0, s0
192 ; SI: s_lshl_b32 s1, s1, 16
193 ; SI: s_add_i32 s0, s0, 1
194 ; SI: s_add_i32 s1, s1, 0x10000
195 ; SI: s_and_b32 s0, s0, 0xffff
196 ; SI: s_or_b32 s0, s0, s1
197 define amdgpu_ps void @ps_mesa_inreg_v2i16(<2 x i16> inreg %arg0) {
198 %add = add <2 x i16> %arg0, <i16 1, i16 1>
199 store <2 x i16> %add, <2 x i16> addrspace(1)* undef
203 attributes #0 = { nounwind noinline }