From 4d18c297eb4e8f4f1cda3ccfd1efac6c033b9a16 Mon Sep 17 00:00:00 2001 From: rsandifo Date: Tue, 17 Jan 2012 20:37:46 +0000 Subject: [PATCH] gcc/ 2012-01-17 Andreas Krebbel Richard Sandiford PR middle-end/50325 PR middle-end/51192 * optabs.h (simplify_expand_binop): Declare. * optabs.c (simplify_expand_binop): Make global. * expmed.c (store_bit_field_1): Use simplify_expand_binop on big endian targets if the source cannot be exactly covered by word mode chunks. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@183262 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 11 +++++++++++ gcc/expmed.c | 18 +++++++++++++++--- gcc/optabs.c | 2 +- gcc/optabs.h | 4 ++++ 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fbd93bb..6def41f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2012-01-17 Andreas Krebbel + Richard Sandiford + + PR middle-end/50325 + PR middle-end/51192 + * optabs.h (simplify_expand_binop): Declare. + * optabs.c (simplify_expand_binop): Make global. + * expmed.c (store_bit_field_1): Use simplify_expand_binop on big + endian targets if the source cannot be exactly covered by word + mode chunks. + 2012-01-17 Jakub Jelinek PR bootstrap/51872 diff --git a/gcc/expmed.c b/gcc/expmed.c index bced96e..09a933d 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -557,9 +557,21 @@ store_bit_field_1 (rtx str_rtx, unsigned HOST_WIDE_INT bitsize, 0) : (int) i * BITS_PER_WORD); rtx value_word = operand_subword_force (value, wordnum, fieldmode); - - if (!store_bit_field_1 (op0, MIN (BITS_PER_WORD, - bitsize - i * BITS_PER_WORD), + unsigned HOST_WIDE_INT new_bitsize = + MIN (BITS_PER_WORD, bitsize - i * BITS_PER_WORD); + + /* If the remaining chunk doesn't have full wordsize we have + to make sure that for big endian machines the higher order + bits are used. */ + if (new_bitsize < BITS_PER_WORD && BYTES_BIG_ENDIAN && !backwards) + value_word = simplify_expand_binop (word_mode, lshr_optab, + value_word, + GEN_INT (BITS_PER_WORD + - new_bitsize), + NULL_RTX, true, + OPTAB_LIB_WIDEN); + + if (!store_bit_field_1 (op0, new_bitsize, bitnum + bit_offset, bitregion_start, bitregion_end, word_mode, diff --git a/gcc/optabs.c b/gcc/optabs.c index b586eb9..a532ba3 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -659,7 +659,7 @@ expand_ternary_op (enum machine_mode mode, optab ternary_optab, rtx op0, calculated at compile time. The arguments and return value are otherwise the same as for expand_binop. */ -static rtx +rtx simplify_expand_binop (enum machine_mode mode, optab binoptab, rtx op0, rtx op1, rtx target, int unsignedp, enum optab_methods methods) diff --git a/gcc/optabs.h b/gcc/optabs.h index cc4854d..6ad6dae 100644 --- a/gcc/optabs.h +++ b/gcc/optabs.h @@ -859,6 +859,10 @@ extern rtx expand_ternary_op (enum machine_mode mode, optab ternary_optab, extern rtx expand_binop (enum machine_mode, optab, rtx, rtx, rtx, int, enum optab_methods); +extern rtx simplify_expand_binop (enum machine_mode mode, optab binoptab, + rtx op0, rtx op1, rtx target, int unsignedp, + enum optab_methods methods); + extern bool force_expand_binop (enum machine_mode, optab, rtx, rtx, rtx, int, enum optab_methods); -- 2.7.4