On Jul 26, 2005, at 3:34 PM, Dale Johannesen wrote:
I think the RA may be missing the concept that memory might be faster
than any possible register....
will dig further.
Yes, it is. The following fixes my problem, and causes a couple of
3DNow-specific regressions
in the testsuite which I need to look at, but nothing serious; I think
it's gotten far enough to post
for opinions. This is intended to go on top of Paolo's patch
http://gcc.gnu.org/ml/gcc-patches/2005-07/msg01044.html
It may, of course, run afoul of inaccuracies in the patterns on various
targets, haven't
tried any performance testing yet.
Index: regclass.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/regclass.c,v
retrieving revision 1.206
diff -u -b -r1.206 regclass.c
--- regclass.c 25 Jun 2005 02:00:52 -0000 1.206
+++ regclass.c 27 Jul 2005 06:04:40 -0000
@@ -838,7 +838,8 @@
/* Structure used to record preferences of given pseudo. */
struct reg_pref
{
- /* (enum reg_class) prefclass is the preferred class. */
+ /* (enum reg_class) prefclass is the preferred class. May be
+ NO_REGS if no class is better than memory. */
char prefclass;
/* altclass is a register class that we should use for allocating
@@ -1321,6 +1322,10 @@
best = reg_class_subunion[(int) best][class];
}
+ /* If no register class is better than memory, use memory. */
+ if (p->mem_cost < best_cost)
+ best = NO_REGS;
+
/* Record the alternate register class; i.e., a class for which
every register in it is better than using memory. If adding a
class would make a smaller class (i.e., no union of just those
@@ -1528,7 +1533,7 @@
to what we would add if this register were not in the
appropriate class. */
- if (reg_pref)
+ if (reg_pref && reg_pref[REGNO (op)].prefclass != NO_REGS)
alt_cost
+= (may_move_in_cost[mode]
[(unsigned char) reg_pref[REGNO (op)].prefclass]
@@ -1754,7 +1759,7 @@
to what we would add if this register were not in the
appropriate class. */
- if (reg_pref)
+ if (reg_pref && reg_pref[REGNO (op)].prefclass != NO_REGS)
alt_cost
+= (may_move_in_cost[mode]
[(unsigned char) reg_pref[REGNO (op)].prefclass]
@@ -1840,7 +1845,8 @@
int class;
unsigned int nr;
- if (regno >= FIRST_PSEUDO_REGISTER && reg_pref != 0)
+ if (regno >= FIRST_PSEUDO_REGISTER && reg_pref != 0
+ && reg_pref[regno].prefclass != NO_REGS)
{
enum reg_class pref = reg_pref[regno].prefclass;