diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index 8dea0570356..43afcfdc750 100644 --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -5803,21 +5803,21 @@ ;; But this doesn't seem useful in practice. (define_expand "vec_fmaddsub4" - [(set (match_operand:VF 0 "register_operand") - (unspec:VF - [(match_operand:VF 1 "nonimmediate_operand") - (match_operand:VF 2 "nonimmediate_operand") - (match_operand:VF 3 "nonimmediate_operand")] + [(set (match_operand:VFH 0 "register_operand") + (unspec:VFH + [(match_operand:VFH 1 "nonimmediate_operand") + (match_operand:VFH 2 "nonimmediate_operand") + (match_operand:VFH 3 "nonimmediate_operand")] UNSPEC_FMADDSUB))] "TARGET_FMA || TARGET_FMA4 || ( == 64 || TARGET_AVX512VL)") (define_expand "vec_fmsubadd4" - [(set (match_operand:VF 0 "register_operand") - (unspec:VF - [(match_operand:VF 1 "nonimmediate_operand") - (match_operand:VF 2 "nonimmediate_operand") - (neg:VF - (match_operand:VF 3 "nonimmediate_operand"))] + [(set (match_operand:VFH 0 "register_operand") + (unspec:VFH + [(match_operand:VFH 1 "nonimmediate_operand") + (match_operand:VFH 2 "nonimmediate_operand") + (neg:VFH + (match_operand:VFH 3 "nonimmediate_operand"))] UNSPEC_FMADDSUB))] "TARGET_FMA || TARGET_FMA4 || ( == 64 || TARGET_AVX512VL)") @@ -5877,11 +5877,11 @@ (set_attr "mode" "")]) (define_insn "fma_fmaddsub_" - [(set (match_operand:VFH_SF_AVX512VL 0 "register_operand" "=v,v,v") - (unspec:VFH_SF_AVX512VL - [(match_operand:VFH_SF_AVX512VL 1 "" "%0,0,v") - (match_operand:VFH_SF_AVX512VL 2 "" ",v,") - (match_operand:VFH_SF_AVX512VL 3 "" "v,,0")] + [(set (match_operand:VFH_AVX512VL 0 "register_operand" "=v,v,v") + (unspec:VFH_AVX512VL + [(match_operand:VFH_AVX512VL 1 "" "%0,0,v") + (match_operand:VFH_AVX512VL 2 "" ",v,") + (match_operand:VFH_AVX512VL 3 "" "v,,0")] UNSPEC_FMADDSUB))] "TARGET_AVX512F && && " "@ @@ -5943,12 +5943,12 @@ (set_attr "mode" "")]) (define_insn "fma_fmsubadd_" - [(set (match_operand:VFH_SF_AVX512VL 0 "register_operand" "=v,v,v") - (unspec:VFH_SF_AVX512VL - [(match_operand:VFH_SF_AVX512VL 1 "" "%0,0,v") - (match_operand:VFH_SF_AVX512VL 2 "" ",v,") - (neg:VFH_SF_AVX512VL - (match_operand:VFH_SF_AVX512VL 3 "" "v,,0"))] + [(set (match_operand:VFH_AVX512VL 0 "register_operand" "=v,v,v") + (unspec:VFH_AVX512VL + [(match_operand:VFH_AVX512VL 1 "" "%0,0,v") + (match_operand:VFH_AVX512VL 2 "" ",v,") + (neg:VFH_AVX512VL + (match_operand:VFH_AVX512VL 3 "" "v,,0"))] UNSPEC_FMADDSUB))] "TARGET_AVX512F && && " "@ diff --git a/gcc/testsuite/gcc.target/i386/pr81904.c b/gcc/testsuite/gcc.target/i386/pr81904.c new file mode 100644 index 00000000000..9f5ad0bd952 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr81904.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512fp16 -mavx512vl -O2 -mprefer-vector-width=512" } */ +/* { dg-final { scan-assembler-times "vfmaddsub...ph\[ \t\]+\[^\n\]*%zmm\[0-9\]" 1 } } */ +/* { dg-final { scan-assembler-times "vfmsubadd...ph\[ \t\]+\[^\n\]*%zmm\[0-9\]" 1 } } */ + +void vec_fmaddsub_fp16(int n, _Float16 da_r, _Float16 *x, _Float16* y, _Float16* __restrict z) +{ + for (int i = 0; i < 32; i += 2) + { + z[i] = da_r * x[i] - y[i]; + z[i+1] = da_r * x[i+1] + y[i+1]; + } +} + +void vec_fmasubadd_fp16(int n, _Float16 da_r, _Float16 *x, _Float16* y, _Float16* __restrict z) +{ + for (int i = 0; i < 32; i += 2) + { + z[i] = da_r * x[i] + y[i]; + z[i+1] = da_r * x[i+1] - y[i+1]; + } +}