public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "wilson at specifixinc dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/15239] suboptimal mult-by-const expansion cost limit
Date: Sat, 01 May 2004 04:16:00 -0000	[thread overview]
Message-ID: <20040501041619.24447.qmail@sources.redhat.com> (raw)
In-Reply-To: <20040430234603.15239.l_belev@yahoo.com>


------- Additional Comments From wilson at specifixinc dot com  2004-05-01 04:16 -------
Subject: Re:  New: suboptimal mult-by-const expansion cost limit

l_belev at yahoo dot com wrote:
> Look in the file gcc/expmed.c, function expand_mult(). The code 
>       mult_cost = rtx_cost (gen_rtx_MULT (mode, op0, op1), SET); 
>       mult_cost = MIN (12 * add_cost, mult_cost); 
> calculates the initial cost limit before the recursive search for 
> a good expansion is invoked. 

As I mentioned on the gcc list, this is apparently used to avoid 
unresaonble code size expansion.  When converting multiplies to 
add-sequences, we limit the number of adds emitted to 12, so that the 
code size increase will be bounded.

I suggested changing the calculation to be 6 * add_cost + 6 * 
sihft_cost, because shifts often have higher costs than adds, and we are 
really emitting a sequence of shifts and adds, not just a sequence of adds.

It may also be reasonable to vary the number based on the optimization 
level, e.g. use a higher limit for -O3.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15239


  parent reply	other threads:[~2004-05-01  4:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20040430234603.15239.l_belev@yahoo.com>
2004-05-01  0:07 ` [Bug c/15239] " jsm at polyomino dot org dot uk
2004-05-01  0:11 ` [Bug middle-end/15239] " pinskia at gcc dot gnu dot org
2004-05-01  4:12 ` wilson at specifixinc dot com
2004-05-01  4:16 ` wilson at specifixinc dot com [this message]
2004-05-01 13:06 ` l_belev at yahoo dot com
2004-05-01 14:26 ` l_belev at yahoo dot com
2004-06-24 20:40 ` cvs-commit at gcc dot gnu dot org
2004-06-24 21:08 ` pinskia 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=20040501041619.24447.qmail@sources.redhat.com \
    --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).