https://gcc.gnu.org/g:6e3bda5937eab9120635e5ddf15c7e332db69583

commit r17-2554-g6e3bda5937eab9120635e5ddf15c7e332db69583
Author: Richard Biener <[email protected]>
Date:   Thu Jul 16 15:20:25 2026 +0200

    target/126271 - honor v2df_reduction_prefer_haddpd better
    
    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
    
            PR target/126271
            * config/i386/i386-expand.cc (ix86_expand_reduc): Honor
            TARGET_V2DF_REDUCTION_PREFER_HADDPD and expand via
            gen_sse3_haddv2df3.

Diff:
---
 gcc/config/i386/i386-expand.cc | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
index bdd75067a007..fde8002eddbf 100644
--- a/gcc/config/i386/i386-expand.cc
+++ b/gcc/config/i386/i386-expand.cc
@@ -20083,6 +20083,16 @@ 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
+      && fn == gen_addv2df3)
+    {
+      emit_insn (gen_sse3_haddv2df3 (dest, in, in));
+      return;
+    }
+
   for (i = GET_MODE_BITSIZE (mode);
        i > GET_MODE_UNIT_BITSIZE (mode);
        i >>= 1)

Reply via email to