public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "etienne_lorrain at yahoo dot fr" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/49839] New: Use constants in registers preferably to inline constants (-Os) Date: Mon, 25 Jul 2011 13:20:00 -0000 [thread overview] Message-ID: <bug-49839-4@http.gcc.gnu.org/bugzilla/> (raw) 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.
next reply other threads:[~2011-07-25 13:20 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-07-25 13:20 etienne_lorrain at yahoo dot fr [this message] 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
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-49839-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).