On Tue, 10 May 2011, Michael Matz wrote: > Hi, > > On Tue, 10 May 2011, Richard Guenther wrote: > > > struct B { > > unsigned bit0 : 1; > > unsigned bit1 : 1; > > }; > > > > void > > foo (struct B *b) > > { > > b->bit0 = b->bit0 | b->bit1; > > } > > > > we with this patch generate > > > > D.2686_2 = b_1(D)->bit0; > > D.2688_4 = b_1(D)->bit1; > > D.2693_10 = D.2688_4 ^ D.2686_2; > > b_1(D)->bit0 = D.2693_10; > > I assume that this generates a XOR instead of an OR is a typo not a > feature of the patch ;-)
Yes ;) > > + struct B { > > + unsigned bit0 : 1; > > + unsigned bit1 : 1; > > + }; > > + > > + void > > + foo (struct B *b) > > + { > > + b->bit0 = b->bit0 | b->bit1; > > + } > > + > > + /* { dg-final { scan-tree-dump-not "\\\(unsigned char\\\)" "optimized" } > > } */ > > Perhaps test for only '\\\(unsigned' ? Because I'm not sure if some > targets don't extend to "unsigned int", after all that's the base type of > the bitfields. It's what some of the premature FE optimization does, shortening the width of the operation. The C standard would have int (or unsigned int) conversions. So in reality no conversion at all should prevail, but I didn't want to try inventing a regexp for that ;) But yes, matching \\\(unsigned should be enough. Richard.