; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mcpu=core-avx2 | FileCheck %s --check-prefix=CHECK --check-prefix=AVX2
; RUN: llc < %s -mcpu=skx | FileCheck %s --check-prefix=CHECK --check-prefix=AVX512
+; RUN: llc < %s -mattr=fma4 | FileCheck %s --check-prefix=FMA4
target triple = "x86_64-unknown-unknown"
; CHECK-NEXT: vfmadd213ss (%rsi), %xmm0, %xmm0
; CHECK-NEXT: vmovss %xmm0, (%rdi)
; CHECK-NEXT: retq
+;
+; FMA4-LABEL: fmadd_aab_ss:
+; FMA4: # BB#0:
+; FMA4-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
+; FMA4-NEXT: vmovss {{.*#+}} xmm1 = mem[0],zero,zero,zero
+; FMA4-NEXT: vfmaddss %xmm1, %xmm0, %xmm0, %xmm0
+; FMA4-NEXT: vmovss %xmm0, (%rdi)
+; FMA4-NEXT: retq
%a.val = load float, float* %a
%av0 = insertelement <4 x float> undef, float %a.val, i32 0
%av1 = insertelement <4 x float> %av0, float 0.000000e+00, i32 1
; CHECK-NEXT: vfmadd132ss (%rsi), %xmm0, %xmm0
; CHECK-NEXT: vmovss %xmm0, (%rdi)
; CHECK-NEXT: retq
+;
+; FMA4-LABEL: fmadd_aba_ss:
+; FMA4: # BB#0:
+; FMA4-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
+; FMA4-NEXT: vmovss {{.*#+}} xmm1 = mem[0],zero,zero,zero
+; FMA4-NEXT: vfmaddss %xmm0, %xmm1, %xmm0, %xmm0
+; FMA4-NEXT: vmovss %xmm0, (%rdi)
+; FMA4-NEXT: retq
%a.val = load float, float* %a
%av0 = insertelement <4 x float> undef, float %a.val, i32 0
%av1 = insertelement <4 x float> %av0, float 0.000000e+00, i32 1
; CHECK-NEXT: vfmsub213ss (%rsi), %xmm0, %xmm0
; CHECK-NEXT: vmovss %xmm0, (%rdi)
; CHECK-NEXT: retq
+;
+; FMA4-LABEL: fmsub_aab_ss:
+; FMA4: # BB#0:
+; FMA4-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
+; FMA4-NEXT: vmovss {{.*#+}} xmm1 = mem[0],zero,zero,zero
+; FMA4-NEXT: vfmsubss %xmm1, %xmm0, %xmm0, %xmm0
+; FMA4-NEXT: vmovss %xmm0, (%rdi)
+; FMA4-NEXT: retq
%a.val = load float, float* %a
%av0 = insertelement <4 x float> undef, float %a.val, i32 0
%av1 = insertelement <4 x float> %av0, float 0.000000e+00, i32 1
; CHECK-NEXT: vfmsub132ss (%rsi), %xmm0, %xmm0
; CHECK-NEXT: vmovss %xmm0, (%rdi)
; CHECK-NEXT: retq
+;
+; FMA4-LABEL: fmsub_aba_ss:
+; FMA4: # BB#0:
+; FMA4-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
+; FMA4-NEXT: vmovss {{.*#+}} xmm1 = mem[0],zero,zero,zero
+; FMA4-NEXT: vfmsubss %xmm0, %xmm1, %xmm0, %xmm0
+; FMA4-NEXT: vmovss %xmm0, (%rdi)
+; FMA4-NEXT: retq
%a.val = load float, float* %a
%av0 = insertelement <4 x float> undef, float %a.val, i32 0
%av1 = insertelement <4 x float> %av0, float 0.000000e+00, i32 1
; CHECK-NEXT: vfnmadd213ss (%rsi), %xmm0, %xmm0
; CHECK-NEXT: vmovss %xmm0, (%rdi)
; CHECK-NEXT: retq
+;
+; FMA4-LABEL: fnmadd_aab_ss:
+; FMA4: # BB#0:
+; FMA4-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
+; FMA4-NEXT: vmovss {{.*#+}} xmm1 = mem[0],zero,zero,zero
+; FMA4-NEXT: vfnmaddss %xmm1, %xmm0, %xmm0, %xmm0
+; FMA4-NEXT: vmovss %xmm0, (%rdi)
+; FMA4-NEXT: retq
%a.val = load float, float* %a
%av0 = insertelement <4 x float> undef, float %a.val, i32 0
%av1 = insertelement <4 x float> %av0, float 0.000000e+00, i32 1
; CHECK-NEXT: vfnmadd132ss (%rsi), %xmm0, %xmm0
; CHECK-NEXT: vmovss %xmm0, (%rdi)
; CHECK-NEXT: retq
+;
+; FMA4-LABEL: fnmadd_aba_ss:
+; FMA4: # BB#0:
+; FMA4-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
+; FMA4-NEXT: vmovss {{.*#+}} xmm1 = mem[0],zero,zero,zero
+; FMA4-NEXT: vfnmaddss %xmm0, %xmm1, %xmm0, %xmm0
+; FMA4-NEXT: vmovss %xmm0, (%rdi)
+; FMA4-NEXT: retq
%a.val = load float, float* %a
%av0 = insertelement <4 x float> undef, float %a.val, i32 0
%av1 = insertelement <4 x float> %av0, float 0.000000e+00, i32 1
; CHECK-NEXT: vfnmsub213ss (%rsi), %xmm0, %xmm0
; CHECK-NEXT: vmovss %xmm0, (%rdi)
; CHECK-NEXT: retq
+;
+; FMA4-LABEL: fnmsub_aab_ss:
+; FMA4: # BB#0:
+; FMA4-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
+; FMA4-NEXT: vmovss {{.*#+}} xmm1 = mem[0],zero,zero,zero
+; FMA4-NEXT: vfnmsubss %xmm1, %xmm0, %xmm0, %xmm0
+; FMA4-NEXT: vmovss %xmm0, (%rdi)
+; FMA4-NEXT: retq
%a.val = load float, float* %a
%av0 = insertelement <4 x float> undef, float %a.val, i32 0
%av1 = insertelement <4 x float> %av0, float 0.000000e+00, i32 1
; CHECK-NEXT: vfnmsub132ss (%rsi), %xmm0, %xmm0
; CHECK-NEXT: vmovss %xmm0, (%rdi)
; CHECK-NEXT: retq
+;
+; FMA4-LABEL: fnmsub_aba_ss:
+; FMA4: # BB#0:
+; FMA4-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
+; FMA4-NEXT: vmovss {{.*#+}} xmm1 = mem[0],zero,zero,zero
+; FMA4-NEXT: vfnmsubss %xmm0, %xmm1, %xmm0, %xmm0
+; FMA4-NEXT: vmovss %xmm0, (%rdi)
+; FMA4-NEXT: retq
%a.val = load float, float* %a
%av0 = insertelement <4 x float> undef, float %a.val, i32 0
%av1 = insertelement <4 x float> %av0, float 0.000000e+00, i32 1
; CHECK-NEXT: vfmadd213sd (%rsi), %xmm0, %xmm0
; CHECK-NEXT: vmovlpd %xmm0, (%rdi)
; CHECK-NEXT: retq
+;
+; FMA4-LABEL: fmadd_aab_sd:
+; FMA4: # BB#0:
+; FMA4-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
+; FMA4-NEXT: vmovsd {{.*#+}} xmm1 = mem[0],zero
+; FMA4-NEXT: vfmaddsd %xmm1, %xmm0, %xmm0, %xmm0
+; FMA4-NEXT: vmovlpd %xmm0, (%rdi)
+; FMA4-NEXT: retq
%a.val = load double, double* %a
%av0 = insertelement <2 x double> undef, double %a.val, i32 0
%av = insertelement <2 x double> %av0, double 0.000000e+00, i32 1
; CHECK-NEXT: vfmadd132sd (%rsi), %xmm0, %xmm0
; CHECK-NEXT: vmovlpd %xmm0, (%rdi)
; CHECK-NEXT: retq
+;
+; FMA4-LABEL: fmadd_aba_sd:
+; FMA4: # BB#0:
+; FMA4-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
+; FMA4-NEXT: vmovsd {{.*#+}} xmm1 = mem[0],zero
+; FMA4-NEXT: vfmaddsd %xmm0, %xmm1, %xmm0, %xmm0
+; FMA4-NEXT: vmovlpd %xmm0, (%rdi)
+; FMA4-NEXT: retq
%a.val = load double, double* %a
%av0 = insertelement <2 x double> undef, double %a.val, i32 0
%av = insertelement <2 x double> %av0, double 0.000000e+00, i32 1
; CHECK-NEXT: vfmsub213sd (%rsi), %xmm0, %xmm0
; CHECK-NEXT: vmovlpd %xmm0, (%rdi)
; CHECK-NEXT: retq
+;
+; FMA4-LABEL: fmsub_aab_sd:
+; FMA4: # BB#0:
+; FMA4-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
+; FMA4-NEXT: vmovsd {{.*#+}} xmm1 = mem[0],zero
+; FMA4-NEXT: vfmsubsd %xmm1, %xmm0, %xmm0, %xmm0
+; FMA4-NEXT: vmovlpd %xmm0, (%rdi)
+; FMA4-NEXT: retq
%a.val = load double, double* %a
%av0 = insertelement <2 x double> undef, double %a.val, i32 0
%av = insertelement <2 x double> %av0, double 0.000000e+00, i32 1
; CHECK-NEXT: vfmsub132sd (%rsi), %xmm0, %xmm0
; CHECK-NEXT: vmovlpd %xmm0, (%rdi)
; CHECK-NEXT: retq
+;
+; FMA4-LABEL: fmsub_aba_sd:
+; FMA4: # BB#0:
+; FMA4-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
+; FMA4-NEXT: vmovsd {{.*#+}} xmm1 = mem[0],zero
+; FMA4-NEXT: vfmsubsd %xmm0, %xmm1, %xmm0, %xmm0
+; FMA4-NEXT: vmovlpd %xmm0, (%rdi)
+; FMA4-NEXT: retq
%a.val = load double, double* %a
%av0 = insertelement <2 x double> undef, double %a.val, i32 0
%av = insertelement <2 x double> %av0, double 0.000000e+00, i32 1
; CHECK-NEXT: vfnmadd213sd (%rsi), %xmm0, %xmm0
; CHECK-NEXT: vmovlpd %xmm0, (%rdi)
; CHECK-NEXT: retq
+;
+; FMA4-LABEL: fnmadd_aab_sd:
+; FMA4: # BB#0:
+; FMA4-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
+; FMA4-NEXT: vmovsd {{.*#+}} xmm1 = mem[0],zero
+; FMA4-NEXT: vfnmaddsd %xmm1, %xmm0, %xmm0, %xmm0
+; FMA4-NEXT: vmovlpd %xmm0, (%rdi)
+; FMA4-NEXT: retq
%a.val = load double, double* %a
%av0 = insertelement <2 x double> undef, double %a.val, i32 0
%av = insertelement <2 x double> %av0, double 0.000000e+00, i32 1
; CHECK-NEXT: vfnmadd132sd (%rsi), %xmm0, %xmm0
; CHECK-NEXT: vmovlpd %xmm0, (%rdi)
; CHECK-NEXT: retq
+;
+; FMA4-LABEL: fnmadd_aba_sd:
+; FMA4: # BB#0:
+; FMA4-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
+; FMA4-NEXT: vmovsd {{.*#+}} xmm1 = mem[0],zero
+; FMA4-NEXT: vfnmaddsd %xmm0, %xmm1, %xmm0, %xmm0
+; FMA4-NEXT: vmovlpd %xmm0, (%rdi)
+; FMA4-NEXT: retq
%a.val = load double, double* %a
%av0 = insertelement <2 x double> undef, double %a.val, i32 0
%av = insertelement <2 x double> %av0, double 0.000000e+00, i32 1
; CHECK-NEXT: vfnmsub213sd (%rsi), %xmm0, %xmm0
; CHECK-NEXT: vmovlpd %xmm0, (%rdi)
; CHECK-NEXT: retq
+;
+; FMA4-LABEL: fnmsub_aab_sd:
+; FMA4: # BB#0:
+; FMA4-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
+; FMA4-NEXT: vmovsd {{.*#+}} xmm1 = mem[0],zero
+; FMA4-NEXT: vfnmsubsd %xmm1, %xmm0, %xmm0, %xmm0
+; FMA4-NEXT: vmovlpd %xmm0, (%rdi)
+; FMA4-NEXT: retq
%a.val = load double, double* %a
%av0 = insertelement <2 x double> undef, double %a.val, i32 0
%av = insertelement <2 x double> %av0, double 0.000000e+00, i32 1
; CHECK-NEXT: vfnmsub132sd (%rsi), %xmm0, %xmm0
; CHECK-NEXT: vmovlpd %xmm0, (%rdi)
; CHECK-NEXT: retq
+;
+; FMA4-LABEL: fnmsub_aba_sd:
+; FMA4: # BB#0:
+; FMA4-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
+; FMA4-NEXT: vmovsd {{.*#+}} xmm1 = mem[0],zero
+; FMA4-NEXT: vfnmsubsd %xmm0, %xmm1, %xmm0, %xmm0
+; FMA4-NEXT: vmovlpd %xmm0, (%rdi)
+; FMA4-NEXT: retq
%a.val = load double, double* %a
%av0 = insertelement <2 x double> undef, double %a.val, i32 0
%av = insertelement <2 x double> %av0, double 0.000000e+00, i32 1