https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116274

Hongtao Liu <liuhongt at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |liuhongt at gcc dot gnu.org

--- Comment #4 from Hongtao Liu <liuhongt at gcc dot gnu.org> ---
W/ below patch, compiled with -march=x86-64-v3 -O3, redundant spills is gone.

diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index f044826269c..e8bcf314752 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -20292,6 +20292,10 @@ inline_secondary_memory_needed (machine_mode mode,
reg_class_t class1,
       if (!(INTEGER_CLASS_P (class1) || INTEGER_CLASS_P (class2)))
        return true;

+      /* *movti_internal supports movement between SSE_REGS and GENERAL_REGS. 
*/
+      if (mode == TImode)
+       return false;
+
       int msize = GET_MODE_SIZE (mode);

       /* Between SSE and general, we have moves no larger than word size.  */


struct aq { long x,y; };
long testq(struct aq a) { return a.x+a.y; }

struct aw { short a0,a1,a2,a3,a4,a5,a6,a7; };
short testw(struct aw a) { return a.a0+a.a1+a.a2+a.a3+a.a4+a.a5+a.a6+a.a7; }

struct ad { int x,y,z,w; };
int testd(struct ad a) { return a.x+a.y+a.z+a.w; }

testq:
.LFB0:
        .cfi_startproc
        vmovq   %rdi, %xmm1
        vpinsrq $1, %rsi, %xmm1, %xmm1
        vpsrldq $8, %xmm1, %xmm0
        vpaddq  %xmm1, %xmm0, %xmm0
        vmovq   %xmm0, %rax
        ret
        .cfi_endproc
.LFE0:
        .size   testq, .-testq
        .p2align 4
        .globl  testw
        .type   testw, @function
testw:
.LFB1:
        .cfi_startproc
        vmovq   %rdi, %xmm1
        vpinsrq $1, %rsi, %xmm1, %xmm1
        vpsrldq $8, %xmm1, %xmm0
        vpaddw  %xmm1, %xmm0, %xmm0
        vpsrldq $4, %xmm0, %xmm1
        vpaddw  %xmm1, %xmm0, %xmm0
        vpsrldq $2, %xmm0, %xmm1
        vpaddw  %xmm1, %xmm0, %xmm0
        vpextrw $0, %xmm0, %eax
        ret
        .cfi_endproc
.LFE1:
        .size   testw, .-testw
        .p2align 4
        .globl  testd
        .type   testd, @function
testd:
.LFB2:
        .cfi_startproc
        vmovq   %rdi, %xmm1
        vpinsrq $1, %rsi, %xmm1, %xmm1
        vpsrldq $8, %xmm1, %xmm0
        vpaddd  %xmm1, %xmm0, %xmm0
        vpsrldq $4, %xmm0, %xmm1
        vpaddd  %xmm1, %xmm0, %xmm0
        vmovd   %xmm0, %eax
        ret
        .cfi_endproc

But with -march=x86-64-v2 or -march=x86-64 -O3, the spills are still there,
hmm.

Reply via email to