public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "vda.linux at googlemail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/30354] -Os doesn't optimize a/CONST even if it saves size.
Date: Fri, 18 Jan 2013 10:29:00 -0000 [thread overview]
Message-ID: <bug-30354-4-hiEQv6GOAJ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-30354-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30354
--- Comment #16 from Denis Vlasenko <vda.linux at googlemail dot com> 2013-01-18 10:29:12 UTC ---
(In reply to comment #15)
> Honza, did you find time to have a look?
>
> I think this regressed alot in 4.6
Not really - it's just .eh_frame section.
I re-ran the tests with two gcc's I have here and sizes look like this:
text data bss dec hex filename
257731 0 0 257731 3eec3 divmod-4.2.1-Os.o
242787 0 0 242787 3b463 divmod-4.6.3-Os.o
Stock (unpatched) gcc improved, juggles registers better. For example:
int ib_100_x(int x) { return (100 / x) ^ (100 % x); }
0: b8 64 00 00 00 mov $0x64,%eax
5: 99 cltd
6: f7 7c 24 04 idivl 0x4(%esp)
- a: 31 c2 xor %eax,%edx
- c: 89 d0 mov %edx,%eax
- e: c3 ret
+ a: 31 d0 xor %edx,%eax
+ c: c3 ret
I believe my patch would improve things still - it is orthogonal to register
allocation.
BTW, just so that we are all on the same page wrt compiler options:
here's the script I use to compile, disassemble, and extract function sizes
from test program in comment 3. Tweakable by setting $PREFIX and/or $CC:
gencode.sh
==========
#!/bin/sh
#PREFIX="i686-"
test "$PREFIX" || PREFIX=""
test "$CC" || CC="${PREFIX}gcc"
test "$OBJDUMP" || OBJDUMP="${PREFIX}objdump"
test "$NM" || NM="${PREFIX}nm"
CC_VER=`$CC --version | sed -n 's/[^ ]* [^ ]* \([3-9]\.[1-9][^ ]*\).*/\1/p'`
test "$CC_VER" || exit 1
build()
{
opt=$1
bname=divmod-$CC_VER${opt}${nail}
# -ffunction-sections makes disasm easier to understand
# (insn offsets start from 0 within every function).
# -fno-exceptions -fno-asynchronous-unwind-tables: die, .eh_frame, die!
$CC \
-m32 \
-fomit-frame-pointer \
-ffunction-sections \
-fno-exceptions \
-fno-asynchronous-unwind-tables \
${opt} t.c -c -o $bname.o \
&& $OBJDUMP -dr $bname.o >$bname.asm \
&& $NM --size-sort $bname.o | sort -k3 >$bname.nm
}
build -Os
#build -O2 #not interesting
#build -O3 #not interesting
size *.o | tee SIZES
next prev parent reply other threads:[~2013-01-18 10:29 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <bug-30354-4@http.gcc.gnu.org/bugzilla/>
2012-06-28 23:29 ` aldot at gcc dot gnu.org
2013-01-18 10:29 ` vda.linux at googlemail dot com [this message]
2021-12-21 11:42 ` pinskia at gcc dot gnu.org
2007-01-02 22:09 [Bug rtl-optimization/30354] New: " vda dot linux at googlemail dot com
2007-01-02 22:45 ` [Bug target/30354] " pinskia at gcc dot gnu dot org
2007-07-25 15:05 ` vda dot linux at googlemail dot com
2007-07-25 15:09 ` vda dot linux at googlemail dot com
2007-07-25 15:17 ` vda dot linux at googlemail dot com
2007-07-25 15:22 ` vda dot linux at googlemail dot com
2009-06-05 16:19 ` aldot at gcc dot gnu dot org
2009-06-06 13:41 ` hubicka at gcc dot gnu dot org
2009-06-21 16:11 ` vda dot linux at googlemail dot com
2009-06-21 16:12 ` vda dot linux at googlemail dot com
2009-06-21 16:26 ` rguenth at gcc dot gnu dot org
2009-06-21 16:47 ` vda dot linux at googlemail dot com
2009-06-21 16:48 ` vda dot linux at googlemail dot com
2009-06-30 13:36 ` hubicka at gcc dot gnu dot org
2010-01-08 9:06 ` steven at gcc dot gnu dot 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-30354-4-hiEQv6GOAJ@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: link
Be 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).