1; RUN: llc < %s -verify-machineinstrs -mtriple=aarch64-none-linux-gnu -mattr=+neon | FileCheck %s
2; RUN: llc < %s -O3 -verify-machineinstrs -mtriple=aarch64-none-linux-gnu -mattr=+neon | FileCheck %s
3
4define <2 x float> @fma_1(<2 x float> %A, <2 x float> %B, <2 x float> %C) {
5; CHECK-LABEL: fma_1:
6; CHECK: fmla {{v[0-9]+}}.2s, {{v[0-9]+}}.2s, {{v[0-9]+}}.2s
7	%tmp1 = fmul contract <2 x float> %A, %B;
8	%tmp2 = fadd contract <2 x float> %C, %tmp1;
9	ret <2 x float> %tmp2
10}
11
12; This case will fold as it was only available through unsafe before, now available from
13; the contract on the fadd
14define <2 x float> @fma_2(<2 x float> %A, <2 x float> %B, <2 x float> %C) {
15; CHECK-LABEL: fma_2:
16; CHECK: fmla {{v[0-9]+}}.2s, {{v[0-9]+}}.2s, {{v[0-9]+}}.2s
17	%tmp1 = fmul <2 x float> %A, %B;
18	%tmp2 = fadd contract <2 x float> %C, %tmp1;
19	ret <2 x float> %tmp2
20}
21
22define <2 x float> @no_fma_1(<2 x float> %A, <2 x float> %B, <2 x float> %C) {
23; CHECK-LABEL: no_fma_1:
24; CHECK: fmul
25; CHECK: fadd
26	%tmp1 = fmul contract <2 x float> %A, %B;
27	%tmp2 = fadd <2 x float> %C, %tmp1;
28	ret <2 x float> %tmp2
29}
30
31define <2 x float> @fma_sub_1(<2 x float> %A, <2 x float> %B, <2 x float> %C) {
32; CHECK-LABEL: fma_sub_1:
33; CHECK: fmls {{v[0-9]+}}.2s, {{v[0-9]+}}.2s, {{v[0-9]+}}.2s
34	%tmp1 = fmul contract <2 x float> %A, %B;
35	%tmp2 = fsub contract <2 x float> %C, %tmp1;
36	ret <2 x float> %tmp2
37}
38
39; This case will fold as it was only available through unsafe before, now available from
40; the contract on the fsub
41define <2 x float> @fma_sub_2(<2 x float> %A, <2 x float> %B, <2 x float> %C) {
42; CHECK-LABEL: fma_sub_2:
43; CHECK: fmls {{v[0-9]+}}.2s, {{v[0-9]+}}.2s, {{v[0-9]+}}.2s
44	%tmp1 = fmul <2 x float> %A, %B;
45	%tmp2 = fsub contract <2 x float> %C, %tmp1;
46	ret <2 x float> %tmp2
47}
48
49define <2 x float> @no_fma_sub_1(<2 x float> %A, <2 x float> %B, <2 x float> %C) {
50; CHECK-LABEL: no_fma_sub_1:
51; CHECK: fmul
52; CHECK: fsub
53	%tmp1 = fmul contract <2 x float> %A, %B;
54	%tmp2 = fsub <2 x float> %C, %tmp1;
55	ret <2 x float> %tmp2
56}
57