public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/13144] New: Bad memory-to-memory code for SSE
@ 2003-11-20 22:08 hjl at lucon dot org
  2003-12-06  9:19 ` [Bug target/13144] " pinskia at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: hjl at lucon dot org @ 2003-11-20 22:08 UTC (permalink / raw)
  To: gcc-bugs

When SSE is enabled, gcc generatea bad memory-to-memory code.

[hjl@gnu-1 memcpy]$ cat foo.c
char buf1 [64];
char buf2 [64];
 
 
void
bar ()
{
  memcpy (buf1, buf2, sizeof (buf1));
}
[hjl@gnu-1 memcpy]$ /usr/gcc-3.4/bin/gcc -msse -S -O2 foo.c
[hjl@gnu-1 memcpy]$ cat foo.s
        .file   "foo.c"
        .text
        .p2align 4,,15
.globl bar
        .type   bar, @function
bar:
        pushl   %ebp
        movl    buf2, %eax
        movl    %esp, %ebp
        popl    %ebp
        movl    %eax, buf1
        movl    buf2+4, %eax
        movl    %eax, buf1+4
        movl    buf2+8, %eax
        movl    %eax, buf1+8
        movl    buf2+12, %eax
        movl    %eax, buf1+12
        movl    buf2+16, %eax
        movl    %eax, buf1+16
        movl    buf2+20, %eax
        movl    %eax, buf1+20
        movl    buf2+24, %eax
        movl    %eax, buf1+24
        movl    buf2+28, %eax
        movl    %eax, buf1+28
        movl    buf2+32, %eax
        movl    %eax, buf1+32
        movl    buf2+36, %eax
        movl    %eax, buf1+36
        movl    buf2+40, %eax
        movl    %eax, buf1+40
        movl    buf2+44, %eax
        movl    %eax, buf1+44
        movl    buf2+48, %eax
        movl    %eax, buf1+48
        movl    buf2+52, %eax
        movl    %eax, buf1+52
        movl    buf2+56, %eax
        movl    %eax, buf1+56
        movl    buf2+60, %eax
        movl    %eax, buf1+60
        ret
        .size   bar, .-bar
        .comm   buf1,64,32
        .comm   buf2,64,32
        .section        .note.GNU-stack,"",@progbits
        .ident  "GCC: (GNU) 3.4 20031105 (experimental)"

It is because move_by_pieces_ninsns assumes TImode can be accessed
with 8 bit alignment. But the i386 backend won't do it. Should i386
define SLOW_UNALIGNED_ACCESS for TImode and move_by_pieces_ninsns
check the widest mode instead of word_mode for slow unaligned access?

-- 
           Summary: Bad memory-to-memory code for SSE
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hjl at lucon dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13144


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/13144] Bad memory-to-memory code for SSE
  2003-11-20 22:08 [Bug target/13144] New: Bad memory-to-memory code for SSE hjl at lucon dot org
@ 2003-12-06  9:19 ` pinskia at gcc dot gnu dot org
  2003-12-09 17:24 ` hjl at lucon dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-06  9:19 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-12-06 09:19 -------
I do not see anything wrong with the code.  What did you think was wrong with it?
In your example, the rtl produced is:
(set (mem/s:SI (plus:SI (reg/f:SI 58)
                (const_int 4 [0x4])) [2 buf2+4 S4 A8])
        (reg:SI 61))
So it is not using TI mode at all.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13144


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/13144] Bad memory-to-memory code for SSE
  2003-11-20 22:08 [Bug target/13144] New: Bad memory-to-memory code for SSE hjl at lucon dot org
  2003-12-06  9:19 ` [Bug target/13144] " pinskia at gcc dot gnu dot org
@ 2003-12-09 17:24 ` hjl at lucon dot org
  2003-12-09 17:47 ` [Bug target/13144] pessimize " pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: hjl at lucon dot org @ 2003-12-09 17:24 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From hjl at lucon dot org  2003-12-09 17:24 -------
How memcpy should be handled is based on the assumption that TImode can be
used. Since the backend can't use TImode for memcpy, it generates slow code.
The problem is move_by_pieces_ninsns may return bogus values when TImode is
available, which leads to less optimized code.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13144


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/13144] pessimize memory-to-memory code for SSE
  2003-11-20 22:08 [Bug target/13144] New: Bad memory-to-memory code for SSE hjl at lucon dot org
  2003-12-06  9:19 ` [Bug target/13144] " pinskia at gcc dot gnu dot org
  2003-12-09 17:24 ` hjl at lucon dot org
@ 2003-12-09 17:47 ` pinskia at gcc dot gnu dot org
  2005-01-06  6:28 ` rth at gcc dot gnu dot org
  2005-01-06  6:53 ` rth at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-09 17:47 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-12-09 17:47 -------
Do not use the word bad as it means to most people wrong. Confirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |pessimizes-code
   Last reconfirmed|0000-00-00 00:00:00         |2003-12-09 17:47:17
               date|                            |
            Summary|Bad memory-to-memory code   |pessimize memory-to-memory
                   |for SSE                     |code for SSE


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13144


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/13144] pessimize memory-to-memory code for SSE
  2003-11-20 22:08 [Bug target/13144] New: Bad memory-to-memory code for SSE hjl at lucon dot org
                   ` (2 preceding siblings ...)
  2003-12-09 17:47 ` [Bug target/13144] pessimize " pinskia at gcc dot gnu dot org
@ 2005-01-06  6:28 ` rth at gcc dot gnu dot org
  2005-01-06  6:53 ` rth at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: rth at gcc dot gnu dot org @ 2005-01-06  6:28 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |rth at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13144


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/13144] pessimize memory-to-memory code for SSE
  2003-11-20 22:08 [Bug target/13144] New: Bad memory-to-memory code for SSE hjl at lucon dot org
                   ` (3 preceding siblings ...)
  2005-01-06  6:28 ` rth at gcc dot gnu dot org
@ 2005-01-06  6:53 ` rth at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: rth at gcc dot gnu dot org @ 2005-01-06  6:53 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rth at gcc dot gnu dot org  2005-01-06 06:53 -------
Just defining SLOW_UNALIGNED_ACCESS is not enough to get the desired result
from 3.4.  Lots of this has been rearranged in mainline, and I don't feel 
like backporting it.  We do not select TImode in mainline, without defining
SLOW_UNALIGNED_ACCESS, so I'm happy leaving well enough alone.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.0.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13144


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-01-06  6:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-20 22:08 [Bug target/13144] New: Bad memory-to-memory code for SSE hjl at lucon dot org
2003-12-06  9:19 ` [Bug target/13144] " pinskia at gcc dot gnu dot org
2003-12-09 17:24 ` hjl at lucon dot org
2003-12-09 17:47 ` [Bug target/13144] pessimize " pinskia at gcc dot gnu dot org
2005-01-06  6:28 ` rth at gcc dot gnu dot org
2005-01-06  6:53 ` rth at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).