re PR middle-end/51893 (Wrong subword index computation in store_bit_field_1 on BIG_E...
authorAurelien Buhrig <aurelien.buhrig.gcc@gmail.com>
Tue, 27 Mar 2012 20:50:16 +0000 (20:50 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Tue, 27 Mar 2012 20:50:16 +0000 (20:50 +0000)
PR middle-end/51893
* expmed.c (store_bit_field_1): Fix wordnum value for big-endian
targets.

From-SVN: r185897

gcc/ChangeLog
gcc/expmed.c

index cc4f0cb3a115fdf6743d5c561916075e5f89ad4f..a7a766153e7804b7d2631923769a669b661da025 100644 (file)
@@ -1,3 +1,9 @@
+2012-03-27  Aurelien Buhrig  <aurelien.buhrig.gcc@gmail.com>
+
+       PR middle-end/51893
+       * expmed.c (store_bit_field_1): Fix wordnum value for big-endian
+       targets.
+
 2012-03-27  Oleg Endo  <olegendo@gcc.gnu.org>
 
        PR target/50751
index 54e51dca02dd28a98a0f1f6a26b60997d4f43f78..5eea2ab8b5177441e8a750710651699218fb1cf9 100644 (file)
@@ -550,7 +550,10 @@ store_bit_field_1 (rtx str_rtx, unsigned HOST_WIDE_INT bitsize,
        {
          /* If I is 0, use the low-order word in both field and target;
             if I is 1, use the next to lowest word; and so on.  */
-         unsigned int wordnum = (backwards ? nwords - i - 1 : i);
+         unsigned int wordnum = (backwards
+                                 ? GET_MODE_SIZE (fieldmode) / UNITS_PER_WORD
+                                 - i - 1
+                                 : i);
          unsigned int bit_offset = (backwards
                                     ? MAX ((int) bitsize - ((int) i + 1)
                                            * BITS_PER_WORD,