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