public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/101920] New: memcpy expansion treats unknown pointers as unaligned
@ 2021-08-15 8:54 dragan.mladjenovic at syrmia dot com
2021-08-15 9:13 ` [Bug middle-end/101920] " pinskia at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: dragan.mladjenovic at syrmia dot com @ 2021-08-15 8:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101920
Bug ID: 101920
Summary: memcpy expansion treats unknown pointers as unaligned
Product: gcc
Version: 11.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: dragan.mladjenovic at syrmia dot com
Target Milestone: ---
I guess it is easiest to observe this on Aarch64 with the following code:
#include <string.h>
void test (int *dst, int *src)
{
(void)memcpy (dst, src, sizeof *src);
}
With -O1 -mno-strict-align we get:
ldr w1, [x1]
str w1, [x0]
ret
With -O1 -mstrict-align we get:
ldrb w2, [x1]
strb w2, [x0]
ldrb w2, [x1, 1]
strb w2, [x0, 1]
ldrb w2, [x1, 2]
strb w2, [x0, 2]
ldrb w1, [x1, 3]
strb w1, [x0, 3]
ret
Or with Os:
mov x2, 4
b memcpy
It seems that builtins.c:get_pointer_alignment finds empty SSA_NAME_PTR_INFO
for both pointers and defaults to 8-bit alignment. This can be worked around by
applying __builtin_assume_alligned to both src and dest.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug middle-end/101920] memcpy expansion treats unknown pointers as unaligned
2021-08-15 8:54 [Bug middle-end/101920] New: memcpy expansion treats unknown pointers as unaligned dragan.mladjenovic at syrmia dot com
@ 2021-08-15 9:13 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 2+ 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=101920
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 50417.
*** This bug has been marked as a duplicate of bug 50417 ***
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-08-15 9:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-15 8:54 [Bug middle-end/101920] New: memcpy expansion treats unknown pointers as unaligned dragan.mladjenovic at syrmia dot com
2021-08-15 9:13 ` [Bug middle-end/101920] " pinskia 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).