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
4 define <2 x float> @fma_1(<2 x float> %A, <2 x float> %B, <2 x float> %C) {
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;
12 ; This case will fold as it was only available through unsafe before, now available from
13 ; the contract on the fadd
14 define <2 x float> @fma_2(<2 x float> %A, <2 x float> %B, <2 x float> %C) {
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;
22 define <2 x float> @no_fma_1(<2 x float> %A, <2 x float> %B, <2 x float> %C) {
23 ; CHECK-LABEL: no_fma_1:
26 %tmp1 = fmul contract <2 x float> %A, %B;
27 %tmp2 = fadd <2 x float> %C, %tmp1;
31 define <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;
39 ; This case will fold as it was only available through unsafe before, now available from
40 ; the contract on the fsub
41 define <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;
49 define <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:
53 %tmp1 = fmul contract <2 x float> %A, %B;
54 %tmp2 = fsub <2 x float> %C, %tmp1;
58 ; Regression test: contract FMF allows folding (A * 0 + B) to FMA(A, 0, B), but
59 ; reassoc FMF must not allow further folding to just (B) without additional
61 define float @fma_zero(float %A, float %B) {
62 ; CHECK-LABEL: fma_zero:
64 ; CHECK-NEXT: movi d2, #0000000000000000
65 ; CHECK-NEXT: fmadd s0, s0, s2, s1
67 %tmp1 = fmul contract reassoc float %A, 0.0e+0;
68 %tmp2 = fadd contract reassoc float %B, %tmp1;