1 ; RUN: llc -amdgpu-scalarize-global-loads=false -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
3 declare float @llvm.fabs.f32(float) #0
4 declare float @llvm.canonicalize.f32(float) #0
5 declare <2 x float> @llvm.canonicalize.v2f32(<2 x float>) #0
6 declare <3 x float> @llvm.canonicalize.v3f32(<3 x float>) #0
7 declare <4 x float> @llvm.canonicalize.v4f32(<4 x float>) #0
8 declare <8 x float> @llvm.canonicalize.v8f32(<8 x float>) #0
9 declare double @llvm.fabs.f64(double) #0
10 declare double @llvm.canonicalize.f64(double) #0
11 declare <2 x double> @llvm.canonicalize.v2f64(<2 x double>) #0
12 declare <3 x double> @llvm.canonicalize.v3f64(<3 x double>) #0
13 declare <4 x double> @llvm.canonicalize.v4f64(<4 x double>) #0
14 declare half @llvm.canonicalize.f16(half) #0
15 declare <2 x half> @llvm.canonicalize.v2f16(<2 x half>) #0
16 declare i32 @llvm.amdgcn.workitem.id.x() #0
18 ; GCN-LABEL: {{^}}v_test_canonicalize_var_f32:
19 ; GCN: v_mul_f32_e32 [[REG:v[0-9]+]], 1.0, {{v[0-9]+}}
20 ; GCN: buffer_store_dword [[REG]]
21 define amdgpu_kernel void @v_test_canonicalize_var_f32(float addrspace(1)* %out) #1 {
22 %val = load float, float addrspace(1)* %out
23 %canonicalized = call float @llvm.canonicalize.f32(float %val)
24 store float %canonicalized, float addrspace(1)* %out
28 ; GCN-LABEL: {{^}}s_test_canonicalize_var_f32:
29 ; GCN: v_mul_f32_e64 [[REG:v[0-9]+]], 1.0, {{s[0-9]+}}
30 ; GCN: buffer_store_dword [[REG]]
31 define amdgpu_kernel void @s_test_canonicalize_var_f32(float addrspace(1)* %out, float %val) #1 {
32 %canonicalized = call float @llvm.canonicalize.f32(float %val)
33 store float %canonicalized, float addrspace(1)* %out
37 ; GCN-LABEL: {{^}}v_test_canonicalize_fabs_var_f32:
38 ; GCN: v_mul_f32_e64 [[REG:v[0-9]+]], 1.0, |{{v[0-9]+}}|
39 ; GCN: buffer_store_dword [[REG]]
40 define amdgpu_kernel void @v_test_canonicalize_fabs_var_f32(float addrspace(1)* %out) #1 {
41 %val = load float, float addrspace(1)* %out
42 %val.fabs = call float @llvm.fabs.f32(float %val)
43 %canonicalized = call float @llvm.canonicalize.f32(float %val.fabs)
44 store float %canonicalized, float addrspace(1)* %out
48 ; GCN-LABEL: {{^}}v_test_canonicalize_fneg_fabs_var_f32:
49 ; GCN: v_mul_f32_e64 [[REG:v[0-9]+]], -1.0, |{{v[0-9]+}}|
50 ; GCN: buffer_store_dword [[REG]]
51 define amdgpu_kernel void @v_test_canonicalize_fneg_fabs_var_f32(float addrspace(1)* %out) #1 {
52 %val = load float, float addrspace(1)* %out
53 %val.fabs = call float @llvm.fabs.f32(float %val)
54 %val.fabs.fneg = fsub float -0.0, %val.fabs
55 %canonicalized = call float @llvm.canonicalize.f32(float %val.fabs.fneg)
56 store float %canonicalized, float addrspace(1)* %out
60 ; GCN-LABEL: {{^}}v_test_canonicalize_fneg_var_f32:
61 ; GCN: v_mul_f32_e32 [[REG:v[0-9]+]], -1.0, {{v[0-9]+}}
62 ; GCN: buffer_store_dword [[REG]]
63 define amdgpu_kernel void @v_test_canonicalize_fneg_var_f32(float addrspace(1)* %out) #1 {
64 %val = load float, float addrspace(1)* %out
65 %val.fneg = fsub float -0.0, %val
66 %canonicalized = call float @llvm.canonicalize.f32(float %val.fneg)
67 store float %canonicalized, float addrspace(1)* %out
71 ; GCN-LABEL: {{^}}test_fold_canonicalize_undef_f32:
72 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x7fc00000{{$}}
73 ; GCN: buffer_store_dword [[REG]]
74 define amdgpu_kernel void @test_fold_canonicalize_undef_f32(float addrspace(1)* %out) #1 {
75 %canonicalized = call float @llvm.canonicalize.f32(float undef)
76 store float %canonicalized, float addrspace(1)* %out
80 ; GCN-LABEL: {{^}}test_fold_canonicalize_p0_f32:
81 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0{{$}}
82 ; GCN: buffer_store_dword [[REG]]
83 define amdgpu_kernel void @test_fold_canonicalize_p0_f32(float addrspace(1)* %out) #1 {
84 %canonicalized = call float @llvm.canonicalize.f32(float 0.0)
85 store float %canonicalized, float addrspace(1)* %out
89 ; GCN-LABEL: {{^}}test_fold_canonicalize_n0_f32:
90 ; GCN: v_bfrev_b32_e32 [[REG:v[0-9]+]], 1{{$}}
91 ; GCN: buffer_store_dword [[REG]]
92 define amdgpu_kernel void @test_fold_canonicalize_n0_f32(float addrspace(1)* %out) #1 {
93 %canonicalized = call float @llvm.canonicalize.f32(float -0.0)
94 store float %canonicalized, float addrspace(1)* %out
98 ; GCN-LABEL: {{^}}test_fold_canonicalize_p1_f32:
99 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 1.0{{$}}
100 ; GCN: buffer_store_dword [[REG]]
101 define amdgpu_kernel void @test_fold_canonicalize_p1_f32(float addrspace(1)* %out) #1 {
102 %canonicalized = call float @llvm.canonicalize.f32(float 1.0)
103 store float %canonicalized, float addrspace(1)* %out
107 ; GCN-LABEL: {{^}}test_fold_canonicalize_n1_f32:
108 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], -1.0{{$}}
109 ; GCN: buffer_store_dword [[REG]]
110 define amdgpu_kernel void @test_fold_canonicalize_n1_f32(float addrspace(1)* %out) #1 {
111 %canonicalized = call float @llvm.canonicalize.f32(float -1.0)
112 store float %canonicalized, float addrspace(1)* %out
116 ; GCN-LABEL: {{^}}test_fold_canonicalize_literal_f32:
117 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x41800000{{$}}
118 ; GCN: buffer_store_dword [[REG]]
119 define amdgpu_kernel void @test_fold_canonicalize_literal_f32(float addrspace(1)* %out) #1 {
120 %canonicalized = call float @llvm.canonicalize.f32(float 16.0)
121 store float %canonicalized, float addrspace(1)* %out
125 ; GCN-LABEL: {{^}}test_no_denormals_fold_canonicalize_denormal0_f32:
126 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0{{$}}
127 ; GCN: buffer_store_dword [[REG]]
128 define amdgpu_kernel void @test_no_denormals_fold_canonicalize_denormal0_f32(float addrspace(1)* %out) #1 {
129 %canonicalized = call float @llvm.canonicalize.f32(float bitcast (i32 8388607 to float))
130 store float %canonicalized, float addrspace(1)* %out
134 ; GCN-LABEL: {{^}}test_denormals_fold_canonicalize_denormal0_f32:
135 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x7fffff{{$}}
136 ; GCN: buffer_store_dword [[REG]]
137 define amdgpu_kernel void @test_denormals_fold_canonicalize_denormal0_f32(float addrspace(1)* %out) #3 {
138 %canonicalized = call float @llvm.canonicalize.f32(float bitcast (i32 8388607 to float))
139 store float %canonicalized, float addrspace(1)* %out
143 ; GCN-LABEL: {{^}}test_no_denormals_fold_canonicalize_denormal1_f32:
144 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0{{$}}
145 ; GCN: buffer_store_dword [[REG]]
146 define amdgpu_kernel void @test_no_denormals_fold_canonicalize_denormal1_f32(float addrspace(1)* %out) #1 {
147 %canonicalized = call float @llvm.canonicalize.f32(float bitcast (i32 2155872255 to float))
148 store float %canonicalized, float addrspace(1)* %out
152 ; GCN-LABEL: {{^}}test_denormals_fold_canonicalize_denormal1_f32:
153 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x807fffff{{$}}
154 ; GCN: buffer_store_dword [[REG]]
155 define amdgpu_kernel void @test_denormals_fold_canonicalize_denormal1_f32(float addrspace(1)* %out) #3 {
156 %canonicalized = call float @llvm.canonicalize.f32(float bitcast (i32 2155872255 to float))
157 store float %canonicalized, float addrspace(1)* %out
161 ; GCN-LABEL: {{^}}test_fold_canonicalize_qnan_f32:
162 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x7fc00000{{$}}
163 ; GCN: buffer_store_dword [[REG]]
164 define amdgpu_kernel void @test_fold_canonicalize_qnan_f32(float addrspace(1)* %out) #1 {
165 %canonicalized = call float @llvm.canonicalize.f32(float 0x7FF8000000000000)
166 store float %canonicalized, float addrspace(1)* %out
170 ; GCN-LABEL: {{^}}test_fold_canonicalize_qnan_value_neg1_f32:
171 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x7fc00000{{$}}
172 ; GCN: buffer_store_dword [[REG]]
173 define amdgpu_kernel void @test_fold_canonicalize_qnan_value_neg1_f32(float addrspace(1)* %out) #1 {
174 %canonicalized = call float @llvm.canonicalize.f32(float bitcast (i32 -1 to float))
175 store float %canonicalized, float addrspace(1)* %out
179 ; GCN-LABEL: {{^}}test_fold_canonicalize_qnan_value_neg2_f32:
180 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x7fc00000{{$}}
181 ; GCN: buffer_store_dword [[REG]]
182 define amdgpu_kernel void @test_fold_canonicalize_qnan_value_neg2_f32(float addrspace(1)* %out) #1 {
183 %canonicalized = call float @llvm.canonicalize.f32(float bitcast (i32 -2 to float))
184 store float %canonicalized, float addrspace(1)* %out
188 ; GCN-LABEL: {{^}}test_fold_canonicalize_snan0_value_f32:
189 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x7fc00000{{$}}
190 ; GCN: buffer_store_dword [[REG]]
191 define amdgpu_kernel void @test_fold_canonicalize_snan0_value_f32(float addrspace(1)* %out) #1 {
192 %canonicalized = call float @llvm.canonicalize.f32(float bitcast (i32 2139095041 to float))
193 store float %canonicalized, float addrspace(1)* %out
197 ; GCN-LABEL: {{^}}test_fold_canonicalize_snan1_value_f32:
198 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x7fc00000{{$}}
199 ; GCN: buffer_store_dword [[REG]]
200 define amdgpu_kernel void @test_fold_canonicalize_snan1_value_f32(float addrspace(1)* %out) #1 {
201 %canonicalized = call float @llvm.canonicalize.f32(float bitcast (i32 2143289343 to float))
202 store float %canonicalized, float addrspace(1)* %out
206 ; GCN-LABEL: {{^}}test_fold_canonicalize_snan2_value_f32:
207 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x7fc00000{{$}}
208 ; GCN: buffer_store_dword [[REG]]
209 define amdgpu_kernel void @test_fold_canonicalize_snan2_value_f32(float addrspace(1)* %out) #1 {
210 %canonicalized = call float @llvm.canonicalize.f32(float bitcast (i32 4286578689 to float))
211 store float %canonicalized, float addrspace(1)* %out
215 ; GCN-LABEL: {{^}}test_fold_canonicalize_snan3_value_f32:
216 ; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x7fc00000{{$}}
217 ; GCN: buffer_store_dword [[REG]]
218 define amdgpu_kernel void @test_fold_canonicalize_snan3_value_f32(float addrspace(1)* %out) #1 {
219 %canonicalized = call float @llvm.canonicalize.f32(float bitcast (i32 4290772991 to float))
220 store float %canonicalized, float addrspace(1)* %out
224 ; GCN-LABEL: {{^}}v_test_canonicalize_var_f64:
225 ; GCN: v_max_f64 [[REG:v\[[0-9]+:[0-9]+\]]], {{v\[[0-9]+:[0-9]+\]}}, {{v\[[0-9]+:[0-9]+\]}}
226 ; GCN: buffer_store_dwordx2 [[REG]]
227 define amdgpu_kernel void @v_test_canonicalize_var_f64(double addrspace(1)* %out) #1 {
228 %val = load double, double addrspace(1)* %out
229 %canonicalized = call double @llvm.canonicalize.f64(double %val)
230 store double %canonicalized, double addrspace(1)* %out
234 ; GCN-LABEL: {{^}}s_test_canonicalize_var_f64:
235 ; GCN: v_max_f64 [[REG:v\[[0-9]+:[0-9]+\]]], {{s\[[0-9]+:[0-9]+\]}}, {{s\[[0-9]+:[0-9]+\]}}
236 ; GCN: buffer_store_dwordx2 [[REG]]
237 define amdgpu_kernel void @s_test_canonicalize_var_f64(double addrspace(1)* %out, double %val) #1 {
238 %canonicalized = call double @llvm.canonicalize.f64(double %val)
239 store double %canonicalized, double addrspace(1)* %out
243 ; GCN-LABEL: {{^}}v_test_canonicalize_fabs_var_f64:
244 ; GCN: v_max_f64 [[REG:v\[[0-9]+:[0-9]+\]]], |{{v\[[0-9]+:[0-9]+\]}}|, |{{v\[[0-9]+:[0-9]+\]}}|
245 ; GCN: buffer_store_dwordx2 [[REG]]
246 define amdgpu_kernel void @v_test_canonicalize_fabs_var_f64(double addrspace(1)* %out) #1 {
247 %val = load double, double addrspace(1)* %out
248 %val.fabs = call double @llvm.fabs.f64(double %val)
249 %canonicalized = call double @llvm.canonicalize.f64(double %val.fabs)
250 store double %canonicalized, double addrspace(1)* %out
254 ; GCN-LABEL: {{^}}v_test_canonicalize_fneg_fabs_var_f64:
255 ; GCN: v_max_f64 [[REG:v\[[0-9]+:[0-9]\]]], -|{{v\[[0-9]+:[0-9]+\]}}|, -|{{v\[[0-9]+:[0-9]+\]}}|
256 ; GCN: buffer_store_dwordx2 [[REG]]
257 define amdgpu_kernel void @v_test_canonicalize_fneg_fabs_var_f64(double addrspace(1)* %out) #1 {
258 %val = load double, double addrspace(1)* %out
259 %val.fabs = call double @llvm.fabs.f64(double %val)
260 %val.fabs.fneg = fsub double -0.0, %val.fabs
261 %canonicalized = call double @llvm.canonicalize.f64(double %val.fabs.fneg)
262 store double %canonicalized, double addrspace(1)* %out
266 ; GCN-LABEL: {{^}}v_test_canonicalize_fneg_var_f64:
267 ; GCN: v_max_f64 [[REG:v\[[0-9]+:[0-9]+\]]], -{{v\[[0-9]+:[0-9]+\]}}, -{{v\[[0-9]+:[0-9]+\]}}
268 ; GCN: buffer_store_dwordx2 [[REG]]
269 define amdgpu_kernel void @v_test_canonicalize_fneg_var_f64(double addrspace(1)* %out) #1 {
270 %val = load double, double addrspace(1)* %out
271 %val.fneg = fsub double -0.0, %val
272 %canonicalized = call double @llvm.canonicalize.f64(double %val.fneg)
273 store double %canonicalized, double addrspace(1)* %out
277 ; GCN-LABEL: {{^}}test_fold_canonicalize_p0_f64:
278 ; GCN: v_mov_b32_e32 v[[LO:[0-9]+]], 0{{$}}
279 ; GCN: v_mov_b32_e32 v[[HI:[0-9]+]], v[[LO]]{{$}}
280 ; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
281 define amdgpu_kernel void @test_fold_canonicalize_p0_f64(double addrspace(1)* %out) #1 {
282 %canonicalized = call double @llvm.canonicalize.f64(double 0.0)
283 store double %canonicalized, double addrspace(1)* %out
287 ; GCN-LABEL: {{^}}test_fold_canonicalize_n0_f64:
288 ; GCN-DAG: v_mov_b32_e32 v[[LO:[0-9]+]], 0{{$}}
289 ; GCN-DAG: v_bfrev_b32_e32 v[[HI:[0-9]+]], 1{{$}}
290 ; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
291 define amdgpu_kernel void @test_fold_canonicalize_n0_f64(double addrspace(1)* %out) #1 {
292 %canonicalized = call double @llvm.canonicalize.f64(double -0.0)
293 store double %canonicalized, double addrspace(1)* %out
297 ; GCN-LABEL: {{^}}test_fold_canonicalize_p1_f64:
298 ; GCN-DAG: v_mov_b32_e32 v[[LO:[0-9]+]], 0{{$}}
299 ; GCN-DAG: v_mov_b32_e32 v[[HI:[0-9]+]], 0x3ff00000{{$}}
300 ; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
301 define amdgpu_kernel void @test_fold_canonicalize_p1_f64(double addrspace(1)* %out) #1 {
302 %canonicalized = call double @llvm.canonicalize.f64(double 1.0)
303 store double %canonicalized, double addrspace(1)* %out
307 ; GCN-LABEL: {{^}}test_fold_canonicalize_n1_f64:
308 ; GCN-DAG: v_mov_b32_e32 v[[LO:[0-9]+]], 0{{$}}
309 ; GCN-DAG: v_mov_b32_e32 v[[HI:[0-9]+]], 0xbff00000{{$}}
310 ; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
311 define amdgpu_kernel void @test_fold_canonicalize_n1_f64(double addrspace(1)* %out) #1 {
312 %canonicalized = call double @llvm.canonicalize.f64(double -1.0)
313 store double %canonicalized, double addrspace(1)* %out
317 ; GCN-LABEL: {{^}}test_fold_canonicalize_literal_f64:
318 ; GCN-DAG: v_mov_b32_e32 v[[LO:[0-9]+]], 0{{$}}
319 ; GCN-DAG: v_mov_b32_e32 v[[HI:[0-9]+]], 0x40300000{{$}}
320 ; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
321 define amdgpu_kernel void @test_fold_canonicalize_literal_f64(double addrspace(1)* %out) #1 {
322 %canonicalized = call double @llvm.canonicalize.f64(double 16.0)
323 store double %canonicalized, double addrspace(1)* %out
327 ; GCN-LABEL: {{^}}test_no_denormals_fold_canonicalize_denormal0_f64:
328 ; GCN: v_mov_b32_e32 v[[LO:[0-9]+]], 0{{$}}
329 ; GCN: v_mov_b32_e32 v[[HI:[0-9]+]], v[[LO]]{{$}}
330 ; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
331 define amdgpu_kernel void @test_no_denormals_fold_canonicalize_denormal0_f64(double addrspace(1)* %out) #2 {
332 %canonicalized = call double @llvm.canonicalize.f64(double bitcast (i64 4503599627370495 to double))
333 store double %canonicalized, double addrspace(1)* %out
337 ; GCN-LABEL: {{^}}test_denormals_fold_canonicalize_denormal0_f64:
338 ; GCN-DAG: v_mov_b32_e32 v[[LO:[0-9]+]], -1{{$}}
339 ; GCN-DAG: v_mov_b32_e32 v[[HI:[0-9]+]], 0xfffff{{$}}
340 ; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
341 define amdgpu_kernel void @test_denormals_fold_canonicalize_denormal0_f64(double addrspace(1)* %out) #3 {
342 %canonicalized = call double @llvm.canonicalize.f64(double bitcast (i64 4503599627370495 to double))
343 store double %canonicalized, double addrspace(1)* %out
347 ; GCN-LABEL: {{^}}test_no_denormals_fold_canonicalize_denormal1_f64:
348 ; GCN: v_mov_b32_e32 v[[LO:[0-9]+]], 0{{$}}
349 ; GCN: v_mov_b32_e32 v[[HI:[0-9]+]], v[[LO]]{{$}}
350 ; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
351 define amdgpu_kernel void @test_no_denormals_fold_canonicalize_denormal1_f64(double addrspace(1)* %out) #2 {
352 %canonicalized = call double @llvm.canonicalize.f64(double bitcast (i64 9227875636482146303 to double))
353 store double %canonicalized, double addrspace(1)* %out
357 ; GCN-LABEL: {{^}}test_denormals_fold_canonicalize_denormal1_f64:
358 ; GCN-DAG: v_mov_b32_e32 v[[LO:[0-9]+]], -1{{$}}
359 ; GCN-DAG: v_mov_b32_e32 v[[HI:[0-9]+]], 0x800fffff{{$}}
360 ; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
361 define amdgpu_kernel void @test_denormals_fold_canonicalize_denormal1_f64(double addrspace(1)* %out) #3 {
362 %canonicalized = call double @llvm.canonicalize.f64(double bitcast (i64 9227875636482146303 to double))
363 store double %canonicalized, double addrspace(1)* %out
367 ; GCN-LABEL: {{^}}test_fold_canonicalize_qnan_f64:
368 ; GCN-DAG: v_mov_b32_e32 v[[HI:[0-9]+]], 0x7ff80000{{$}}
369 ; GCN-DAG: v_mov_b32_e32 v[[LO:[0-9]+]], 0{{$}}
370 ; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
371 define amdgpu_kernel void @test_fold_canonicalize_qnan_f64(double addrspace(1)* %out) #1 {
372 %canonicalized = call double @llvm.canonicalize.f64(double 0x7FF8000000000000)
373 store double %canonicalized, double addrspace(1)* %out
377 ; GCN-LABEL: {{^}}test_fold_canonicalize_qnan_value_neg1_f64:
378 ; GCN-DAG: v_mov_b32_e32 v[[HI:[0-9]+]], 0x7ff80000{{$}}
379 ; GCN-DAG: v_mov_b32_e32 v[[LO:[0-9]+]], 0{{$}}
380 ; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
381 define amdgpu_kernel void @test_fold_canonicalize_qnan_value_neg1_f64(double addrspace(1)* %out) #1 {
382 %canonicalized = call double @llvm.canonicalize.f64(double bitcast (i64 -1 to double))
383 store double %canonicalized, double addrspace(1)* %out
387 ; GCN-LABEL: {{^}}test_fold_canonicalize_qnan_value_neg2_f64:
388 ; GCN-DAG: v_mov_b32_e32 v[[HI:[0-9]+]], 0x7ff80000{{$}}
389 ; GCN-DAG: v_mov_b32_e32 v[[LO:[0-9]+]], 0{{$}}
390 ; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
391 define amdgpu_kernel void @test_fold_canonicalize_qnan_value_neg2_f64(double addrspace(1)* %out) #1 {
392 %canonicalized = call double @llvm.canonicalize.f64(double bitcast (i64 -2 to double))
393 store double %canonicalized, double addrspace(1)* %out
397 ; GCN-LABEL: {{^}}test_fold_canonicalize_snan0_value_f64:
398 ; GCN-DAG: v_mov_b32_e32 v[[HI:[0-9]+]], 0x7ff80000{{$}}
399 ; GCN-DAG: v_mov_b32_e32 v[[LO:[0-9]+]], 0{{$}}
400 ; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
401 define amdgpu_kernel void @test_fold_canonicalize_snan0_value_f64(double addrspace(1)* %out) #1 {
402 %canonicalized = call double @llvm.canonicalize.f64(double bitcast (i64 9218868437227405313 to double))
403 store double %canonicalized, double addrspace(1)* %out
407 ; GCN-LABEL: {{^}}test_fold_canonicalize_snan1_value_f64:
408 ; GCN-DAG: v_mov_b32_e32 v[[HI:[0-9]+]], 0x7ff80000{{$}}
409 ; GCN-DAG: v_mov_b32_e32 v[[LO:[0-9]+]], 0{{$}}
410 ; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
411 define amdgpu_kernel void @test_fold_canonicalize_snan1_value_f64(double addrspace(1)* %out) #1 {
412 %canonicalized = call double @llvm.canonicalize.f64(double bitcast (i64 9223372036854775807 to double))
413 store double %canonicalized, double addrspace(1)* %out
417 ; GCN-LABEL: {{^}}test_fold_canonicalize_snan2_value_f64:
418 ; GCN-DAG: v_mov_b32_e32 v[[HI:[0-9]+]], 0x7ff80000{{$}}
419 ; GCN-DAG: v_mov_b32_e32 v[[LO:[0-9]+]], 0{{$}}
420 ; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
421 define amdgpu_kernel void @test_fold_canonicalize_snan2_value_f64(double addrspace(1)* %out) #1 {
422 %canonicalized = call double @llvm.canonicalize.f64(double bitcast (i64 18442240474082181121 to double))
423 store double %canonicalized, double addrspace(1)* %out
427 ; GCN-LABEL: {{^}}test_fold_canonicalize_snan3_value_f64:
428 ; GCN-DAG: v_mov_b32_e32 v[[HI:[0-9]+]], 0x7ff80000{{$}}
429 ; GCN-DAG: v_mov_b32_e32 v[[LO:[0-9]+]], 0{{$}}
430 ; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
431 define amdgpu_kernel void @test_fold_canonicalize_snan3_value_f64(double addrspace(1)* %out) #1 {
432 %canonicalized = call double @llvm.canonicalize.f64(double bitcast (i64 18446744073709551615 to double))
433 store double %canonicalized, double addrspace(1)* %out
437 ; GCN-LABEL: {{^}}test_canonicalize_value_f64_flush:
438 ; GCN: v_mul_f64 v[{{[0-9:]+}}], 1.0, v[{{[0-9:]+}}]
439 define amdgpu_kernel void @test_canonicalize_value_f64_flush(double addrspace(1)* %arg, double addrspace(1)* %out) #4 {
440 %id = tail call i32 @llvm.amdgcn.workitem.id.x()
441 %gep = getelementptr inbounds double, double addrspace(1)* %arg, i32 %id
442 %v = load double, double addrspace(1)* %gep, align 8
443 %canonicalized = tail call double @llvm.canonicalize.f64(double %v)
444 %gep2 = getelementptr inbounds double, double addrspace(1)* %out, i32 %id
445 store double %canonicalized, double addrspace(1)* %gep2, align 8
449 ; GCN-LABEL: {{^}}test_canonicalize_value_f32_flush:
450 ; GCN: v_mul_f32_e32 {{v[0-9]+}}, 1.0, {{v[0-9]+}}
451 define amdgpu_kernel void @test_canonicalize_value_f32_flush(float addrspace(1)* %arg, float addrspace(1)* %out) #4 {
452 %id = tail call i32 @llvm.amdgcn.workitem.id.x()
453 %gep = getelementptr inbounds float, float addrspace(1)* %arg, i32 %id
454 %v = load float, float addrspace(1)* %gep, align 4
455 %canonicalized = tail call float @llvm.canonicalize.f32(float %v)
456 %gep2 = getelementptr inbounds float, float addrspace(1)* %out, i32 %id
457 store float %canonicalized, float addrspace(1)* %gep2, align 4
461 ; GCN-LABEL: {{^}}test_canonicalize_value_f16_flush:
462 ; GCN: v_mul_f16_e32 {{v[0-9]+}}, 1.0, {{v[0-9]+}}
463 define amdgpu_kernel void @test_canonicalize_value_f16_flush(half addrspace(1)* %arg, half addrspace(1)* %out) #4 {
464 %id = tail call i32 @llvm.amdgcn.workitem.id.x()
465 %gep = getelementptr inbounds half, half addrspace(1)* %arg, i32 %id
466 %v = load half, half addrspace(1)* %gep, align 2
467 %canonicalized = tail call half @llvm.canonicalize.f16(half %v)
468 %gep2 = getelementptr inbounds half, half addrspace(1)* %out, i32 %id
469 store half %canonicalized, half addrspace(1)* %gep2, align 2
473 ; GCN-LABEL: {{^}}test_canonicalize_value_v2f16_flush_gfx8:
474 ; GCN: v_mov_b32_e32 [[ONE:v[0-9]+]], 0x3c00
475 ; GCN-DAG: v_mul_f16_sdwa v{{[0-9]+}}, [[ONE]], v{{[0-9]+}} dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:WORD_1
476 ; GCN-DAG: v_mul_f16_e32 v{{[0-9]+}}, 1.0, v{{[0-9]+}}
477 define amdgpu_kernel void @test_canonicalize_value_v2f16_flush_gfx8(<2 x half> addrspace(1)* %arg, <2 x half> addrspace(1)* %out) #4 {
478 %id = tail call i32 @llvm.amdgcn.workitem.id.x()
479 %gep = getelementptr inbounds <2 x half>, <2 x half> addrspace(1)* %arg, i32 %id
480 %v = load <2 x half>, <2 x half> addrspace(1)* %gep, align 4
481 %canonicalized = tail call <2 x half> @llvm.canonicalize.v2f16(<2 x half> %v)
482 %gep2 = getelementptr inbounds <2 x half>, <2 x half> addrspace(1)* %out, i32 %id
483 store <2 x half> %canonicalized, <2 x half> addrspace(1)* %gep2, align 2
487 ; GCN-LABEL: {{^}}test_canonicalize_value_v2f16_flush_gfx9:
488 ; GCN-DAG: v_pk_mul_f16 v{{[0-9]+}}, 1.0, v{{[0-9]+}} op_sel_hi:[0,1]{{$}}
489 define amdgpu_kernel void @test_canonicalize_value_v2f16_flush_gfx9(<2 x half> addrspace(1)* %arg, <2 x half> addrspace(1)* %out) #6 {
490 %id = tail call i32 @llvm.amdgcn.workitem.id.x()
491 %gep = getelementptr inbounds <2 x half>, <2 x half> addrspace(1)* %arg, i32 %id
492 %v = load <2 x half>, <2 x half> addrspace(1)* %gep, align 4
493 %canonicalized = tail call <2 x half> @llvm.canonicalize.v2f16(<2 x half> %v)
494 %gep2 = getelementptr inbounds <2 x half>, <2 x half> addrspace(1)* %out, i32 %id
495 store <2 x half> %canonicalized, <2 x half> addrspace(1)* %gep2, align 2
499 ; GCN-LABEL: {{^}}test_canonicalize_value_f64_denorm:
500 ; GCN: v_max_f64 v[{{[0-9:]+}}], v[{{[0-9:]+}}], v[{{[0-9:]+}}]
501 define amdgpu_kernel void @test_canonicalize_value_f64_denorm(double addrspace(1)* %arg, double addrspace(1)* %out) #5 {
502 %id = tail call i32 @llvm.amdgcn.workitem.id.x()
503 %gep = getelementptr inbounds double, double addrspace(1)* %arg, i32 %id
504 %v = load double, double addrspace(1)* %gep, align 8
505 %canonicalized = tail call double @llvm.canonicalize.f64(double %v)
506 %gep2 = getelementptr inbounds double, double addrspace(1)* %out, i32 %id
507 store double %canonicalized, double addrspace(1)* %gep2, align 8
511 ; GCN-LABEL: {{^}}test_canonicalize_value_f32_denorm:
512 ; GCN: v_max_f32_e32 {{v[0-9]+}}, {{v[0-9]+}}, {{v[0-9]+}}
513 define amdgpu_kernel void @test_canonicalize_value_f32_denorm(float addrspace(1)* %arg, float addrspace(1)* %out) #5 {
514 %id = tail call i32 @llvm.amdgcn.workitem.id.x()
515 %gep = getelementptr inbounds float, float addrspace(1)* %arg, i32 %id
516 %v = load float, float addrspace(1)* %gep, align 4
517 %canonicalized = tail call float @llvm.canonicalize.f32(float %v)
518 %gep2 = getelementptr inbounds float, float addrspace(1)* %out, i32 %id
519 store float %canonicalized, float addrspace(1)* %gep2, align 4
523 ; GCN-LABEL: {{^}}test_canonicalize_value_f16_denorm:
524 ; GCN: v_max_f16_e32 {{v[0-9]+}}, {{v[0-9]+}}, {{v[0-9]+}}
525 define amdgpu_kernel void @test_canonicalize_value_f16_denorm(half addrspace(1)* %arg, half addrspace(1)* %out) #5 {
526 %id = tail call i32 @llvm.amdgcn.workitem.id.x()
527 %gep = getelementptr inbounds half, half addrspace(1)* %arg, i32 %id
528 %v = load half, half addrspace(1)* %gep, align 2
529 %canonicalized = tail call half @llvm.canonicalize.f16(half %v)
530 %gep2 = getelementptr inbounds half, half addrspace(1)* %out, i32 %id
531 store half %canonicalized, half addrspace(1)* %gep2, align 2
535 ; GCN-LABEL: {{^}}test_canonicalize_value_v2f16_denorm:
536 ; GCN: v_pk_max_f16 {{v[0-9]+}}, {{v[0-9]+}}, {{v[0-9]+}}
537 define amdgpu_kernel void @test_canonicalize_value_v2f16_denorm(<2 x half> addrspace(1)* %arg, <2 x half> addrspace(1)* %out) #5 {
538 %id = tail call i32 @llvm.amdgcn.workitem.id.x()
539 %gep = getelementptr inbounds <2 x half>, <2 x half> addrspace(1)* %arg, i32 %id
540 %v = load <2 x half>, <2 x half> addrspace(1)* %gep, align 4
541 %canonicalized = tail call <2 x half> @llvm.canonicalize.v2f16(<2 x half> %v)
542 %gep2 = getelementptr inbounds <2 x half>, <2 x half> addrspace(1)* %out, i32 %id
543 store <2 x half> %canonicalized, <2 x half> addrspace(1)* %gep2, align 2
547 ; GCN-LABEL: {{^}}v_test_canonicalize_var_v2f64:
550 define amdgpu_kernel void @v_test_canonicalize_var_v2f64(<2 x double> addrspace(1)* %out) #1 {
551 %tid = call i32 @llvm.amdgcn.workitem.id.x()
552 %gep = getelementptr <2 x double>, <2 x double> addrspace(1)* %out, i32 %tid
553 %val = load <2 x double>, <2 x double> addrspace(1)* %gep
554 %canonicalized = call <2 x double> @llvm.canonicalize.v2f64(<2 x double> %val)
555 store <2 x double> %canonicalized, <2 x double> addrspace(1)* %out
559 ; GCN-LABEL: {{^}}v_test_canonicalize_v2f32:
560 ; GCN: v_mul_f32_e32 [[REG:v[0-9]+]], 1.0, {{v[0-9]+}}
561 ; GCN: v_mul_f32_e32 [[REG:v[0-9]+]], 1.0, {{v[0-9]+}}
562 define <2 x float> @v_test_canonicalize_v2f32(<2 x float> %arg) #1 {
563 %canon = call <2 x float> @llvm.canonicalize.v2f32(<2 x float> %arg)
564 ret <2 x float> %canon
567 ; GCN-LABEL: {{^}}v_test_canonicalize_v3f32:
568 ; GCN: v_mul_f32_e32 [[REG:v[0-9]+]], 1.0, {{v[0-9]+}}
569 ; GCN: v_mul_f32_e32 [[REG:v[0-9]+]], 1.0, {{v[0-9]+}}
570 ; GCN: v_mul_f32_e32 [[REG:v[0-9]+]], 1.0, {{v[0-9]+}}
571 define <3 x float> @v_test_canonicalize_v3f32(<3 x float> %arg) #1 {
572 %canon = call <3 x float> @llvm.canonicalize.v3f32(<3 x float> %arg)
573 ret <3 x float> %canon
576 ; GCN-LABEL: {{^}}v_test_canonicalize_v4f32:
577 ; GCN: v_mul_f32_e32 [[REG:v[0-9]+]], 1.0, {{v[0-9]+}}
578 ; GCN: v_mul_f32_e32 [[REG:v[0-9]+]], 1.0, {{v[0-9]+}}
579 ; GCN: v_mul_f32_e32 [[REG:v[0-9]+]], 1.0, {{v[0-9]+}}
580 ; GCN: v_mul_f32_e32 [[REG:v[0-9]+]], 1.0, {{v[0-9]+}}
581 define <4 x float> @v_test_canonicalize_v4f32(<4 x float> %arg) #1 {
582 %canon = call <4 x float> @llvm.canonicalize.v4f32(<4 x float> %arg)
583 ret <4 x float> %canon
586 ; GCN-LABEL: {{^}}v_test_canonicalize_v8f32:
587 ; GCN: v_mul_f32_e32 [[REG:v[0-9]+]], 1.0, {{v[0-9]+}}
588 ; GCN: v_mul_f32_e32 [[REG:v[0-9]+]], 1.0, {{v[0-9]+}}
589 ; GCN: v_mul_f32_e32 [[REG:v[0-9]+]], 1.0, {{v[0-9]+}}
590 ; GCN: v_mul_f32_e32 [[REG:v[0-9]+]], 1.0, {{v[0-9]+}}
591 ; GCN: v_mul_f32_e32 [[REG:v[0-9]+]], 1.0, {{v[0-9]+}}
592 ; GCN: v_mul_f32_e32 [[REG:v[0-9]+]], 1.0, {{v[0-9]+}}
593 ; GCN: v_mul_f32_e32 [[REG:v[0-9]+]], 1.0, {{v[0-9]+}}
594 ; GCN: v_mul_f32_e32 [[REG:v[0-9]+]], 1.0, {{v[0-9]+}}
595 define <8 x float> @v_test_canonicalize_v8f32(<8 x float> %arg) #1 {
596 %canon = call <8 x float> @llvm.canonicalize.v8f32(<8 x float> %arg)
597 ret <8 x float> %canon
600 ; GCN-LABEL: {{^}}v_test_canonicalize_v2f64:
603 define <2 x double> @v_test_canonicalize_v2f64(<2 x double> %arg) #1 {
604 %canon = call <2 x double> @llvm.canonicalize.v2f64(<2 x double> %arg)
605 ret <2 x double> %canon
608 ; GCN-LABEL: {{^}}v_test_canonicalize_v3f64:
612 define <3 x double> @v_test_canonicalize_v3f64(<3 x double> %arg) #1 {
613 %canon = call <3 x double> @llvm.canonicalize.v3f64(<3 x double> %arg)
614 ret <3 x double> %canon
617 ; GCN-LABEL: {{^}}v_test_canonicalize_v4f64:
622 define <4 x double> @v_test_canonicalize_v4f64(<4 x double> %arg) #1 {
623 %canon = call <4 x double> @llvm.canonicalize.v4f64(<4 x double> %arg)
624 ret <4 x double> %canon
627 attributes #0 = { nounwind readnone }
628 attributes #1 = { nounwind }
629 attributes #2 = { nounwind "target-features"="-fp32-denormals,-fp64-fp16-denormals" }
630 attributes #3 = { nounwind "target-features"="+fp32-denormals,+fp64-fp16-denormals" }
631 attributes #4 = { nounwind "target-features"="-fp32-denormals,-fp64-fp16-denormals" "target-cpu"="tonga" }
632 attributes #5 = { nounwind "target-features"="+fp32-denormals,+fp64-fp16-denormals" "target-cpu"="gfx900" }
633 attributes #6 = { nounwind "target-features"="-fp32-denormals,-fp64-fp16-denormals" "target-cpu"="gfx900" }