public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/49839] New: Use constants in registers preferably to inline constants (-Os)
@ 2011-07-25 13:20 etienne_lorrain at yahoo dot fr
2011-07-25 17:29 ` [Bug target/49839] " pinskia at gcc dot gnu.org
2021-08-15 5:04 ` pinskia at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: etienne_lorrain at yahoo dot fr @ 2011-07-25 13:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49839
Summary: Use constants in registers preferably to inline
constants (-Os)
Product: gcc
Version: 4.6.1
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: rtl-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: etienne_lorrain@yahoo.fr
When GCC needs to zero out an integer in memory, and it already has one
register at value zero, it takes less code bytes to write the register than
inline a constant, i.e.:
etienne@etienne-server:~/projet$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/i386-linux-gnu/gcc/i486-linux-gnu/4.6.1/lto-wrapper
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.6.1-4'
--with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr
--program-suffix=-4.6 --enable-shared --enable-multiarch
--with-multiarch-defaults=i386-linux-gnu --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib/i386-linux-gnu
--without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib/i386-linux-gnu
--enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc
--enable-targets=all --with-arch-32=i586 --with-tune=generic
--enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu
--target=i486-linux-gnu
Thread model: posix
gcc version 4.6.1 (Debian 4.6.1-4)
etienne@etienne-server:~/projet$ cat tmp.c
unsigned a, b;
unsigned fct (void)
{
a = b = 0;
return 0;
}
etienne@etienne-server:~/projet$ gcc -Os -fomit-frame-pointer tmp.c -c -o tmp.o
etienne@etienne-server:~/projet$ objdump -d tmp.o
tmp.o: file format elf32-i386
Disassembly of section .text:
00000000 <fct>:
0: c7 05 00 00 00 00 00 movl $0x0,0x0
7: 00 00 00
a: 31 c0 xor %eax,%eax
c: c7 05 00 00 00 00 00 movl $0x0,0x0
13: 00 00 00
16: c3 ret
etienne@etienne-server:~/projet$
It would be shorter to get this assembly:
0: 31 c0 xor %eax,%eax
2: a3 00 00 00 00 mov %eax,a
7: a3 00 00 00 00 mov %eax,b
c: c3 ret
Regards,
Etienne.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-08-15 5:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-25 13:20 [Bug rtl-optimization/49839] New: Use constants in registers preferably to inline constants (-Os) etienne_lorrain at yahoo dot fr
2011-07-25 17:29 ` [Bug target/49839] " pinskia at gcc dot gnu.org
2021-08-15 5:04 ` 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).