diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-10-08 20:49:19 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-10-08 20:49:19 +0000 |
commit | abb1ab9c610c809eaf965147a2eab843a5046058 (patch) | |
tree | 132af12e172f41cd9faf29bd32999c04ed39e7ec /gcc/simplify-rtx.c | |
parent | a05f57b77402f7a47cbc7d784ae588c5f9798dc7 (diff) | |
download | gcc-abb1ab9c610c809eaf965147a2eab843a5046058.tar.gz |
PR tree-optimization/45903
* simplify-rtx.c (simplify_subreg): Optimize lowpart SUBREG
of *SHIFTRT of MEM.
* gcc.target/i386/pr45903.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165200 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/simplify-rtx.c')
-rw-r--r-- | gcc/simplify-rtx.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 122c45fdf64..ff1437be41b 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -5482,6 +5482,31 @@ simplify_subreg (enum machine_mode outermode, rtx op, : byte + shifted_bytes)); } + /* If we have a lowpart SUBREG of a right shift of MEM, make a new MEM + and try replacing the SUBREG and shift with it. Don't do this if + the MEM has a mode-dependent address or if we would be widening it. */ + + if ((GET_CODE (op) == LSHIFTRT + || GET_CODE (op) == ASHIFTRT) + && MEM_P (XEXP (op, 0)) + && CONST_INT_P (XEXP (op, 1)) + && GET_MODE_SIZE (outermode) < GET_MODE_SIZE (GET_MODE (op)) + && (INTVAL (XEXP (op, 1)) % GET_MODE_BITSIZE (outermode)) == 0 + && INTVAL (XEXP (op, 1)) > 0 + && INTVAL (XEXP (op, 1)) < GET_MODE_BITSIZE (innermode) + && ! mode_dependent_address_p (XEXP (XEXP (op, 0), 0)) + && ! MEM_VOLATILE_P (XEXP (op, 0)) + && byte == subreg_lowpart_offset (outermode, innermode) + && (GET_MODE_SIZE (outermode) >= UNITS_PER_WORD + || WORDS_BIG_ENDIAN == BYTES_BIG_ENDIAN)) + { + int shifted_bytes = INTVAL (XEXP (op, 1)) / BITS_PER_UNIT; + return adjust_address_nv (XEXP (op, 0), outermode, + (WORDS_BIG_ENDIAN + ? byte - shifted_bytes + : byte + shifted_bytes)); + } + return NULL_RTX; } |