diff mbox

Bug fix in store_bit_field_1 for big endian targets (issue 51893)

Message ID 4F69979E.4070502@gmail.com
State New
Headers show

Commit Message

Aurelien Buhrig March 21, 2012, 8:55 a.m. UTC
Hi,

This patch (for 4.6) fixes a wrong subword index computation in
store_bit_field_1 for big endian targets when value is at least 4 times
bigger than a word (DI REG value with HI words).

It fixes a regression on gcc.c-torture/execute/bitfld-3.c for my current
backend port.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51893

OK to commit?

Aurélien

Comments

Eric Botcazou March 21, 2012, 9:53 p.m. UTC | #1
> This patch (for 4.6) fixes a wrong subword index computation in
> store_bit_field_1 for big endian targets when value is at least 4 times
> bigger than a word (DI REG value with HI words).
>
> It fixes a regression on gcc.c-torture/execute/bitfld-3.c for my current
> backend port.
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51893
>
> OK to commit?

It is OK for mainline on principle but there is no ChangeLog entry and the 
patch doesn't follow the GNU Coding Style: TABs instead of spaces, spaces 
before parentheses, etc.  See the equivalent code in extract_bit_field_1.
Moreover you need to properly test it on a mainstream big-endian platform.

See http://gcc.gnu.org/contribute.html for a more complete reference.
Alan Modra March 23, 2012, 3:39 a.m. UTC | #2
On Wed, Mar 21, 2012 at 10:53:07PM +0100, Eric Botcazou wrote:
> > This patch (for 4.6) fixes a wrong subword index computation in
> > store_bit_field_1 for big endian targets when value is at least 4 times
> > bigger than a word (DI REG value with HI words).
> >
> > It fixes a regression on gcc.c-torture/execute/bitfld-3.c for my current
> > backend port.
> >
> > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51893
> >
> > OK to commit?
> 
> It is OK for mainline on principle but there is no ChangeLog entry and the 
> patch doesn't follow the GNU Coding Style: TABs instead of spaces, spaces 
> before parentheses, etc.  See the equivalent code in extract_bit_field_1.
> Moreover you need to properly test it on a mainstream big-endian platform.

Passes bootstrap and regression test powerpc64-linux.
Eric Botcazou March 24, 2012, 9:51 a.m. UTC | #3
> Passes bootstrap and regression test powerpc64-linux.

Thanks a lot, Alan!

So, Aurelien, you only need to adjust the formatting of the patch and post a 
ChangeLog entry along with it.  TIA.
diff mbox

Patch

--- gcc-4.6.1.orig/gcc/expmed.c	2011-05-22 21:02:59.000000000 +0200
+++ src/gcc/expmed.c	2012-01-19 09:32:04.000000000 +0100
@@ -589,7 +589,10 @@ 
 	{
 	  /* 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,