The following makes sure to honor v2df_reduction_prefer_haddpd
when expanding reduc_plus_scal_V2DF via ix86_expand_reduc.

There is test coverage in gcc.target/i386/pr54400.c

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

OK?

Thanks,
Richard.

        PR target/126271
        * config/i386/i386-expand.cc (ix86_expand_reduc): Honor
        TARGET_V2DF_REDUCTION_PREFER_HADDPD and expand via
        gen_sse3_haddv2df3.
---
 gcc/config/i386/i386-expand.cc | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
index a448e470f73..0cd4a72256e 100644
--- a/gcc/config/i386/i386-expand.cc
+++ b/gcc/config/i386/i386-expand.cc
@@ -20079,6 +20079,15 @@ ix86_expand_reduc (rtx (*fn) (rtx, rtx, rtx), rtx 
dest, rtx in)
       return;
     }
 
+  /* SSE3 has haddpd, some targets prefer that over movhlpd plus add.  */
+  if (TARGET_SSE3
+      && TARGET_V2DF_REDUCTION_PREFER_HADDPD
+      && mode == V2DFmode)
+    {
+      emit_insn (gen_sse3_haddv2df3 (dest, in, in));
+      return;
+    }
+
   for (i = GET_MODE_BITSIZE (mode);
        i > GET_MODE_UNIT_BITSIZE (mode);
        i >>= 1)
-- 
2.51.0

Reply via email to