public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "vda dot 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: Wed, 25 Jul 2007 15:05:00 -0000 [thread overview] Message-ID: <20070725150537.20630.qmail@sourceware.org> (raw) In-Reply-To: <bug-30354-12956@http.gcc.gnu.org/bugzilla/> ------- Comment #2 from vda dot linux at googlemail dot com 2007-07-25 15:05 ------- Created an attachment (id=13973) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13973&action=view) Fix: adjust div cost for -Os on i386 Patch was tested with 4.2.1, I guess it will apply to other versions of gcc as it is quite trivial. Test program with lots or randomly-generated constant divisions and %'s was compiled by patched gcc with different costs of division: text data bss dec hex filename 257731 0 0 257731 3eec3 421.org/t-Os.o 256788 0 0 256788 3eb14 421.7/t-Os.o 256788 0 0 256788 3eb14 421.8/t-Os.o 257377 0 0 257377 3ed61 421.9/t-Os.o 257825 0 0 257825 3ef21 421.10/t-Os.o Seems like (at least on 4.2.1) cost of 8 is giving smallest code. Among 15000 divisions in test program, only signed divisions by power-of-two grew in size (but they become MUCH faster, as they don't even use multiply now, let alone div): @@ -1703 +1703 @@ -0000000f T id_x_16 +00000012 T id_x_16 @@ -1836 +1836 @@ -0000000f T id_x_2 +0000000e T id_x_2 @@ -2030 +2030 @@ -0000000f T id_x_32 +00000012 T id_x_32 id_x_16 was: movl 4(%esp), %eax movl $16, %edx movl %edx, %ecx cltd idivl %ecx ret Now it is: movl 4(%esp), %edx movl %edx, %eax sarl $31, %eax andl $15, %eax addl %edx, %eax sarl $4, %eax ret and also unsigned_x / 28, unsigned_x / 13952, unsigned_x / 56 grew by 1 byte. The rest either were not changed (and still use div insn) or shrank (typically by 1 byte, record holders are "unsigned_x / 641" and "unsigned_x / 6700417" - shrank by 4 bytes). -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30354
next prev parent reply other threads:[~2007-07-25 15:05 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 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 [this message] 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 [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 2021-12-21 11:42 ` 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=20070725150537.20630.qmail@sourceware.org \ --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).