diff options
author | Roger Sayle <roger@eyesopen.com> | 2003-12-05 14:06:46 +0000 |
---|---|---|
committer | Roger Sayle <sayle@gcc.gnu.org> | 2003-12-05 14:06:46 +0000 |
commit | 2a67ff5e9e1a909a2c4a056920abdfadbbe293dd (patch) | |
tree | 7b626e91f813aeaea1a249d43406dd0cb5930b3e | |
parent | 64ed86c71833cb21c29cee783cde01c5e1a3d2f4 (diff) | |
download | gcc-2a67ff5e9e1a909a2c4a056920abdfadbbe293dd.tar.gz |
dojump.c (do_jump): If the expression being compared against zero...
* dojump.c (do_jump): If the expression being compared against
zero, is the subreg of a promoted variable, perform the comparison
in the promoted mode.
* simplify-rtx.c (simplify_unary_operation): Optimize sign and
zero-extensions of subregs of promoted variables where the
extension is identical to that used to promote the variable.
From-SVN: r74332
-rw-r--r-- | gcc/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/dojump.c | 9 | ||||
-rw-r--r-- | gcc/simplify-rtx.c | 22 |
3 files changed, 37 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4f79d5e521e..66ba57984c9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2003-12-05 Roger Sayle <roger@eyesopen.com> + + * dojump.c (do_jump): If the expression being compared against + zero, is the subreg of a promoted variable, perform the comparison + in the promoted mode. + * simplify-rtx.c (simplify_unary_operation): Optimize sign and + zero-extensions of subregs of promoted variables where the + extension is identical to that used to promote the variable. + 2003-12-05 Hans-Peter Nilsson <hp@axis.com> PR target/13256 diff --git a/gcc/dojump.c b/gcc/dojump.c index 2ed014bacf9..8887c498eca 100644 --- a/gcc/dojump.c +++ b/gcc/dojump.c @@ -584,7 +584,14 @@ do_jump (tree exp, rtx if_false_label, rtx if_true_label) { /* The RTL optimizers prefer comparisons against pseudos. */ if (GET_CODE (temp) == SUBREG) - temp = copy_to_reg (temp); + { + /* Compare promoted variables in their promoted mode. */ + if (SUBREG_PROMOTED_VAR_P (temp) + && GET_CODE (XEXP (temp, 0)) == REG) + temp = XEXP (temp, 0); + else + temp = copy_to_reg (temp); + } do_compare_rtx_and_jump (temp, CONST0_RTX (GET_MODE (temp)), NE, TREE_UNSIGNED (TREE_TYPE (exp)), GET_MODE (temp), NULL_RTX, diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index bf44b55e765..ffa87cd785f 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -1031,6 +1031,15 @@ simplify_unary_operation (enum rtx_code code, enum machine_mode mode, && GET_CODE (XEXP (XEXP (op, 0), 1)) == LABEL_REF) return XEXP (op, 0); + /* Check for a sign extension of a subreg of a promoted + variable, where the promotion is sign-extended, and the + target mode is the same as the variable's promotion. */ + if (GET_CODE (op) == SUBREG + && SUBREG_PROMOTED_VAR_P (op) + && ! SUBREG_PROMOTED_UNSIGNED_P (op) + && GET_MODE (XEXP (op, 0)) == mode) + return XEXP (op, 0); + #if defined(POINTERS_EXTEND_UNSIGNED) && !defined(HAVE_ptr_extend) if (! POINTERS_EXTEND_UNSIGNED && mode == Pmode && GET_MODE (op) == ptr_mode @@ -1043,8 +1052,17 @@ simplify_unary_operation (enum rtx_code code, enum machine_mode mode, #endif break; -#if defined(POINTERS_EXTEND_UNSIGNED) && !defined(HAVE_ptr_extend) case ZERO_EXTEND: + /* Check for a zero extension of a subreg of a promoted + variable, where the promotion is zero-extended, and the + target mode is the same as the variable's promotion. */ + if (GET_CODE (op) == SUBREG + && SUBREG_PROMOTED_VAR_P (op) + && SUBREG_PROMOTED_UNSIGNED_P (op) + && GET_MODE (XEXP (op, 0)) == mode) + return XEXP (op, 0); + +#if defined(POINTERS_EXTEND_UNSIGNED) && !defined(HAVE_ptr_extend) if (POINTERS_EXTEND_UNSIGNED > 0 && mode == Pmode && GET_MODE (op) == ptr_mode && (CONSTANT_P (op) @@ -1053,8 +1071,8 @@ simplify_unary_operation (enum rtx_code code, enum machine_mode mode, && REG_POINTER (SUBREG_REG (op)) && GET_MODE (SUBREG_REG (op)) == Pmode))) return convert_memory_address (Pmode, op); - break; #endif + break; default: break; |