1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mattr=+fma4,-fma | FileCheck %s
3 ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mattr=+fma4,+fma | FileCheck %s
5 declare <4 x float> @llvm.x86.fma4.vfmadd.ss(<4 x float> %a, <4 x float> %b, <4 x float> %c)
6 declare <2 x double> @llvm.x86.fma4.vfmadd.sd(<2 x double> %a, <2 x double> %b, <2 x double> %c)
8 ; TODO this can be negated
9 define <4 x float> @test1(<4 x float> %a, <4 x float> %b, <4 x float> %c) {
12 ; CHECK-NEXT: vfmaddss {{.*#+}} xmm0 = (xmm0 * xmm1) + xmm2
13 ; CHECK-NEXT: vxorps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
15 %res = tail call <4 x float> @llvm.x86.fma4.vfmadd.ss(<4 x float> %a, <4 x float> %b, <4 x float> %c)
16 %sub.i = fsub <4 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, %res
17 ret <4 x float> %sub.i
20 define <4 x float> @test2(<4 x float> %a, <4 x float> %b, <4 x float> %c) {
23 ; CHECK-NEXT: vfmsubss {{.*#+}} xmm0 = (xmm0 * xmm1) - xmm2
25 %sub.i = fsub <4 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, %c
26 %res = tail call <4 x float> @llvm.x86.fma4.vfmadd.ss(<4 x float> %a, <4 x float> %b, <4 x float> %sub.i)
30 define <4 x float> @test3(<4 x float> %a, <4 x float> %b, <4 x float> %c) {
33 ; CHECK-NEXT: vfnmaddss {{.*#+}} xmm0 = -(xmm0 * xmm1) + xmm2
35 %sub.i = fsub <4 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, %b
36 %res = tail call <4 x float> @llvm.x86.fma4.vfmadd.ss(<4 x float> %a, <4 x float> %sub.i, <4 x float> %c)
40 define <4 x float> @test4(<4 x float> %a, <4 x float> %b, <4 x float> %c) {
43 ; CHECK-NEXT: vfnmaddss {{.*#+}} xmm0 = -(xmm0 * xmm1) + xmm2
45 %sub.i = fsub <4 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, %a
46 %res = tail call <4 x float> @llvm.x86.fma4.vfmadd.ss(<4 x float> %sub.i, <4 x float> %b, <4 x float> %c)
50 define <4 x float> @test5(<4 x float> %a, <4 x float> %b, <4 x float> %c) {
53 ; CHECK-NEXT: vfnmsubss {{.*#+}} xmm0 = -(xmm0 * xmm1) - xmm2
55 %sub.i = fsub <4 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, %a
56 %sub.i.2 = fsub <4 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, %c
57 %res = tail call <4 x float> @llvm.x86.fma4.vfmadd.ss(<4 x float> %sub.i, <4 x float> %b, <4 x float> %sub.i.2)
61 define <2 x double> @test6(<2 x double> %a, <2 x double> %b, <2 x double> %c) {
64 ; CHECK-NEXT: vfmaddsd {{.*#+}} xmm0 = (xmm0 * xmm1) + xmm2
65 ; CHECK-NEXT: vxorpd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
67 %res = tail call <2 x double> @llvm.x86.fma4.vfmadd.sd(<2 x double> %a, <2 x double> %b, <2 x double> %c)
68 %sub.i = fsub <2 x double> <double -0.000000e+00, double -0.000000e+00>, %res
69 ret <2 x double> %sub.i
72 define <2 x double> @test7(<2 x double> %a, <2 x double> %b, <2 x double> %c) {
75 ; CHECK-NEXT: vfmsubsd {{.*#+}} xmm0 = (xmm0 * xmm1) - xmm2
77 %sub.i = fsub <2 x double> <double -0.000000e+00, double -0.000000e+00>, %c
78 %res = tail call <2 x double> @llvm.x86.fma4.vfmadd.sd(<2 x double> %a, <2 x double> %b, <2 x double> %sub.i)
82 define <2 x double> @test8(<2 x double> %a, <2 x double> %b, <2 x double> %c) {
85 ; CHECK-NEXT: vfnmaddsd {{.*#+}} xmm0 = -(xmm0 * xmm1) + xmm2
87 %sub.i = fsub <2 x double> <double -0.000000e+00, double -0.000000e+00>, %b
88 %res = tail call <2 x double> @llvm.x86.fma4.vfmadd.sd(<2 x double> %a, <2 x double> %sub.i, <2 x double> %c)
92 define <2 x double> @test9(<2 x double> %a, <2 x double> %b, <2 x double> %c) {
95 ; CHECK-NEXT: vfnmaddsd {{.*#+}} xmm0 = -(xmm0 * xmm1) + xmm2
97 %sub.i = fsub <2 x double> <double -0.000000e+00, double -0.000000e+00>, %a
98 %res = tail call <2 x double> @llvm.x86.fma4.vfmadd.sd(<2 x double> %sub.i, <2 x double> %b, <2 x double> %c)
102 define <2 x double> @test10(<2 x double> %a, <2 x double> %b, <2 x double> %c) {
103 ; CHECK-LABEL: test10:
105 ; CHECK-NEXT: vfnmsubsd {{.*#+}} xmm0 = -(xmm0 * xmm1) - xmm2
107 %sub.i = fsub <2 x double> <double -0.000000e+00, double -0.000000e+00>, %a
108 %sub.i.2 = fsub <2 x double> <double -0.000000e+00, double -0.000000e+00>, %c
109 %res = tail call <2 x double> @llvm.x86.fma4.vfmadd.sd(<2 x double> %sub.i, <2 x double> %b, <2 x double> %sub.i.2)
110 ret <2 x double> %res