From e89b312ed39af831f4e88534326ca723e8eed271 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Thu, 28 Aug 2014 06:22:24 +0000 Subject: [PATCH] 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 --- gcc/ChangeLog | 7 +++++++ gcc/cse.c | 55 ++++++++++++++++++++------------------------------- 2 files changed, 28 insertions(+), 34 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 69331bd79f3..1d318096038 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2014-08-28 Richard Sandiford + + * 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 * cfgcleanup.c: Include rtl-iter.h. diff --git a/gcc/cse.c b/gcc/cse.c index 32efc47a376..4b9a961e0d1 100644 --- a/gcc/cse.c +++ b/gcc/cse.c @@ -42,6 +42,7 @@ along with GCC; see the file COPYING3. If not see #include "df.h" #include "dbgcnt.h" #include "hash-set.h" +#include "rtl-iter.h" /* The basic idea of common subexpression elimination is to go through the code, keeping a record of expressions that would @@ -550,8 +551,6 @@ static sbitmap cse_visited_basic_blocks; static bool fixed_base_plus_p (rtx x); 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 void new_basic_block (void); static void make_new_qty (unsigned int, enum machine_mode); @@ -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 -approx_reg_cost_1 (rtx *xp, void *data) +approx_reg_cost (const_rtx x) { - rtx x = *xp; - int *cost_p = (int *) data; - - if (x && REG_P (x)) + int cost = 0; + subrtx_iterator::array_type array; + FOR_EACH_SUBRTX (iter, array, x, NONCONST) { - unsigned int regno = REGNO (x); - - if (! CHEAP_REGNO (regno)) + const_rtx x = *iter; + if (REG_P (x)) { - if (regno < FIRST_PSEUDO_REGISTER) + unsigned int regno = REGNO (x); + if (!CHEAP_REGNO (regno)) { - if (targetm.small_register_classes_for_mode_p (GET_MODE (x))) - return 1; - *cost_p += 2; + if (regno < FIRST_PSEUDO_REGISTER) + { + if (targetm.small_register_classes_for_mode_p (GET_MODE (x))) + return MAX_COST; + cost += 2; + } + else + cost += 1; } - else - *cost_p += 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; } -- 2.30.2