OSDN Git Service

gcc/
[pf3gnuchains/gcc-fork.git] / gcc / expmed.c
index cfa045b..09a933d 100644 (file)
@@ -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,
@@ -4216,10 +4228,9 @@ expand_divmod (int rem_flag, enum tree_code code, enum machine_mode mode,
                                        << (HOST_BITS_PER_WIDE_INT - 1)))
                          set_dst_reg_note (insn, REG_EQUAL,
                                            gen_rtx_DIV (compute_mode, op0,
-                                                        GEN_INT
-                                                          (trunc_int_for_mode
-                                                            (abs_d,
-                                                             compute_mode))),
+                                                        gen_int_mode
+                                                          (abs_d,
+                                                           compute_mode)),
                                            quotient);
 
                        quotient = expand_unop (compute_mode, neg_optab,