1 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=core-avx2 -mattr=avx2,+fma -fp-contract=fast | FileCheck %s
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=bdver2 -mattr=-fma4 -fp-contract=fast | FileCheck %s
4 ; CHECK: test_x86_fmadd_ps
5 ; CHECK: vfmadd213ps %xmm2, %xmm0, %xmm1
7 define <4 x float> @test_x86_fmadd_ps(<4 x float> %a0, <4 x float> %a1, <4 x float> %a2) {
8 %x = fmul <4 x float> %a0, %a1
9 %res = fadd <4 x float> %x, %a2
13 ; CHECK: test_x86_fmsub_ps
14 ; CHECK: fmsub213ps %xmm2, %xmm0, %xmm1
16 define <4 x float> @test_x86_fmsub_ps(<4 x float> %a0, <4 x float> %a1, <4 x float> %a2) {
17 %x = fmul <4 x float> %a0, %a1
18 %res = fsub <4 x float> %x, %a2
22 ; CHECK: test_x86_fnmadd_ps
23 ; CHECK: fnmadd213ps %xmm2, %xmm0, %xmm1
25 define <4 x float> @test_x86_fnmadd_ps(<4 x float> %a0, <4 x float> %a1, <4 x float> %a2) {
26 %x = fmul <4 x float> %a0, %a1
27 %res = fsub <4 x float> %a2, %x
31 ; CHECK: test_x86_fnmsub_ps
32 ; CHECK: fnmsub213ps %xmm2, %xmm0, %xmm1
34 define <4 x float> @test_x86_fnmsub_ps(<4 x float> %a0, <4 x float> %a1, <4 x float> %a2) {
35 %x = fmul <4 x float> %a0, %a1
36 %y = fsub <4 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, %x
37 %res = fsub <4 x float> %y, %a2
41 ; CHECK: test_x86_fmadd_ps_y
42 ; CHECK: vfmadd213ps %ymm2, %ymm0, %ymm1
44 define <8 x float> @test_x86_fmadd_ps_y(<8 x float> %a0, <8 x float> %a1, <8 x float> %a2) {
45 %x = fmul <8 x float> %a0, %a1
46 %res = fadd <8 x float> %x, %a2
50 ; CHECK: test_x86_fmsub_ps_y
51 ; CHECK: vfmsub213ps %ymm2, %ymm0, %ymm1
53 define <8 x float> @test_x86_fmsub_ps_y(<8 x float> %a0, <8 x float> %a1, <8 x float> %a2) {
54 %x = fmul <8 x float> %a0, %a1
55 %res = fsub <8 x float> %x, %a2
59 ; CHECK: test_x86_fnmadd_ps_y
60 ; CHECK: vfnmadd213ps %ymm2, %ymm0, %ymm1
62 define <8 x float> @test_x86_fnmadd_ps_y(<8 x float> %a0, <8 x float> %a1, <8 x float> %a2) {
63 %x = fmul <8 x float> %a0, %a1
64 %res = fsub <8 x float> %a2, %x
68 ; CHECK: test_x86_fnmsub_ps_y
69 ; CHECK: vfnmsub213ps %ymm2, %ymm0, %ymm1
71 define <8 x float> @test_x86_fnmsub_ps_y(<8 x float> %a0, <8 x float> %a1, <8 x float> %a2) {
72 %x = fmul <8 x float> %a0, %a1
73 %y = fsub <8 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, %x
74 %res = fsub <8 x float> %y, %a2
78 ; CHECK: test_x86_fmadd_pd_y
79 ; CHECK: vfmadd213pd %ymm2, %ymm0, %ymm1
81 define <4 x double> @test_x86_fmadd_pd_y(<4 x double> %a0, <4 x double> %a1, <4 x double> %a2) {
82 %x = fmul <4 x double> %a0, %a1
83 %res = fadd <4 x double> %x, %a2
87 ; CHECK: test_x86_fmsub_pd_y
88 ; CHECK: vfmsub213pd %ymm2, %ymm0, %ymm1
90 define <4 x double> @test_x86_fmsub_pd_y(<4 x double> %a0, <4 x double> %a1, <4 x double> %a2) {
91 %x = fmul <4 x double> %a0, %a1
92 %res = fsub <4 x double> %x, %a2
96 ; CHECK: test_x86_fmsub_pd
97 ; CHECK: vfmsub213pd %xmm2, %xmm0, %xmm1
99 define <2 x double> @test_x86_fmsub_pd(<2 x double> %a0, <2 x double> %a1, <2 x double> %a2) {
100 %x = fmul <2 x double> %a0, %a1
101 %res = fsub <2 x double> %x, %a2
102 ret <2 x double> %res
105 ; CHECK: test_x86_fnmadd_ss
106 ; CHECK: vfnmadd213ss %xmm2, %xmm0, %xmm1
108 define float @test_x86_fnmadd_ss(float %a0, float %a1, float %a2) {
109 %x = fmul float %a0, %a1
110 %res = fsub float %a2, %x
114 ; CHECK: test_x86_fnmadd_sd
115 ; CHECK: vfnmadd213sd %xmm2, %xmm0, %xmm1
117 define double @test_x86_fnmadd_sd(double %a0, double %a1, double %a2) {
118 %x = fmul double %a0, %a1
119 %res = fsub double %a2, %x
123 ; CHECK: test_x86_fmsub_sd
124 ; CHECK: vfmsub213sd %xmm2, %xmm0, %xmm1
126 define double @test_x86_fmsub_sd(double %a0, double %a1, double %a2) {
127 %x = fmul double %a0, %a1
128 %res = fsub double %x, %a2
132 ; CHECK: test_x86_fnmsub_ss
133 ; CHECK: vfnmsub213ss %xmm2, %xmm0, %xmm1
135 define float @test_x86_fnmsub_ss(float %a0, float %a1, float %a2) {
136 %x = fsub float -0.000000e+00, %a0
137 %y = fmul float %x, %a1
138 %res = fsub float %y, %a2