public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/50417] New: regression: memcpy with known alignment
@ 2011-09-15  8:57 wouter.vermaelen at scarlet dot be
  2011-09-25 10:13 ` [Bug tree-optimization/50417] " rguenth at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: wouter.vermaelen at scarlet dot be @ 2011-09-15  8:57 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 50417
           Summary: regression: memcpy with known alignment
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: wouter.vermaelen@scarlet.be


Consider these functions:

void copy1(char* d, const char* s) {
    memcpy(d, s, 256);
}
void copy2(short* d, const short* s) {
    memcpy(d, s, 256);
}
void copy3(int* d, const int* s) {
    memcpy(d, s, 256);
}
void copy4(long* d, const long* s) {
    memcpy(d, s, 256);
}

g++-4.5.2 is able to generate better code for the later functions. But when I
test with a recent snapshot (SVN revision 178875 on linux x86_64) it generates
the same code for all versions (same as copy1()).


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

* [Bug tree-optimization/50417] regression: memcpy with known alignment
  2011-09-15  8:57 [Bug tree-optimization/50417] New: regression: memcpy with known alignment wouter.vermaelen at scarlet dot be
@ 2011-09-25 10:13 ` rguenth at gcc dot gnu.org
  2012-06-06 11:01 ` rguenth at gcc dot gnu.org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-09-25 10:13 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

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

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-09-25 09:58:43 UTC ---
The middle-end does not know anything about the parameters alignment.


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

* [Bug tree-optimization/50417] regression: memcpy with known alignment
  2011-09-15  8:57 [Bug tree-optimization/50417] New: regression: memcpy with known alignment wouter.vermaelen at scarlet dot be
  2011-09-25 10:13 ` [Bug tree-optimization/50417] " rguenth at gcc dot gnu.org
@ 2012-06-06 11:01 ` rguenth at gcc dot gnu.org
  2013-07-14 10:31 ` olegendo at gcc dot gnu.org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-06-06 11:01 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jay.foad at gmail dot com

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-06-06 11:00:31 UTC ---
*** Bug 52415 has been marked as a duplicate of this bug. ***


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

* [Bug tree-optimization/50417] regression: memcpy with known alignment
  2011-09-15  8:57 [Bug tree-optimization/50417] New: regression: memcpy with known alignment wouter.vermaelen at scarlet dot be
  2011-09-25 10:13 ` [Bug tree-optimization/50417] " rguenth at gcc dot gnu.org
  2012-06-06 11:01 ` rguenth at gcc dot gnu.org
@ 2013-07-14 10:31 ` olegendo at gcc dot gnu.org
  2013-10-09  9:25 ` gjl at gcc dot gnu.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: olegendo at gcc dot gnu.org @ 2013-07-14 10:31 UTC (permalink / raw)
  To: gcc-bugs

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

Oleg Endo <olegendo at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |sh*-*-* arm*-*-* avr*-*-*
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-07-14
                 CC|                            |olegendo at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #3 from Oleg Endo <olegendo at gcc dot gnu.org> ---
I ran into this issue when trying out something on SH, too.
(4.9 trunk rev 200571)
Example:

void test (const int* a, int* b)
{
  std::memcpy (b, a, 4);
}

Here I'd have expected this to result in a int load + int store, like...

        mov.l   @r4,r1
        rts
        mov.l   r1,@r5

However, this does not happen.  The SH's movmemsi pattern gets a 'common
alignment' of '1'.  SH is a strict alignment target and thus the expander will
fall back to memcpy library call.
If I remember correctly, on strict alignment targets a pointer to some type is
by default assumed to satisfy the minimum alignment of that type.
For example

int test (const int* a)
{
  return a[0];
}

resuls in (as expected):

        rts
        mov.l   @r4,r0

In the memcpy case it should be safe to assume that the alignment of int* is 32
bit aligned.
As it has been mentioned in PR 52415, I've also tried out
__builtin_assume_aligned and the problem disappears.  In this case the memcpy
is eliminated early on and the movmemsi pattern is not used at all.


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

* [Bug tree-optimization/50417] regression: memcpy with known alignment
  2011-09-15  8:57 [Bug tree-optimization/50417] New: regression: memcpy with known alignment wouter.vermaelen at scarlet dot be
                   ` (2 preceding siblings ...)
  2013-07-14 10:31 ` olegendo at gcc dot gnu.org
@ 2013-10-09  9:25 ` gjl at gcc dot gnu.org
  2014-04-02  8:39 ` rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: gjl at gcc dot gnu.org @ 2013-10-09  9:25 UTC (permalink / raw)
  To: gcc-bugs

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

Georg-Johann Lay <gjl at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
             Target|sh*-*-* arm*-*-* avr*-*-*   |sh*-*-* arm*-*-*
                 CC|                            |gjl at gcc dot gnu.org

--- Comment #4 from Georg-Johann Lay <gjl at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #1)
> The middle-end does not know anything about the parameters alignment.

But the following code will use SImode load / store, even on strict-alignment
backends

void test (const int* a, int* b)
{
  *b = *a;
}

If SImode operations are in order here, why not in memcpy et al. provided it is
feeded with int*?

In the case where an unaligned pointer is used in *b = *a and this causes, e.g.
 a trap, this is in order.  Similar should apply for memcpy on strict-alignment
machines if it gets an unaligned int* for example and the size is a multiple of
the alignment requirement.

BTW: AVR is an 8-bit machine that copies in chunks of 1 byte, this applies also
for 4.5 and older.  avr-gcc is /not/ a strict alignment backend.  Thul removed
from the targets.


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

* [Bug tree-optimization/50417] regression: memcpy with known alignment
  2011-09-15  8:57 [Bug tree-optimization/50417] New: regression: memcpy with known alignment wouter.vermaelen at scarlet dot be
                   ` (3 preceding siblings ...)
  2013-10-09  9:25 ` gjl at gcc dot gnu.org
@ 2014-04-02  8:39 ` rguenth at gcc dot gnu.org
  2015-09-22  8:04 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-04-02  8:39 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anton at samba dot org

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
*** Bug 60737 has been marked as a duplicate of this bug. ***


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

* [Bug tree-optimization/50417] regression: memcpy with known alignment
  2011-09-15  8:57 [Bug tree-optimization/50417] New: regression: memcpy with known alignment wouter.vermaelen at scarlet dot be
                   ` (4 preceding siblings ...)
  2014-04-02  8:39 ` rguenth at gcc dot gnu.org
@ 2015-09-22  8:04 ` rguenth at gcc dot gnu.org
  2021-05-14  9:46 ` [Bug tree-optimization/50417] [9/10/11/12 regression]: " jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-09-22  8:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
*** Bug 67676 has been marked as a duplicate of this bug. ***


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

* [Bug tree-optimization/50417] [9/10/11/12 regression]: memcpy with known alignment
  2011-09-15  8:57 [Bug tree-optimization/50417] New: regression: memcpy with known alignment wouter.vermaelen at scarlet dot be
                   ` (5 preceding siblings ...)
  2015-09-22  8:04 ` rguenth at gcc dot gnu.org
@ 2021-05-14  9:46 ` jakub at gcc dot gnu.org
  2021-06-01  8:05 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-05-14  9:46 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|8.5                         |9.4

--- Comment #32 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 8 branch is being closed.

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

* [Bug tree-optimization/50417] [9/10/11/12 regression]: memcpy with known alignment
  2011-09-15  8:57 [Bug tree-optimization/50417] New: regression: memcpy with known alignment wouter.vermaelen at scarlet dot be
                   ` (6 preceding siblings ...)
  2021-05-14  9:46 ` [Bug tree-optimization/50417] [9/10/11/12 regression]: " jakub at gcc dot gnu.org
@ 2021-06-01  8:05 ` rguenth at gcc dot gnu.org
  2021-08-15  9:13 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-01  8:05 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.4                         |9.5

--- Comment #33 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9.4 is being released, retargeting bugs to GCC 9.5.

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

* [Bug tree-optimization/50417] [9/10/11/12 regression]: memcpy with known alignment
  2011-09-15  8:57 [Bug tree-optimization/50417] New: regression: memcpy with known alignment wouter.vermaelen at scarlet dot be
                   ` (7 preceding siblings ...)
  2021-06-01  8:05 ` rguenth at gcc dot gnu.org
@ 2021-08-15  9:13 ` pinskia at gcc dot gnu.org
  2022-05-27  9:34 ` [Bug tree-optimization/50417] [10/11/12/13 " rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-15  9:13 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dragan.mladjenovic at syrmia dot c
                   |                            |om

--- Comment #34 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 101920 has been marked as a duplicate of this bug. ***

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

* [Bug tree-optimization/50417] [10/11/12/13 regression]: memcpy with known alignment
  2011-09-15  8:57 [Bug tree-optimization/50417] New: regression: memcpy with known alignment wouter.vermaelen at scarlet dot be
                   ` (8 preceding siblings ...)
  2021-08-15  9:13 ` pinskia at gcc dot gnu.org
@ 2022-05-27  9:34 ` rguenth at gcc dot gnu.org
  2022-06-28 10:30 ` jakub at gcc dot gnu.org
  2023-07-07 10:29 ` [Bug tree-optimization/50417] [11/12/13/14 " rguenth at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-27  9:34 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.5                         |10.4

--- Comment #35 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9 branch is being closed

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

* [Bug tree-optimization/50417] [10/11/12/13 regression]: memcpy with known alignment
  2011-09-15  8:57 [Bug tree-optimization/50417] New: regression: memcpy with known alignment wouter.vermaelen at scarlet dot be
                   ` (9 preceding siblings ...)
  2022-05-27  9:34 ` [Bug tree-optimization/50417] [10/11/12/13 " rguenth at gcc dot gnu.org
@ 2022-06-28 10:30 ` jakub at gcc dot gnu.org
  2023-07-07 10:29 ` [Bug tree-optimization/50417] [11/12/13/14 " rguenth at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-28 10:30 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.4                        |10.5

--- Comment #36 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 10.4 is being released, retargeting bugs to GCC 10.5.

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

* [Bug tree-optimization/50417] [11/12/13/14 regression]: memcpy with known alignment
  2011-09-15  8:57 [Bug tree-optimization/50417] New: regression: memcpy with known alignment wouter.vermaelen at scarlet dot be
                   ` (10 preceding siblings ...)
  2022-06-28 10:30 ` jakub at gcc dot gnu.org
@ 2023-07-07 10:29 ` rguenth at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07 10:29 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.5                        |11.5

--- Comment #37 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 10 branch is being closed.

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

end of thread, other threads:[~2023-07-07 10:29 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-15  8:57 [Bug tree-optimization/50417] New: regression: memcpy with known alignment wouter.vermaelen at scarlet dot be
2011-09-25 10:13 ` [Bug tree-optimization/50417] " rguenth at gcc dot gnu.org
2012-06-06 11:01 ` rguenth at gcc dot gnu.org
2013-07-14 10:31 ` olegendo at gcc dot gnu.org
2013-10-09  9:25 ` gjl at gcc dot gnu.org
2014-04-02  8:39 ` rguenth at gcc dot gnu.org
2015-09-22  8:04 ` rguenth at gcc dot gnu.org
2021-05-14  9:46 ` [Bug tree-optimization/50417] [9/10/11/12 regression]: " jakub at gcc dot gnu.org
2021-06-01  8:05 ` rguenth at gcc dot gnu.org
2021-08-15  9:13 ` pinskia at gcc dot gnu.org
2022-05-27  9:34 ` [Bug tree-optimization/50417] [10/11/12/13 " rguenth at gcc dot gnu.org
2022-06-28 10:30 ` jakub at gcc dot gnu.org
2023-07-07 10:29 ` [Bug tree-optimization/50417] [11/12/13/14 " rguenth at gcc dot gnu.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).