diff mbox

[SRA] Do not care about trailing zero-sized bit-fields any more

Message ID 20100924165441.GB31666@virgil.arch.suse.de
State New
Headers show

Commit Message

Martin Jambor Sept. 24, 2010, 4:54 p.m. UTC
Hi,

with SRA producing MEM_REFs to access components of aggregates,
zero-sized trailing bit-fields are no longer a problem (PR 43191,
better description:
http://gcc.gnu.org/ml/gcc-patches/2010-03/msg00207.html) and so there
is no need to handle them specially.

Bootstrapped and tested on x86_64-linux.  OK for trunk?

Thanks,

Martin


2010-09-24  Martin Jambor  <mjambor@suse.cz>

	* tree-sra.c (type_consists_of_records_p): Do not check for trailing
	zero sized bit-fields.

Comments

Richard Biener Sept. 24, 2010, 5:06 p.m. UTC | #1
On Fri, 24 Sep 2010, Martin Jambor wrote:

> Hi,
> 
> with SRA producing MEM_REFs to access components of aggregates,
> zero-sized trailing bit-fields are no longer a problem (PR 43191,
> better description:
> http://gcc.gnu.org/ml/gcc-patches/2010-03/msg00207.html) and so there
> is no need to handle them specially.
> 
> Bootstrapped and tested on x86_64-linux.  OK for trunk?

Ok.

Thanks,
Richard.

> Thanks,
> 
> Martin
> 
> 
> 2010-09-24  Martin Jambor  <mjambor@suse.cz>
> 
> 	* tree-sra.c (type_consists_of_records_p): Do not check for trailing
> 	zero sized bit-fields.
> 
> Index: mine/gcc/tree-sra.c
> ===================================================================
> --- mine.orig/gcc/tree-sra.c
> +++ mine/gcc/tree-sra.c
> @@ -815,14 +815,12 @@ create_access (tree expr, gimple stmt, b
>  
>  /* Return true iff TYPE is a RECORD_TYPE with fields that are either of gimple
>     register types or (recursively) records with only these two kinds of fields.
> -   It also returns false if any of these records has a zero-size field as its
> -   last field or has a bit-field.  */
> +   It also returns false if any of these records contains a bit-field.  */
>  
>  static bool
>  type_consists_of_records_p (tree type)
>  {
>    tree fld;
> -  bool last_fld_has_zero_size = false;
>  
>    if (TREE_CODE (type) != RECORD_TYPE)
>      return false;
> @@ -838,13 +836,8 @@ type_consists_of_records_p (tree type)
>  	if (!is_gimple_reg_type (ft)
>  	    && !type_consists_of_records_p (ft))
>  	  return false;
> -
> -	last_fld_has_zero_size = tree_low_cst (DECL_SIZE (fld), 1) == 0;
>        }
>  
> -  if (last_fld_has_zero_size)
> -    return false;
> -
>    return true;
>  }
>  
> 
>
Steven Bosscher Sept. 24, 2010, 5:07 p.m. UTC | #2
On Fri, Sep 24, 2010 at 6:54 PM, Martin Jambor <mjambor@suse.cz> wrote:
>
>        * tree-sra.c (type_consists_of_records_p): Do not check for trailing
>        zero sized bit-fields.


Test case? :-D

Ciao!
Steven
Martin Jambor Sept. 29, 2010, 9:07 a.m. UTC | #3
Hi,

On Fri, Sep 24, 2010 at 07:07:01PM +0200, Steven Bosscher wrote:
> On Fri, Sep 24, 2010 at 6:54 PM, Martin Jambor <mjambor@suse.cz> wrote:
> >
> >            * tree-sra.c (type_consists_of_records_p): Do not check for trailing
> >            zero sized bit-fields.
> 
> 
> Test case? :-D

Two testcases are already in trunk:
testsuite/gcc.c-torture/compile/pr43164.c and
testsuite/gcc.c-torture/compile/pr43191.c.

See the email I linked when posting the patch
(http://gcc.gnu.org/ml/gcc-patches/2010-03/msg00207.html) for more
details.

I'll re-test the patch today with a fresh checkout of trunk and
commit it afterwards.

Thanks,

Martin
diff mbox

Patch

Index: mine/gcc/tree-sra.c
===================================================================
--- mine.orig/gcc/tree-sra.c
+++ mine/gcc/tree-sra.c
@@ -815,14 +815,12 @@  create_access (tree expr, gimple stmt, b
 
 /* Return true iff TYPE is a RECORD_TYPE with fields that are either of gimple
    register types or (recursively) records with only these two kinds of fields.
-   It also returns false if any of these records has a zero-size field as its
-   last field or has a bit-field.  */
+   It also returns false if any of these records contains a bit-field.  */
 
 static bool
 type_consists_of_records_p (tree type)
 {
   tree fld;
-  bool last_fld_has_zero_size = false;
 
   if (TREE_CODE (type) != RECORD_TYPE)
     return false;
@@ -838,13 +836,8 @@  type_consists_of_records_p (tree type)
 	if (!is_gimple_reg_type (ft)
 	    && !type_consists_of_records_p (ft))
 	  return false;
-
-	last_fld_has_zero_size = tree_low_cst (DECL_SIZE (fld), 1) == 0;
       }
 
-  if (last_fld_has_zero_size)
-    return false;
-
   return true;
 }