Patchwork [PR,tree-optimization/46620,4.4] skip padding in bitfield SRA grouping

login
register
mail settings
Submitter Alexandre Oliva
Date Feb. 16, 2011, 10:04 a.m.
Message ID <or39no70tr.fsf@livre.localdomain>
Download mbox | patch
Permalink /patch/83351/
State New
Headers show

Comments

Alexandre Oliva - Feb. 16, 2011, 10:04 a.m.
Before the latest SRA rewrite, we had a pass that attempted to group
multiple bitfields into single variables.  It attempted to extend these
variables to cover padding bits, but there was a bug that got it
confused when it found padding bits before the range it intended to
cover.

This patch changes the tests so that the tentatively-extended range will
always shrink towards the range of interest, instead of getting stuck at
a padding range.

Regstrapped on x86_64-linux-gnu.  Ok to install?
Richard Guenther - Feb. 16, 2011, 10:23 a.m.
On Wed, Feb 16, 2011 at 11:04 AM, Alexandre Oliva <aoliva@redhat.com> wrote:
> Before the latest SRA rewrite, we had a pass that attempted to group
> multiple bitfields into single variables.  It attempted to extend these
> variables to cover padding bits, but there was a bug that got it
> confused when it found padding bits before the range it intended to
> cover.
>
> This patch changes the tests so that the tentatively-extended range will
> always shrink towards the range of interest, instead of getting stuck at
> a padding range.
>
> Regstrapped on x86_64-linux-gnu.  Ok to install?

Please add a runtime testcase for such wrong-code bugs.  Ok with
that, please also install the testcase on the 4.5 branch and trunk.

Thanks,
Richard.

Patch

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

	PR tree-optimization/46620
	* tree-sra.c (try_instantiate_multiple_fields): Don't get stuck at
	padding within accessed words.

Index: gcc/tree-sra.c
===================================================================
--- gcc/tree-sra.c.orig	2011-02-15 22:32:20.659134294 -0200
+++ gcc/tree-sra.c	2011-02-15 22:37:41.632435631 -0200
@@ -1661,13 +1661,13 @@  try_instantiate_multiple_fields (struct 
 		  || mbit + msize <= fbit)
 		continue;
 
-	      if (fbit <= mbit)
+	      if (fbit < bit)
 		{
 		  unsigned HOST_WIDE_INT diff = fbit + fsize - mbit;
 		  mbit += diff;
 		  msize -= diff;
 		}
-	      else if (fbit > mbit)
+	      else if (fbit > bit)
 		msize -= (mbit + msize - fbit);
 	      else
 		gcc_unreachable ();