This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Reload bug & SRA oddness


On May  6, 2007, Alexandre Oliva <aoliva@redhat.com> wrote:

> struct a { unsigned long long x : 16, y : 15, z : 33; };
> struct a fa(struct a v) { return v; }
> struct b { unsigned long long x : 16, y : 16, z : 32; };
> struct b fb(struct b v) { return v; }

Err...  This one (quilt-refreshed) should even compile ;-)

It has actually passed bootstrap and regression testing on
a i686-linux-gnu native built on a x86_64-linux-gnu OS.  Ok to install
along with the other previous patches?

for gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* tree-sra.c (try_instantiate_multiple_fields): Grow alignment
	to fit wider fields that start within the same word.

Index: gcc/tree-sra.c
===================================================================
--- gcc/tree-sra.c.orig	2007-05-06 11:53:04.000000000 -0300
+++ gcc/tree-sra.c	2007-05-06 11:53:49.000000000 -0300
@@ -1521,13 +1521,38 @@ try_instantiate_multiple_fields (struct 
       if (bit + size == nbit)
 	{
 	  if ((bit & alchk) != ((nbit + nsize - 1) & alchk))
-	    break;
+	    {
+	      /* If we're at an alignment boundary, don't bother
+		 growing alignment such that we can include this next
+		 field.  */
+	      if ((nbit & alchk)
+		  || GET_MODE_BITSIZE (DECL_MODE (f)) <= align)
+		break;
+
+	      align = GET_MODE_BITSIZE (DECL_MODE (f));
+	      alchk = align - 1;
+	      alchk = ~alchk;
+
+	      if ((bit & alchk) != ((nbit + nsize - 1) & alchk))
+		break;
+	    }
 	  size += nsize;
 	}
       else if (nbit + nsize == bit)
 	{
 	  if ((nbit & alchk) != ((bit + size - 1) & alchk))
-	    break;
+	    {
+	      if ((bit & alchk)
+		  || GET_MODE_BITSIZE (DECL_MODE (f)) <= align)
+		break;
+
+	      align = GET_MODE_BITSIZE (DECL_MODE (f));
+	      alchk = align - 1;
+	      alchk = ~alchk;
+
+	      if ((nbit & alchk) != ((bit + size - 1) & alchk))
+		break;
+	    }
 	  bit = nbit;
 	  size += nsize;
 	}
-- 
Alexandre Oliva         http://www.lsd.ic.unicamp.br/~oliva/
FSF Latin America Board Member         http://www.fsfla.org/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]