1 ; RUN: llc -amdgpu-scalarize-global-loads=false -march=amdgcn -mcpu=tahiti -verify-machineinstrs < %s | FileCheck -check-prefix=SI %s
2 ; RUN: llc -amdgpu-scalarize-global-loads=false -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=SI %s
4 declare double @llvm.fabs.f64(double) #0
6 ; SI-LABEL: {{^}}fsub_f64:
7 ; SI: v_add_f64 {{v\[[0-9]+:[0-9]+\], v\[[0-9]+:[0-9]+\], -v\[[0-9]+:[0-9]+\]}}
8 define amdgpu_kernel void @fsub_f64(double addrspace(1)* %out, double addrspace(1)* %in1,
9 double addrspace(1)* %in2) {
10 %r0 = load double, double addrspace(1)* %in1
11 %r1 = load double, double addrspace(1)* %in2
12 %r2 = fsub double %r0, %r1
13 store double %r2, double addrspace(1)* %out
17 ; SI-LABEL: {{^}}fsub_fabs_f64:
18 ; SI: v_add_f64 {{v\[[0-9]+:[0-9]+\], v\[[0-9]+:[0-9]+\], -\|v\[[0-9]+:[0-9]+\]\|}}
19 define amdgpu_kernel void @fsub_fabs_f64(double addrspace(1)* %out, double addrspace(1)* %in1,
20 double addrspace(1)* %in2) {
21 %r0 = load double, double addrspace(1)* %in1
22 %r1 = load double, double addrspace(1)* %in2
23 %r1.fabs = call double @llvm.fabs.f64(double %r1) #0
24 %r2 = fsub double %r0, %r1.fabs
25 store double %r2, double addrspace(1)* %out
29 ; SI-LABEL: {{^}}fsub_fabs_inv_f64:
30 ; SI: v_add_f64 {{v\[[0-9]+:[0-9]+\], |v\[[0-9]+:[0-9]+\]|, -v\[[0-9]+:[0-9]+\]}}
31 define amdgpu_kernel void @fsub_fabs_inv_f64(double addrspace(1)* %out, double addrspace(1)* %in1,
32 double addrspace(1)* %in2) {
33 %r0 = load double, double addrspace(1)* %in1
34 %r1 = load double, double addrspace(1)* %in2
35 %r0.fabs = call double @llvm.fabs.f64(double %r0) #0
36 %r2 = fsub double %r0.fabs, %r1
37 store double %r2, double addrspace(1)* %out
41 ; SI-LABEL: {{^}}s_fsub_f64:
42 ; SI: v_add_f64 {{v\[[0-9]+:[0-9]+\], s\[[0-9]+:[0-9]+\], -v\[[0-9]+:[0-9]+\]}}
43 define amdgpu_kernel void @s_fsub_f64(double addrspace(1)* %out, double %a, double %b) {
44 %sub = fsub double %a, %b
45 store double %sub, double addrspace(1)* %out
49 ; SI-LABEL: {{^}}s_fsub_imm_f64:
50 ; SI: v_add_f64 {{v\[[0-9]+:[0-9]+\], -s\[[0-9]+:[0-9]+\]}}, 4.0
51 define amdgpu_kernel void @s_fsub_imm_f64(double addrspace(1)* %out, double %a, double %b) {
52 %sub = fsub double 4.0, %a
53 store double %sub, double addrspace(1)* %out
57 ; SI-LABEL: {{^}}s_fsub_imm_inv_f64:
58 ; SI: v_add_f64 {{v\[[0-9]+:[0-9]+\], s\[[0-9]+:[0-9]+\]}}, -4.0
59 define amdgpu_kernel void @s_fsub_imm_inv_f64(double addrspace(1)* %out, double %a, double %b) {
60 %sub = fsub double %a, 4.0
61 store double %sub, double addrspace(1)* %out
65 ; SI-LABEL: {{^}}s_fsub_self_f64:
66 ; SI: v_add_f64 {{v\[[0-9]+:[0-9]+\], s\[[0-9]+:[0-9]+\], -s\[[0-9]+:[0-9]+\]}}
67 define amdgpu_kernel void @s_fsub_self_f64(double addrspace(1)* %out, double %a) {
68 %sub = fsub double %a, %a
69 store double %sub, double addrspace(1)* %out
73 ; SI-LABEL: {{^}}fsub_v2f64:
74 ; SI: v_add_f64 {{v\[[0-9]+:[0-9]+\], s\[[0-9]+:[0-9]+\], -v\[[0-9]+:[0-9]+\]}}
75 ; SI: v_add_f64 {{v\[[0-9]+:[0-9]+\], s\[[0-9]+:[0-9]+\], -v\[[0-9]+:[0-9]+\]}}
76 define amdgpu_kernel void @fsub_v2f64(<2 x double> addrspace(1)* %out, <2 x double> %a, <2 x double> %b) {
77 %sub = fsub <2 x double> %a, %b
78 store <2 x double> %sub, <2 x double> addrspace(1)* %out
82 ; SI-LABEL: {{^}}fsub_v4f64:
83 ; SI: v_add_f64 {{v\[[0-9]+:[0-9]+\], v\[[0-9]+:[0-9]+\], -v\[[0-9]+:[0-9]+\]}}
84 ; SI: v_add_f64 {{v\[[0-9]+:[0-9]+\], v\[[0-9]+:[0-9]+\], -v\[[0-9]+:[0-9]+\]}}
85 ; SI: v_add_f64 {{v\[[0-9]+:[0-9]+\], v\[[0-9]+:[0-9]+\], -v\[[0-9]+:[0-9]+\]}}
86 ; SI: v_add_f64 {{v\[[0-9]+:[0-9]+\], v\[[0-9]+:[0-9]+\], -v\[[0-9]+:[0-9]+\]}}
87 define amdgpu_kernel void @fsub_v4f64(<4 x double> addrspace(1)* %out, <4 x double> addrspace(1)* %in) {
88 %b_ptr = getelementptr <4 x double>, <4 x double> addrspace(1)* %in, i32 1
89 %a = load <4 x double>, <4 x double> addrspace(1)* %in
90 %b = load <4 x double>, <4 x double> addrspace(1)* %b_ptr
91 %result = fsub <4 x double> %a, %b
92 store <4 x double> %result, <4 x double> addrspace(1)* %out
96 ; SI-LABEL: {{^}}s_fsub_v4f64:
97 ; SI: v_add_f64 {{v\[[0-9]+:[0-9]+\], s\[[0-9]+:[0-9]+\], -v\[[0-9]+:[0-9]+\]}}
98 ; SI: v_add_f64 {{v\[[0-9]+:[0-9]+\], s\[[0-9]+:[0-9]+\], -v\[[0-9]+:[0-9]+\]}}
99 ; SI: v_add_f64 {{v\[[0-9]+:[0-9]+\], s\[[0-9]+:[0-9]+\], -v\[[0-9]+:[0-9]+\]}}
100 ; SI: v_add_f64 {{v\[[0-9]+:[0-9]+\], s\[[0-9]+:[0-9]+\], -v\[[0-9]+:[0-9]+\]}}
101 define amdgpu_kernel void @s_fsub_v4f64(<4 x double> addrspace(1)* %out, <4 x double> %a, <4 x double> %b) {
102 %result = fsub <4 x double> %a, %b
103 store <4 x double> %result, <4 x double> addrspace(1)* %out, align 16
107 attributes #0 = { nounwind readnone }