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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.8.0
             Status|NEW                         |RESOLVED
      Known to work|                            |4.8.0
           Keywords|                            |ra
         Resolution|---                         |FIXED

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The problem was this RTL:
(insn 7 2 25 2 (set (reg:V4SI 65 [ MEM[(int[8] *)&baz] ])
        (mem/c:V4SI (symbol_ref:SI ("baz") [flags 0x2]  <var_decl
0x7fc7df4971e0 baz>) [2 MEM[(int[8] *)&baz]+0 S16 A256])) /app/example.cpp:19
1080 {*movv4si_internal}
     (nil))

(insn 25 7 26 2 (set (reg:SI 72)
        (subreg:SI (reg:V4SI 65 [ MEM[(int[8] *)&baz] ]) 0))
/app/example.cpp:19 -1
     (nil))

Which was produced by dse.

In GCC 4.8 we produce the same except lra produces:
(insn 25 7 26 2 (set (reg:SI 0 ax [72])
        (mem/c:SI (symbol_ref:SI ("baz") [flags 0x2]  <var_decl 0x7ffb6912d428
baz>) [2 MEM[(int[8] *)&baz]+0 S4 A256])) /app/example.cpp:19 89
{*movsi_internal}
     (nil))

So this got fixed with the new reload (LRA) :).


Note -fno-tree-loop-distribute-patterns is needed otherwise you get a memcpy
:).
With -mno-sse, the extra register push was gone in GCC 4.6.0.

GCC 8 also no longer vectorizers the code based on the cost model of pentium3,
you need to add -fno-vect-cost-model.

Starting GCC 9, GCC is able to produce for -msse2 case:
        movd    %xmm0, %eax

Anyways the original issue is fixed.


With the trunk -O3 -m32 -msse GCC produces:
foo2():
        movdqa  baz, %xmm7
        movd    %xmm7, %eax
        movaps  %xmm7, bar
        movdqa  baz+16, %xmm7
        movaps  %xmm7, bar+16
        ret

With -O3 -m32 -msse2:
foo2():
        movdqa  baz, %xmm7
        movd    %xmm7, %eax
        movaps  %xmm7, bar
        movdqa  baz+16, %xmm7
        movaps  %xmm7, bar+16
        ret

The problem is -march=pentium3 causes a loop for the memcpy (tuning).

Reply via email to