diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-11-24 12:57:37 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-11-24 12:57:37 +0000 |
commit | 4ed4afb9d6c5c512b4cec5dbe90239f38ca523c3 (patch) | |
tree | f665d5278a21eaab0e6a13d9c9e2d0869b83709d /gcc/dse.c | |
parent | d1a2e87538a36e7985266ca39b9183075ce6e975 (diff) | |
download | gcc-4ed4afb9d6c5c512b4cec5dbe90239f38ca523c3.tar.gz |
PR middle-end/37135
* dse.c (find_shift_sequence): Optimize extraction from a constant.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@142157 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/dse.c')
-rw-r--r-- | gcc/dse.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/dse.c b/gcc/dse.c index 0a3ebb40ffa..d7fb2d8aa20 100644 --- a/gcc/dse.c +++ b/gcc/dse.c @@ -1447,6 +1447,29 @@ find_shift_sequence (int access_size, rtx target, new_reg, shift_seq, insn, new_lhs; int cost; + /* If a constant was stored into memory, try to simplify it here, + otherwise the cost of the shift might preclude this optimization + e.g. at -Os, even when no actual shift will be needed. */ + if (CONSTANT_P (store_info->rhs)) + { + unsigned int byte = subreg_lowpart_offset (new_mode, store_mode); + rtx ret = simplify_subreg (new_mode, store_info->rhs, store_mode, + byte); + if (ret && CONSTANT_P (ret)) + { + ret = simplify_const_binary_operation (LSHIFTRT, new_mode, + ret, GEN_INT (shift)); + if (ret && CONSTANT_P (ret)) + { + byte = subreg_lowpart_offset (read_mode, new_mode); + ret = simplify_subreg (read_mode, ret, new_mode, byte); + if (ret && CONSTANT_P (ret) + && rtx_cost (ret, SET, speed) <= COSTS_N_INSNS (1)) + return ret; + } + } + } + /* Try a wider mode if truncating the store mode to NEW_MODE requires a real instruction. */ if (GET_MODE_BITSIZE (new_mode) < GET_MODE_BITSIZE (store_mode) |