1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+avx2,+fma | FileCheck %s --check-prefix=X32
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2,+fma | FileCheck %s --check-prefix=X64
5 ; This test checks combinations of FNEG and FMA intrinsics
7 define <8 x float> @test1(<8 x float> %a, <8 x float> %b, <8 x float> %c) {
9 ; X32: # %bb.0: # %entry
10 ; X32-NEXT: vfmsub213ps {{.*#+}} ymm0 = (ymm1 * ymm0) - ymm2
14 ; X64: # %bb.0: # %entry
15 ; X64-NEXT: vfmsub213ps {{.*#+}} ymm0 = (ymm1 * ymm0) - ymm2
18 %sub.i = 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>, %c
19 %0 = tail call <8 x float> @llvm.x86.fma.vfmadd.ps.256(<8 x float> %a, <8 x float> %b, <8 x float> %sub.i) #2
23 declare <8 x float> @llvm.x86.fma.vfmadd.ps.256(<8 x float>, <8 x float>, <8 x float>)
25 define <4 x float> @test2(<4 x float> %a, <4 x float> %b, <4 x float> %c) {
27 ; X32: # %bb.0: # %entry
28 ; X32-NEXT: vfnmsub213ps {{.*#+}} xmm0 = -(xmm1 * xmm0) - xmm2
32 ; X64: # %bb.0: # %entry
33 ; X64-NEXT: vfnmsub213ps {{.*#+}} xmm0 = -(xmm1 * xmm0) - xmm2
36 %0 = tail call <4 x float> @llvm.x86.fma.vfmadd.ps(<4 x float> %a, <4 x float> %b, <4 x float> %c) #2
37 %sub.i = fsub <4 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, %0
38 ret <4 x float> %sub.i
41 declare <4 x float> @llvm.x86.fma.vfmadd.ps(<4 x float> %a, <4 x float> %b, <4 x float> %c)
43 define <4 x float> @test3(<4 x float> %a, <4 x float> %b, <4 x float> %c) {
45 ; X32: # %bb.0: # %entry
46 ; X32-NEXT: vfnmadd213ss {{.*#+}} xmm0 = -(xmm1 * xmm0) + xmm2
47 ; X32-NEXT: vbroadcastss {{.*#+}} xmm1 = [-0.0E+0,-0.0E+0,-0.0E+0,-0.0E+0]
48 ; X32-NEXT: vxorps %xmm1, %xmm0, %xmm0
52 ; X64: # %bb.0: # %entry
53 ; X64-NEXT: vfnmadd213ss {{.*#+}} xmm0 = -(xmm1 * xmm0) + xmm2
54 ; X64-NEXT: vbroadcastss {{.*#+}} xmm1 = [-0.0E+0,-0.0E+0,-0.0E+0,-0.0E+0]
55 ; X64-NEXT: vxorps %xmm1, %xmm0, %xmm0
58 %0 = tail call <4 x float> @llvm.x86.fma.vfnmadd.ss(<4 x float> %a, <4 x float> %b, <4 x float> %c) #2
59 %sub.i = fsub <4 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, %0
60 ret <4 x float> %sub.i
63 declare <4 x float> @llvm.x86.fma.vfnmadd.ss(<4 x float> %a, <4 x float> %b, <4 x float> %c)
65 define <8 x float> @test4(<8 x float> %a, <8 x float> %b, <8 x float> %c) {
67 ; X32: # %bb.0: # %entry
68 ; X32-NEXT: vfnmadd213ps {{.*#+}} ymm0 = -(ymm1 * ymm0) + ymm2
72 ; X64: # %bb.0: # %entry
73 ; X64-NEXT: vfnmadd213ps {{.*#+}} ymm0 = -(ymm1 * ymm0) + ymm2
76 %0 = tail call <8 x float> @llvm.x86.fma.vfmsub.ps.256(<8 x float> %a, <8 x float> %b, <8 x float> %c) #2
77 %sub.i = 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>, %0
78 ret <8 x float> %sub.i
81 define <8 x float> @test5(<8 x float> %a, <8 x float> %b, <8 x float> %c) {
83 ; X32: # %bb.0: # %entry
84 ; X32-NEXT: vfmadd213ps {{.*#+}} ymm0 = (ymm1 * ymm0) + ymm2
88 ; X64: # %bb.0: # %entry
89 ; X64-NEXT: vfmadd213ps {{.*#+}} ymm0 = (ymm1 * ymm0) + ymm2
92 %sub.c = 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>, %c
93 %0 = tail call <8 x float> @llvm.x86.fma.vfmsub.ps.256(<8 x float> %a, <8 x float> %b, <8 x float> %sub.c) #2
97 declare <8 x float> @llvm.x86.fma.vfmsub.ps.256(<8 x float>, <8 x float>, <8 x float>)
100 define <2 x double> @test6(<2 x double> %a, <2 x double> %b, <2 x double> %c) {
102 ; X32: # %bb.0: # %entry
103 ; X32-NEXT: vfnmsub213pd {{.*#+}} xmm0 = -(xmm1 * xmm0) - xmm2
107 ; X64: # %bb.0: # %entry
108 ; X64-NEXT: vfnmsub213pd {{.*#+}} xmm0 = -(xmm1 * xmm0) - xmm2
111 %0 = tail call <2 x double> @llvm.x86.fma.vfmadd.pd(<2 x double> %a, <2 x double> %b, <2 x double> %c) #2
112 %sub.i = fsub <2 x double> <double -0.000000e+00, double -0.000000e+00>, %0
113 ret <2 x double> %sub.i
116 declare <2 x double> @llvm.x86.fma.vfmadd.pd(<2 x double> %a, <2 x double> %b, <2 x double> %c)
118 define <8 x float> @test7(float %a, <8 x float> %b, <8 x float> %c) {
120 ; X32: # %bb.0: # %entry
121 ; X32-NEXT: vbroadcastss {{[0-9]+}}(%esp), %ymm2
122 ; X32-NEXT: vfnmadd213ps {{.*#+}} ymm0 = -(ymm2 * ymm0) + ymm1
126 ; X64: # %bb.0: # %entry
127 ; X64-NEXT: vbroadcastss %xmm0, %ymm0
128 ; X64-NEXT: vfnmadd213ps {{.*#+}} ymm0 = -(ymm1 * ymm0) + ymm2
131 %0 = insertelement <8 x float> undef, float %a, i32 0
132 %1 = fsub <8 x float> <float -0.000000e+00, float undef, float undef, float undef, float undef, float undef, float undef, float undef>, %0
133 %2 = shufflevector <8 x float> %1, <8 x float> undef, <8 x i32> zeroinitializer
134 %3 = tail call <8 x float> @llvm.fma.v8f32(<8 x float> %2, <8 x float> %b, <8 x float> %c)
139 define <8 x float> @test8(float %a, <8 x float> %b, <8 x float> %c) {
141 ; X32: # %bb.0: # %entry
142 ; X32-NEXT: vbroadcastss {{[0-9]+}}(%esp), %ymm2
143 ; X32-NEXT: vfnmadd213ps {{.*#+}} ymm0 = -(ymm2 * ymm0) + ymm1
147 ; X64: # %bb.0: # %entry
148 ; X64-NEXT: vbroadcastss %xmm0, %ymm0
149 ; X64-NEXT: vfnmadd213ps {{.*#+}} ymm0 = -(ymm1 * ymm0) + ymm2
152 %0 = fsub float -0.0, %a
153 %1 = insertelement <8 x float> undef, float %0, i32 0
154 %2 = shufflevector <8 x float> %1, <8 x float> undef, <8 x i32> zeroinitializer
155 %3 = tail call <8 x float> @llvm.fma.v8f32(<8 x float> %2, <8 x float> %b, <8 x float> %c)
159 declare <8 x float> @llvm.fma.v8f32(<8 x float> %a, <8 x float> %b, <8 x float> %c)