This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/15419] New: memcpy pessimization
- From: "falk at debian dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 May 2004 14:05:18 -0000
- Subject: [Bug tree-optimization/15419] New: memcpy pessimization
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
gcc (GCC) 3.5.0 20040513 (experimental)
% cat test.c
typedef unsigned uint32_t;
uint32_t get_uint32(const void *p) {
uint32_t w;
memcpy(&w, p, sizeof (uint32_t));
return w;
}
uint32_t get_uint32a(const void *p) {
const struct { uint32_t w; } __attribute__((packed)) *wp = p;
return wp->w;
}
% gcc -c -O3 test.c && objdump -d test.o
0000000000000000 <get_uint32>:
0: 03 00 90 28 ldbu t3,3(a0)
4: 00 00 30 28 ldbu t0,0(a0)
8: f0 ff de 23 lda sp,-16(sp)
c: 01 00 50 28 ldbu t1,1(a0)
10: 02 00 70 28 ldbu t2,2(a0)
14: 00 00 3e 38 stb t0,0(sp)
18: 03 00 9e 38 stb t3,3(sp)
1c: 01 00 5e 38 stb t1,1(sp)
20: 02 00 7e 38 stb t2,2(sp)
24: 00 00 1e a0 ldl v0,0(sp)
28: 10 00 de 23 lda sp,16(sp)
2c: 01 80 fa 6b ret
0000000000000030 <get_uint32a>:
30: 00 00 50 2c ldq_u t1,0(a0)
34: 03 00 30 2c ldq_u t0,3(a0)
38: c2 04 50 48 extll t1,a0,t1
3c: 41 0d 30 48 extlh t0,a0,t0
40: 00 04 41 44 or t1,t0,v0
44: 00 00 e0 43 sextl v0,v0
48: 01 80 fa 6b ret
The code for get_uint32 is really bad compared to get_uint32a, but it is
an important portable idiom to achieve the same.
--
Summary: memcpy pessimization
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Keywords: pessimizes-code
Severity: enhancement
Priority: P2
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: falk at debian dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: alphaev68-unknown-linux-gnu
GCC host triplet: alphaev68-unknown-linux-gnu
GCC target triplet: alphaev68-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15419