This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/16427] New: dead 0 memset not optimized away
- From: "ak at muc dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Jul 2004 01:25:17 -0000
- Subject: [Bug rtl-optimization/16427] New: dead 0 memset not optimized away
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
gcc version 3.5.0 20040704 (experimental)
void f(void)
{
unsigned long x[16];
memset(x, 0, sizeof(x));
}
generates
f:
.LFB2:
subq $136, %rsp
.LCFI0:
movl $128, %edx
xorl %esi, %esi
movq %rsp, %rdi
call memset
addq $136, %rsp
ret
but when the 0 is changed to 0xff or any other value != 0 you get
f:
.LFB2:
subq $16, %rsp
.LCFI0:
addq $16, %rsp
ret
(which btw is also weird because it leaks 16 bytes, but that's a differen issue)
I would expect the 0 memset to be optimized away too.
Looking at the code builtin_memset calls clear_storage() for the 0 case
and store_by_pieces directly for any other values.
Clearly something clear_storage() does is giving the optimizer the fits.
--
Summary: dead 0 memset not optimized away
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: rtl-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ak at muc dot de
CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: x86_64-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16427