Hi! On Wed, 18 Apr 2012 18:16:32 +0200, Bernd Schmidt <ber...@codesourcery.com> wrote: > On 04/18/2012 06:14 PM, Richard Earnshaw wrote: > > On 18/04/12 16:37, Thomas Schwinge wrote: > >> gcc/testsuite/ > >> * gcc.dg/tree-ssa/20030922-1.c: Compile with > >> -fno-strict-volatile-bitfields. > >> * gcc.dg/tree-ssa/foldconst-3.c: Likewise. > >> * gcc.dg/tree-ssa/vrp15.c: Likewise. > >> > > > > None of these have any volatile bitfields, so the option should be a no-op.
That's what I thought, too. :-) > The problem is that we have to treat normal bitfields differently as > well, since a variable may later be declared as volatile. Here is my current test case, reduced from gcc.dg/tree-ssa/20030922-1.c: extern void abort (void); enum tree_code { BIND_EXPR, }; struct tree_common { enum tree_code code:8; }; void voidify_wrapper_expr (struct tree_common *common) { switch (common->code) { case BIND_EXPR: if (common->code != BIND_EXPR) abort (); } } The diff for -fdump-tree-all between compiling with -fno-strict-volatile-bitfields and -fstrict-volatile-bitfields begins with the following, right in 20030922-1.c.003t.original: diff -ru fnsvb/20030922-1.c.003t.original fsvb/20030922-1.c.003t.original --- fnsvb/20030922-1.c.003t.original 2012-04-19 16:51:18.322150866 +0200 +++ fsvb/20030922-1.c.003t.original 2012-04-19 16:49:18.132088498 +0200 @@ -7,7 +7,7 @@ switch ((int) common->code) { case 0:; - if (common->code != 0) + if ((BIT_FIELD_REF <*common, 32, 0> & 255) != 0) { abort (); } That is, for -fno-strict-volatile-bitfields the second instance of »common->code« it is a component_ref, whereas for -fstrict-volatile-bitfields it is a bit_field_ref. The former will be optimized as intended, the latter will not. So, what should be emitted in the -fstrict-volatile-bitfields case? A component_ref -- but this is what Bernd's commit r182545 (for PR51200) changed, I think? Or should later optimization stages learn to better deal with a bit_field_ref, and where would this have to happen? Grüße, Thomas
pgp95HjdOdpvt.pgp
Description: PGP signature