diff options
author | Richard Sandiford <rsandifo@nildram.co.uk> | 2007-10-19 09:17:17 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2007-10-19 09:17:17 +0000 |
commit | 213ce6f2c0708ec60e77e0b91cbb5b51b824775c (patch) | |
tree | 0efc2df8f4f9a1aaa64a0ab8542de8bd3d752679 | |
parent | b87bc4e835ac462427c9185ea2ad120f1338dd7e (diff) | |
download | gcc-213ce6f2c0708ec60e77e0b91cbb5b51b824775c.zip gcc-213ce6f2c0708ec60e77e0b91cbb5b51b824775c.tar.gz gcc-213ce6f2c0708ec60e77e0b91cbb5b51b824775c.tar.bz2 |
mips.c (mips_canonicalize_comparison): Check mips_relational_operand_ok_p before trying to rewrite the test.
gcc/
* config/mips/mips.c (mips_canonicalize_comparison): Check
mips_relational_operand_ok_p before trying to rewrite the test.
Only calculate PLUS_ONE if needed.
(mips_emit_int_relational): Don't call mips_relational_operand_ok_p
here.
From-SVN: r129483
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/config/mips/mips.c | 70 |
2 files changed, 40 insertions, 38 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 26433bb..f7454c5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,13 @@ 2007-10-19 Richard Sandiford <rsandifo@nildram.co.uk> + * config/mips/mips.c (mips_canonicalize_comparison): Check + mips_relational_operand_ok_p before trying to rewrite the test. + Only calculate PLUS_ONE if needed. + (mips_emit_int_relational): Don't call mips_relational_operand_ok_p + here. + +2007-10-19 Richard Sandiford <rsandifo@nildram.co.uk> + * config/mips/mips.c (mips16e_build_save_restore): Fix *OFFSET_PTR calculation. diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index 781388a..8c45369 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -3678,40 +3678,38 @@ static bool mips_canonicalize_comparison (enum rtx_code *code, rtx *cmp1, enum machine_mode mode) { - HOST_WIDE_INT original, plus_one; + HOST_WIDE_INT plus_one; - if (GET_CODE (*cmp1) != CONST_INT) - return false; - - original = INTVAL (*cmp1); - plus_one = trunc_int_for_mode ((unsigned HOST_WIDE_INT) original + 1, mode); - - switch (*code) - { - case LE: - if (original < plus_one) - { - *code = LT; - *cmp1 = force_reg (mode, GEN_INT (plus_one)); - return true; - } - break; + if (mips_relational_operand_ok_p (*code, *cmp1)) + return true; - case LEU: - if (plus_one != 0) - { - *code = LTU; - *cmp1 = force_reg (mode, GEN_INT (plus_one)); - return true; - } - break; + if (GET_CODE (*cmp1) == CONST_INT) + switch (*code) + { + case LE: + plus_one = trunc_int_for_mode (UINTVAL (*cmp1) + 1, mode); + if (INTVAL (*cmp1) < plus_one) + { + *code = LT; + *cmp1 = force_reg (mode, GEN_INT (plus_one)); + return true; + } + break; - default: - return false; - } + case LEU: + plus_one = trunc_int_for_mode (UINTVAL (*cmp1) + 1, mode); + if (plus_one != 0) + { + *code = LTU; + *cmp1 = force_reg (mode, GEN_INT (plus_one)); + return true; + } + break; + default: + break; + } return false; - } /* Compare CMP0 and CMP1 using relational operator CODE and store the @@ -3723,19 +3721,15 @@ static void mips_emit_int_relational (enum rtx_code code, bool *invert_ptr, rtx target, rtx cmp0, rtx cmp1) { - /* First see if there is a MIPS instruction that can do this operation - with CMP1 in its current form. If not, try to canonicalize the - comparison to LT. If that fails, try doing the same for the - inverse operation. If that also fails, force CMP1 into a register - and try again. */ - if (mips_relational_operand_ok_p (code, cmp1)) - mips_emit_binary (code, target, cmp0, cmp1); - else if (mips_canonicalize_comparison (&code, &cmp1, GET_MODE (target))) + /* First see if there is a MIPS instruction that can do this operation. + If not, try doing the same for the inverse operation. If that also + fails, force CMP1 into a register and try again. */ + if (mips_canonicalize_comparison (&code, &cmp1, GET_MODE (target))) mips_emit_binary (code, target, cmp0, cmp1); else { enum rtx_code inv_code = reverse_condition (code); - if (!mips_relational_operand_ok_p (inv_code, cmp1)) + if (!mips_canonicalize_comparison (&inv_code, &cmp1, GET_MODE (target))) { cmp1 = force_reg (GET_MODE (cmp0), cmp1); mips_emit_int_relational (code, invert_ptr, target, cmp0, cmp1); |