This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Old patch: expmed.c (expand_divmod)
- To: gcc-patches at gcc dot gnu dot org
- Subject: Old patch: expmed.c (expand_divmod)
- From: Marek Michalkiewicz <marekm at linux dot org dot pl>
- Date: Tue, 24 Oct 2000 20:57:32 +0200 (CEST)
- CC: denisc at overta dot ru, marekm at linux dot org dot pl
- Reply-To: marekm at linux dot org dot pl
This was part of a larger patch (sent about a month ago), the rest of
which has been applied. I'm resending this in case it went unnoticed -
please excuse me if it is actually being reviewed.
This simple one-line change significantly improves the code (both size
and speed) for signed divide by 2 (quite common operation I think) on
all targets where BRANCH_COST == 0 that worked when Denis tested them
(avr, h8300, m68hc11, pdp11, vax). The improvement is especially big
for avr and m68hc11 (cheap branches, expensive shifts by many bits),
and code size really matters for these small microcontrollers.
No change at all on big machines that generally have BRANCH_COST > 0
(and the current code for divide by 2 seems OK, at least for x86).
No new target macros added. Only one line changed. Please approve
this tiny little patch. Please... Thanks!
Marek
Sat Sep 23 19:10:20 2000 Denis Chertykov <denisc@overta.ru>
* expmed.c (expand_divmod): For signed divide by 2, prefer
a branch and fewer shifts if branches are very cheap.
diff -rc3p orig/egcs/gcc/expmed.c egcs/gcc/expmed.c
*** orig/egcs/gcc/expmed.c Thu Oct 19 19:37:17 2000
--- egcs/gcc/expmed.c Tue Oct 24 19:51:25 2000
*************** expand_divmod (rem_flag, code, mode, op0
*** 3256,3262 ****
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;
--- 3256,3262 ----
else if (EXACT_POWER_OF_2_OR_ZERO_P (abs_d))
{
lgup = floor_log2 (abs_d);
! if (BRANCH_COST < 1 || (abs_d != 2 && BRANCH_COST < 3))
{
rtx label = gen_label_rtx ();
rtx t1;