Message ID | 20100915132034.GA9347@virgil.arch.suse.de |
---|---|
State | New |
Headers | show |
On Wed, 15 Sep 2010, Martin Jambor wrote: > Hi, > > IPA-SRA was never meant to handle bit-fields (because of even more > unclear cost considerations) and so I did not bother to make the > call statement modification work with them and with the new MEM_REF > implementation it doesn't. However, the detection condition is > wrong and fails to catch some cases. Becase it is at a place where > BIT_FIELD_REFs do not get, I changed it to look at the field > declaration directly, just as we do in build_ref_for_model. > > This fixes 450.soplex (at least the test run, I'm running a reference > run now) and I have bootstrapped and tested it without any issues on > x86_64-linux. OK for trunk? Ok. Thanks, Richard. > Thanks, > > Martin > > > 2010-09-14 Martin Jambor <mjambor@suse.cz> > > PR middle-end/45644 > * tree-sra.c (create_access): Check for bit-fields directly. > > * testsuite/gcc.dg/ipa/pr45644.c: New test. > > Index: mine/gcc/tree-sra.c > =================================================================== > --- mine.orig/gcc/tree-sra.c > +++ mine/gcc/tree-sra.c > @@ -774,12 +774,13 @@ create_access (tree expr, gimple stmt, b > disqualify_candidate (base, "Encountered a variable sized access."); > return NULL; > } > - if ((offset % BITS_PER_UNIT) != 0 || (size % BITS_PER_UNIT) != 0) > + if (TREE_CODE (expr) == COMPONENT_REF > + && DECL_BIT_FIELD (TREE_OPERAND (expr, 1))) > { > - disqualify_candidate (base, > - "Encountered an acces not aligned to a byte."); > + disqualify_candidate (base, "Encountered a bit-field access."); > return NULL; > } > + gcc_checking_assert ((offset % BITS_PER_UNIT) == 0); > > if (ptr) > mark_parm_dereference (base, offset + size, stmt); > Index: mine/gcc/testsuite/gcc.dg/ipa/pr45644.c > =================================================================== > --- /dev/null > +++ mine/gcc/testsuite/gcc.dg/ipa/pr45644.c > @@ -0,0 +1,35 @@ > +/* Verify that we do not IPA-SRA bitfields. */ > +/* { dg-do run } */ > +/* { dg-options "-O2" } */ > + > +extern void abort (void); > + > +struct S > +{ > + int j : 8; > + int i : 24; > + int l; > +}; > + > +static int __attribute__((noinline)) foo (struct S *s) > +{ > + int z = s->i; > + if (z != 777) > + abort (); > + return 0; > +} > + > +int __attribute__((noinline)) bar (struct S *s) > +{ > + return foo (s); > +} > + > +int main (int argc, char *argv[]) > +{ > + struct S s; > + s.j = 5; > + s.i = 777; > + s.l = -1; > + > + return bar (&s); > +} > >
Index: mine/gcc/tree-sra.c =================================================================== --- mine.orig/gcc/tree-sra.c +++ mine/gcc/tree-sra.c @@ -774,12 +774,13 @@ create_access (tree expr, gimple stmt, b disqualify_candidate (base, "Encountered a variable sized access."); return NULL; } - if ((offset % BITS_PER_UNIT) != 0 || (size % BITS_PER_UNIT) != 0) + if (TREE_CODE (expr) == COMPONENT_REF + && DECL_BIT_FIELD (TREE_OPERAND (expr, 1))) { - disqualify_candidate (base, - "Encountered an acces not aligned to a byte."); + disqualify_candidate (base, "Encountered a bit-field access."); return NULL; } + gcc_checking_assert ((offset % BITS_PER_UNIT) == 0); if (ptr) mark_parm_dereference (base, offset + size, stmt); Index: mine/gcc/testsuite/gcc.dg/ipa/pr45644.c =================================================================== --- /dev/null +++ mine/gcc/testsuite/gcc.dg/ipa/pr45644.c @@ -0,0 +1,35 @@ +/* Verify that we do not IPA-SRA bitfields. */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); + +struct S +{ + int j : 8; + int i : 24; + int l; +}; + +static int __attribute__((noinline)) foo (struct S *s) +{ + int z = s->i; + if (z != 777) + abort (); + return 0; +} + +int __attribute__((noinline)) bar (struct S *s) +{ + return foo (s); +} + +int main (int argc, char *argv[]) +{ + struct S s; + s.j = 5; + s.i = 777; + s.l = -1; + + return bar (&s); +}