diff options
author | Roger Sayle <roger@eyesopen.com> | 2005-01-07 00:47:13 +0000 |
---|---|---|
committer | Roger Sayle <sayle@gcc.gnu.org> | 2005-01-07 00:47:13 +0000 |
commit | c79fc2963d970e9ca6316d8af8a9669b0ad04e5d (patch) | |
tree | 07e1e79883cfc32b1cc39767b3e85a50942e24b9 /gcc | |
parent | 59d7d7678602bb8dcbeff337a44efc76a3451f01 (diff) | |
download | gcc-c79fc2963d970e9ca6316d8af8a9669b0ad04e5d.zip gcc-c79fc2963d970e9ca6316d8af8a9669b0ad04e5d.tar.gz gcc-c79fc2963d970e9ca6316d8af8a9669b0ad04e5d.tar.bz2 |
simplify-rtx.c (simplify_subreg): Simplify truncations of shifts of sign or zero extended values.
* simplify-rtx.c (simplify_subreg): Simplify truncations of shifts
of sign or zero extended values.
From-SVN: r93022
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/simplify-rtx.c | 49 |
2 files changed, 54 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 44ef9c7..965fe59 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2005-01-06 Roger Sayle <roger@eyesopen.com> + + * simplify-rtx.c (simplify_subreg): Simplify truncations of shifts + of sign or zero extended values. + 2005-01-06 Geoffrey Keating <geoffk@apple.com> * c-cppbuiltin.c (builtin_define_float_constants): Set __*_EPSILON__ diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 6e208aa..0aa1e95 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -3829,6 +3829,55 @@ simplify_subreg (enum machine_mode outermode, rtx op, return CONST0_RTX (outermode); } + /* Simplify (subreg:QI (lshiftrt:SI (sign_extend:SI (x:QI)) C), 0) into + to (ashiftrt:QI (x:QI) C), where C is a suitable small constant and + the outer subreg is effectively a truncation to the original mode. */ + if ((GET_CODE (op) == LSHIFTRT + || GET_CODE (op) == ASHIFTRT) + && SCALAR_INT_MODE_P (outermode) + /* Ensure that OUTERMODE is at least twice as wide as the INNERMODE + to avoid the possibility that an outer LSHIFTRT shifts by more + than the sign extension's sign_bit_copies and introduces zeros + into the high bits of the result. */ + && (2 * GET_MODE_BITSIZE (outermode)) <= GET_MODE_BITSIZE (innermode) + && GET_CODE (XEXP (op, 1)) == CONST_INT + && GET_CODE (XEXP (op, 0)) == SIGN_EXTEND + && GET_MODE (XEXP (XEXP (op, 0), 0)) == outermode + && INTVAL (XEXP (op, 1)) < GET_MODE_BITSIZE (outermode) + && subreg_lsb_1 (outermode, innermode, byte) == 0) + return simplify_gen_binary (ASHIFTRT, outermode, + XEXP (XEXP (op, 0), 0), XEXP (op, 1)); + + /* Likewise (subreg:QI (lshiftrt:SI (zero_extend:SI (x:QI)) C), 0) into + to (lshiftrt:QI (x:QI) C), where C is a suitable small constant and + the outer subreg is effectively a truncation to the original mode. */ + if ((GET_CODE (op) == LSHIFTRT + || GET_CODE (op) == ASHIFTRT) + && SCALAR_INT_MODE_P (outermode) + && GET_MODE_BITSIZE (outermode) < GET_MODE_BITSIZE (innermode) + && GET_CODE (XEXP (op, 1)) == CONST_INT + && GET_CODE (XEXP (op, 0)) == ZERO_EXTEND + && GET_MODE (XEXP (XEXP (op, 0), 0)) == outermode + && INTVAL (XEXP (op, 1)) < GET_MODE_BITSIZE (outermode) + && subreg_lsb_1 (outermode, innermode, byte) == 0) + return simplify_gen_binary (LSHIFTRT, outermode, + XEXP (XEXP (op, 0), 0), XEXP (op, 1)); + + /* Likewise (subreg:QI (ashift:SI (zero_extend:SI (x:QI)) C), 0) into + to (ashift:QI (x:QI) C), where C is a suitable small constant and + the outer subreg is effectively a truncation to the original mode. */ + if (GET_CODE (op) == ASHIFT + && SCALAR_INT_MODE_P (outermode) + && GET_MODE_BITSIZE (outermode) < GET_MODE_BITSIZE (innermode) + && GET_CODE (XEXP (op, 1)) == CONST_INT + && (GET_CODE (XEXP (op, 0)) == ZERO_EXTEND + || GET_CODE (XEXP (op, 0)) == SIGN_EXTEND) + && GET_MODE (XEXP (XEXP (op, 0), 0)) == outermode + && INTVAL (XEXP (op, 1)) < GET_MODE_BITSIZE (outermode) + && subreg_lsb_1 (outermode, innermode, byte) == 0) + return simplify_gen_binary (ASHIFT, outermode, + XEXP (XEXP (op, 0), 0), XEXP (op, 1)); + return NULL_RTX; } |