Commit e89b312e by Richard Sandiford Committed by Richard Sandiford

cse.c: Include rtl-iter.h.

gcc/
	* cse.c: Include rtl-iter.h.
	(approx_reg_cost_1): Delete.
	(approx_reg_cost): Use FOR_EACH_SUBRTX instead of for_each_rtx.
	Don't handle null rtxes.

From-SVN: r214627
parent a2250fe9
2014-08-28 Richard Sandiford <rdsandiford@googlemail.com> 2014-08-28 Richard Sandiford <rdsandiford@googlemail.com>
* cse.c: Include rtl-iter.h.
(approx_reg_cost_1): Delete.
(approx_reg_cost): Use FOR_EACH_SUBRTX instead of for_each_rtx.
Don't handle null rtxes.
2014-08-28 Richard Sandiford <rdsandiford@googlemail.com>
* cfgcleanup.c: Include rtl-iter.h. * cfgcleanup.c: Include rtl-iter.h.
(mentions_nonequal_regs): Turn from being a for_each_rtx callback (mentions_nonequal_regs): Turn from being a for_each_rtx callback
to being a function that examines each subrtx itself. to being a function that examines each subrtx itself.
......
...@@ -42,6 +42,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -42,6 +42,7 @@ along with GCC; see the file COPYING3. If not see
#include "df.h" #include "df.h"
#include "dbgcnt.h" #include "dbgcnt.h"
#include "hash-set.h" #include "hash-set.h"
#include "rtl-iter.h"
/* The basic idea of common subexpression elimination is to go /* The basic idea of common subexpression elimination is to go
through the code, keeping a record of expressions that would through the code, keeping a record of expressions that would
...@@ -550,8 +551,6 @@ static sbitmap cse_visited_basic_blocks; ...@@ -550,8 +551,6 @@ static sbitmap cse_visited_basic_blocks;
static bool fixed_base_plus_p (rtx x); static bool fixed_base_plus_p (rtx x);
static int notreg_cost (rtx, enum rtx_code, int); static int notreg_cost (rtx, enum rtx_code, int);
static int approx_reg_cost_1 (rtx *, void *);
static int approx_reg_cost (rtx);
static int preferable (int, int, int, int); static int preferable (int, int, int, int);
static void new_basic_block (void); static void new_basic_block (void);
static void make_new_qty (unsigned int, enum machine_mode); static void make_new_qty (unsigned int, enum machine_mode);
...@@ -660,47 +659,35 @@ dump_class (struct table_elt *classp) ...@@ -660,47 +659,35 @@ dump_class (struct table_elt *classp)
} }
} }
/* Subroutine of approx_reg_cost; called through for_each_rtx. */ /* Return an estimate of the cost of the registers used in an rtx.
This is mostly the number of different REG expressions in the rtx;
however for some exceptions like fixed registers we use a cost of
0. If any other hard register reference occurs, return MAX_COST. */
static int static int
approx_reg_cost_1 (rtx *xp, void *data) approx_reg_cost (const_rtx x)
{ {
rtx x = *xp; int cost = 0;
int *cost_p = (int *) data; subrtx_iterator::array_type array;
FOR_EACH_SUBRTX (iter, array, x, NONCONST)
if (x && REG_P (x)) {
const_rtx x = *iter;
if (REG_P (x))
{ {
unsigned int regno = REGNO (x); unsigned int regno = REGNO (x);
if (!CHEAP_REGNO (regno))
if (! CHEAP_REGNO (regno))
{ {
if (regno < FIRST_PSEUDO_REGISTER) if (regno < FIRST_PSEUDO_REGISTER)
{ {
if (targetm.small_register_classes_for_mode_p (GET_MODE (x))) if (targetm.small_register_classes_for_mode_p (GET_MODE (x)))
return 1; return MAX_COST;
*cost_p += 2; cost += 2;
} }
else else
*cost_p += 1; cost += 1;
}
} }
} }
return 0;
}
/* Return an estimate of the cost of the registers used in an rtx.
This is mostly the number of different REG expressions in the rtx;
however for some exceptions like fixed registers we use a cost of
0. If any other hard register reference occurs, return MAX_COST. */
static int
approx_reg_cost (rtx x)
{
int cost = 0;
if (for_each_rtx (&x, approx_reg_cost_1, (void *) &cost))
return MAX_COST;
return cost; return cost;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment