[Bug middle-end/15239] suboptimal mult-by-const expansion cost limit

wilson at specifixinc dot com gcc-bugzilla@gcc.gnu.org
Sat May 1 04:16:00 GMT 2004


------- 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



More information about the Gcc-bugs mailing list