From d51102f3e780e69e19c6d7eeb987647e4a8aff15 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Thu, 18 Aug 2011 12:36:51 +0000 Subject: [PATCH] rtl.h (set_rtx_cost, [...]): New functions. gcc/ * rtl.h (set_rtx_cost, get_full_set_rtx_cost): New functions. * auto-inc-dec.c (attempt_change): Use set_rtx_cost. * cfgloopanal.c (seq_cost): Likewise. * loop-invariant.c (create_new_invariant): Likewise. * postreload.c (move2add_use_add2_insn, move2add_use_add3_insn) (reload_cse_move2add): Use get_full_set_rtx_cost. From-SVN: r177850 --- gcc/ChangeLog | 9 +++++++++ gcc/auto-inc-dec.c | 2 +- gcc/cfgloopanal.c | 2 +- gcc/loop-invariant.c | 2 +- gcc/postreload.c | 10 +++++----- gcc/rtl.h | 18 ++++++++++++++++++ 6 files changed, 35 insertions(+), 8 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c9b49b67c0b..f3a95bb3b0b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2011-08-18 Richard Sandiford + + * rtl.h (set_rtx_cost, get_full_set_rtx_cost): New functions. + * auto-inc-dec.c (attempt_change): Use set_rtx_cost. + * cfgloopanal.c (seq_cost): Likewise. + * loop-invariant.c (create_new_invariant): Likewise. + * postreload.c (move2add_use_add2_insn, move2add_use_add3_insn) + (reload_cse_move2add): Use get_full_set_rtx_cost. + 2011-08-18 Richard Guenther * expr.c (get_inner_reference): Fix typo in last change. diff --git a/gcc/auto-inc-dec.c b/gcc/auto-inc-dec.c index dbd12e72f21..0444daecf9b 100644 --- a/gcc/auto-inc-dec.c +++ b/gcc/auto-inc-dec.c @@ -484,7 +484,7 @@ attempt_change (rtx new_addr, rtx inc_reg) XEXP (mem_tmp, 0) = new_addr; old_cost = (rtx_cost (mem, SET, speed) - + rtx_cost (PATTERN (inc_insn.insn), SET, speed)); + + set_rtx_cost (PATTERN (inc_insn.insn), speed)); new_cost = rtx_cost (mem_tmp, SET, speed); /* The first item of business is to see if this is profitable. */ diff --git a/gcc/cfgloopanal.c b/gcc/cfgloopanal.c index 02f02657699..652fc4d8b62 100644 --- a/gcc/cfgloopanal.c +++ b/gcc/cfgloopanal.c @@ -314,7 +314,7 @@ seq_cost (const_rtx seq, bool speed) { set = single_set (seq); if (set) - cost += rtx_cost (set, SET, speed); + cost += set_rtx_cost (set, speed); else cost++; } diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c index b9238a9554f..61ca446f079 100644 --- a/gcc/loop-invariant.c +++ b/gcc/loop-invariant.c @@ -704,7 +704,7 @@ create_new_invariant (struct def *def, rtx insn, bitmap depends_on, the loop. Otherwise we save only cost of the computation. */ if (def) { - inv->cost = rtx_cost (set, SET, speed); + inv->cost = set_rtx_cost (set, speed); /* ??? Try to determine cheapness of address computation. Unfortunately the address cost is only a relative measure, we can't really compare it with any absolute number, but only with other address costs. diff --git a/gcc/postreload.c b/gcc/postreload.c index 72e487e057f..88b401f511c 100644 --- a/gcc/postreload.c +++ b/gcc/postreload.c @@ -1683,9 +1683,9 @@ move2add_use_add2_insn (rtx reg, rtx sym, rtx off, rtx insn) struct full_rtx_costs oldcst, newcst; rtx tem = gen_rtx_PLUS (GET_MODE (reg), reg, new_src); - get_full_rtx_cost (pat, SET, &oldcst); + get_full_set_rtx_cost (pat, &oldcst); SET_SRC (pat) = tem; - get_full_rtx_cost (pat, SET, &newcst); + get_full_set_rtx_cost (pat, &newcst); SET_SRC (pat) = src; if (costs_lt_p (&newcst, &oldcst, speed) @@ -1752,7 +1752,7 @@ move2add_use_add3_insn (rtx reg, rtx sym, rtx off, rtx insn) rtx plus_expr; init_costs_to_max (&mincst); - get_full_rtx_cost (pat, SET, &oldcst); + get_full_set_rtx_cost (pat, &oldcst); plus_expr = gen_rtx_PLUS (GET_MODE (reg), reg, const0_rtx); SET_SRC (pat) = plus_expr; @@ -1781,7 +1781,7 @@ move2add_use_add3_insn (rtx reg, rtx sym, rtx off, rtx insn) else { XEXP (plus_expr, 1) = new_src; - get_full_rtx_cost (pat, SET, &newcst); + get_full_set_rtx_cost (pat, &newcst); if (costs_lt_p (&newcst, &mincst, speed)) { @@ -1934,7 +1934,7 @@ reload_cse_move2add (rtx first) struct full_rtx_costs oldcst, newcst; rtx tem = gen_rtx_PLUS (GET_MODE (reg), reg, new_src); - get_full_rtx_cost (set, SET, &oldcst); + get_full_set_rtx_cost (set, &oldcst); SET_SRC (set) = tem; get_full_rtx_cost (tem, SET, &newcst); SET_SRC (set) = old_src; diff --git a/gcc/rtl.h b/gcc/rtl.h index d5d7b023ec5..84166c47fc2 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -1217,6 +1217,24 @@ extern bool constant_pool_constant_p (rtx); extern bool truncated_to_mode (enum machine_mode, const_rtx); extern int low_bitmask_len (enum machine_mode, unsigned HOST_WIDE_INT); +#ifndef GENERATOR_FILE +/* Return the cost of SET X. SPEED_P is true if optimizing for speed + rather than size. */ + +static inline int +set_rtx_cost (rtx x, bool speed_p) +{ + return rtx_cost (x, INSN, speed_p); +} + +/* Like set_rtx_cost, but return both the speed and size costs in C. */ + +static inline void +get_full_set_rtx_cost (rtx x, struct full_rtx_costs *c) +{ + get_full_rtx_cost (x, INSN, c); +} +#endif /* 1 if RTX is a subreg containing a reg that is already known to be sign- or zero-extended from the mode of the subreg to the mode of -- 2.30.2