From 91000c66b9eb9b3ec0a763c78c0f070b9b256850 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Sun, 6 May 2012 19:12:51 +0000 Subject: [PATCH] mips.c (mips_set_reg_reg_piece_cost): New function. gcc/ * config/mips/mips.c (mips_set_reg_reg_piece_cost): New function. (mips_set_reg_reg_cost): Likewise. (mips_rtx_costs): Handle SET. From-SVN: r187213 --- gcc/ChangeLog | 6 ++++++ gcc/config/mips/mips.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8d6637fbc19..55611c5b979 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2012-05-06 Richard Sandiford + + * config/mips/mips.c (mips_set_reg_reg_piece_cost): New function. + (mips_set_reg_reg_cost): Likewise. + (mips_rtx_costs): Handle SET. + 2012-05-06 Richard Sandiford * lower-subreg.c (shift_cost): Use set_src_cost, avoiding the SET. diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index 1e09f28d9a2..239d6f5a760 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -3490,6 +3490,37 @@ mips_zero_extend_cost (enum machine_mode mode, rtx op) return COSTS_N_INSNS (1); } +/* Return the cost of moving between two registers of mode MODE, + assuming that the move will be in pieces of at most UNITS bytes. */ + +static int +mips_set_reg_reg_piece_cost (enum machine_mode mode, unsigned int units) +{ + return COSTS_N_INSNS ((GET_MODE_SIZE (mode) + units - 1) / units); +} + +/* Return the cost of moving between two registers of mode MODE. */ + +static int +mips_set_reg_reg_cost (enum machine_mode mode) +{ + switch (GET_MODE_CLASS (mode)) + { + case MODE_CC: + return mips_set_reg_reg_piece_cost (mode, GET_MODE_SIZE (CCmode)); + + case MODE_FLOAT: + case MODE_COMPLEX_FLOAT: + case MODE_VECTOR_FLOAT: + if (TARGET_HARD_FLOAT) + return mips_set_reg_reg_piece_cost (mode, UNITS_PER_HWFPVALUE); + /* Fall through */ + + default: + return mips_set_reg_reg_piece_cost (mode, UNITS_PER_WORD); + } +} + /* Implement TARGET_RTX_COSTS. */ static bool @@ -3877,6 +3908,15 @@ mips_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, *total = mips_cost->fp_add; return false; + case SET: + if (register_operand (SET_DEST (x), VOIDmode) + && reg_or_0_operand (SET_SRC (x), VOIDmode)) + { + *total = mips_set_reg_reg_cost (GET_MODE (SET_DEST (x))); + return true; + } + return false; + default: return false; } -- 2.30.2