diff options
author | Richard Sandiford <rdsandiford@googlemail.com> | 2014-08-28 06:22:24 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2014-08-28 06:22:24 +0000 |
commit | e89b312ed39af831f4e88534326ca723e8eed271 (patch) | |
tree | 77adca755e3ada6f2d469869e072ae4de7638191 /gcc/cse.c | |
parent | a2250fe993264183c9742431bd518bfcdb7fca67 (diff) | |
download | gcc-e89b312ed39af831f4e88534326ca723e8eed271.zip gcc-e89b312ed39af831f4e88534326ca723e8eed271.tar.gz gcc-e89b312ed39af831f4e88534326ca723e8eed271.tar.bz2 |
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
Diffstat (limited to 'gcc/cse.c')
-rw-r--r-- | gcc/cse.c | 55 |
1 files changed, 21 insertions, 34 deletions
@@ -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; } |