From 629198e2662378fe918e4b72e1c3d0ee901a54c6 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Fri, 16 Jul 2004 07:35:58 +0000 Subject: [PATCH] mips.c (mips_rtx_costs): In mips16 code, set the cost of 0...255 to 0 when inside a SET. * config/mips/mips.c (mips_rtx_costs): In mips16 code, set the cost of 0...255 to 0 when inside a SET. From-SVN: r84804 --- gcc/ChangeLog | 5 +++++ gcc/config/mips/mips.c | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ae093686d96..8507a920cd8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2004-07-16 Richard Sandiford + + * config/mips/mips.c (mips_rtx_costs): In mips16 code, set the cost + of 0...255 to 0 when inside a SET. + 2004-07-16 Richard Sandiford * config/mips/mips.md: Remove mips16 define_peepholes. diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index 679416c121f..7f72535f2cf 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -2192,6 +2192,20 @@ mips_rtx_costs (rtx x, int code, int outer_code, int *total) return true; } + /* Constants in the range 0...255 can be loaded with an unextended + instruction. They are therefore as cheap as a register move. + + Given the choice between "li R1,0...255" and "move R1,R2" + (where R2 is a known constant), it is usually better to use "li", + since we do not want to unnessarily extend the lifetime of R2. */ + if (outer_code == SET + && INTVAL (x) >= 0 + && INTVAL (x) < 256) + { + *total = 0; + return true; + } + /* Otherwise fall through to the handling below. */ case CONST: -- 2.30.2