The following patch is necessary to make DECL_BIT_FIELD_REPRESENTATIVE useable in COMPONENT_REFs (which is the easiest way to get some bitfield lowering).
An earlier patch passed bootstrapped and testing on x86_64-unknown-linux-gnu (with bitfield lowering), re-testing after minor changes. 2013-11-11 Richard Biener <rguent...@suse.de> * tree-ssa-alias.c (nonoverlapping_component_refs_of_decl_p): Properly handle DECL_BIT_FIELD_REPRESENTATIVE occuring as COMPONENT_REF operand. * alias.c (nonoverlapping_component_refs_p): Likewise. * stor-layout.c (start_bitfield_representative): Mark DECL_BIT_FIELD_REPRESENTATIVE as DECL_NONADDRESSABLE_P. Index: gcc/tree-ssa-alias.c =================================================================== *** gcc/tree-ssa-alias.c.orig 2013-11-11 10:32:25.000000000 +0100 --- gcc/tree-ssa-alias.c 2013-11-11 11:35:16.042386275 +0100 *************** nonoverlapping_component_refs_of_decl_p *** 829,841 **** if (type1 != type2 || TREE_CODE (type1) != RECORD_TYPE) goto may_overlap; - /* Different fields of the same record type cannot overlap. - ??? Bitfields can overlap at RTL level so punt on them. */ if (field1 != field2) { component_refs1.release (); component_refs2.release (); ! return !(DECL_BIT_FIELD (field1) && DECL_BIT_FIELD (field2)); } } --- 829,848 ---- if (type1 != type2 || TREE_CODE (type1) != RECORD_TYPE) goto may_overlap; if (field1 != field2) { component_refs1.release (); component_refs2.release (); ! /* A field and its representative need to be considered the ! same. */ ! if (DECL_BIT_FIELD_REPRESENTATIVE (field1) == field2 ! || DECL_BIT_FIELD_REPRESENTATIVE (field2) == field1) ! return false; ! /* Different fields of the same record type cannot overlap. ! ??? Bitfields can overlap at RTL level so punt on them. */ ! if (DECL_BIT_FIELD (field1) && DECL_BIT_FIELD (field2)) ! return false; ! return true; } } Index: gcc/stor-layout.c =================================================================== *** gcc/stor-layout.c.orig 2013-11-11 12:05:16.000000000 +0100 --- gcc/stor-layout.c 2013-11-11 13:42:14.947161958 +0100 *************** start_bitfield_representative (tree fiel *** 1747,1752 **** --- 1747,1757 ---- DECL_SIZE_UNIT (repr) = DECL_SIZE_UNIT (field); DECL_PACKED (repr) = DECL_PACKED (field); DECL_CONTEXT (repr) = DECL_CONTEXT (field); + /* There are no indirect accesses to this field. If we introduce + some then they have to use the record alias set. This makes + sure to properly conflict with [indirect] accesses to addressable + fields of the bitfield group. */ + DECL_NONADDRESSABLE_P (repr) = 1; return repr; } Index: gcc/alias.c =================================================================== *** gcc/alias.c.orig 2013-11-11 15:29:12.000000000 +0100 --- gcc/alias.c 2013-11-11 15:29:17.054068720 +0100 *************** nonoverlapping_component_refs_p (const_r *** 2302,2310 **** found: /* If we're left with accessing different fields of a structure, then no ! possible overlap, unless they are both bitfields. */ if (TREE_CODE (typex) == RECORD_TYPE && fieldx != fieldy) ! return !(DECL_BIT_FIELD (fieldx) && DECL_BIT_FIELD (fieldy)); /* The comparison on the current field failed. If we're accessing a very nested structure, look at the next outer level. */ --- 2302,2316 ---- found: /* If we're left with accessing different fields of a structure, then no ! possible overlap, unless they are both bitfields or one is ! the representative of the other. */ if (TREE_CODE (typex) == RECORD_TYPE && fieldx != fieldy) ! { ! if (DECL_BIT_FIELD_REPRESENTATIVE (fieldx) == fieldy ! || DECL_BIT_FIELD_REPRESENTATIVE (fieldy) == fieldx) ! return false; ! return !(DECL_BIT_FIELD (fieldx) && DECL_BIT_FIELD (fieldy)); ! } /* The comparison on the current field failed. If we're accessing a very nested structure, look at the next outer level. */