[PATCH, PR 46801] Allow byte-aligned aggregate bit-fields in SRA

Martin Jambor mjambor@suse.cz
Wed Dec 29 03:07:00 GMT 2010


Hi,

PR 46801 tests for an optimization that is not carried out because SRA
currently does not even consider stuff with an aggregate bit-field in
them.  However, the screening of candidates can be made a bit more
permissive because problems are caused by aggregate fields that are
not byte-aligned, not by just any aggregate field with the bit-field
flag set.  And that is what the patch below does.

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

Thanks,

Martin


2010-12-28  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/46801
	* tree-sra.c (type_internals_preclude_sra_p): Check whether
	aggregate fields start at byte boundary instead of the bit-field flag.

	* testsuite/gnat.dg/pack9.adb: Remove xfail.


Index: mine/gcc/testsuite/gnat.dg/pack9.adb
===================================================================
--- mine.orig/gcc/testsuite/gnat.dg/pack9.adb	2010-12-28 23:35:28.000000000 +0100
+++ mine/gcc/testsuite/gnat.dg/pack9.adb	2010-12-28 23:35:30.000000000 +0100
@@ -15,5 +15,5 @@ package body Pack9 is
 
 end Pack9;
 
--- { dg-final { scan-tree-dump-not "gnat_rcheck" "optimized" { xfail *-*-* } } }
+-- { dg-final { scan-tree-dump-not "gnat_rcheck" "optimized" } }
 -- { dg-final { cleanup-tree-dump "optimized" } }
Index: mine/gcc/tree-sra.c
===================================================================
--- mine.orig/gcc/tree-sra.c	2010-12-28 23:29:36.000000000 +0100
+++ mine/gcc/tree-sra.c	2010-12-28 23:30:56.000000000 +0100
@@ -653,7 +653,8 @@ type_internals_preclude_sra_p (tree type
 		|| !DECL_FIELD_OFFSET (fld) || !DECL_SIZE (fld)
 		|| !host_integerp (DECL_FIELD_OFFSET (fld), 1)
 		|| !host_integerp (DECL_SIZE (fld), 1)
-		|| (DECL_BIT_FIELD (fld) && AGGREGATE_TYPE_P (ft)))
+		|| (AGGREGATE_TYPE_P (ft)
+		    && int_bit_position (fld) % BITS_PER_UNIT != 0))
 	      return true;
 
 	    if (AGGREGATE_TYPE_P (ft)



More information about the Gcc-patches mailing list