This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: AVR signed int / 2 divide
- To: law at cygnus dot com
- Subject: Re: AVR signed int / 2 divide
- From: Marek Michalkiewicz <marekm at linux dot org dot pl>
- Date: Sun, 7 May 2000 20:13:52 +0200 (CEST)
- CC: marekm at linux dot org dot pl, gcc-patches at gcc dot gnu dot org
- Reply-To: marekm at linux dot org dot pl
Jeffrey A Law <law@cygnus.com> wrote:
> I think it would be better to use BRANCH_COST to determine the cost
> of the branch and RTX_COST to determine the cost of a shift (and other
> RTL operations). Then select the cheaper one.
Would something like this be OK? In my tests it does the right thing
on avr target, I hope it doesn't break other targets too badly...
Thanks,
Marek
2000-05-07 Marek Michalkiewicz <marekm@linux.org.pl>
* expmed.c (expand_divmod): For signed divide by power of 2,
compare BRANCH_COST with cost of one or two shifts.
*** gcc/expmed.c.orig Fri May 5 08:53:56 2000
--- gcc/expmed.c Sun May 7 19:47:21 2000
*************** expand_divmod (rem_flag, code, mode, op0
*** 3234,3240 ****
else if (EXACT_POWER_OF_2_OR_ZERO_P (abs_d))
{
lgup = floor_log2 (abs_d);
! if (abs_d != 2 && BRANCH_COST < 3)
{
rtx label = gen_label_rtx ();
rtx t1;
--- 3234,3241 ----
else if (EXACT_POWER_OF_2_OR_ZERO_P (abs_d))
{
lgup = floor_log2 (abs_d);
! if (BRANCH_COST < shift_cost[size - 1] * (abs_d != 2)
! + shift_cost[size - lgup])
{
rtx label = gen_label_rtx ();
rtx t1;