https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67731
--- Comment #5 from rguenther at suse dot de <rguenther at suse dot de> --- On Fri, 9 Jun 2017, tetra2005 at gmail dot com wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67731 > > Yuri Gribov <tetra2005 at gmail dot com> changed: > > What |Removed |Added > ---------------------------------------------------------------------------- > CC| |tetra2005 at gmail dot com > > --- Comment #4 from Yuri Gribov <tetra2005 at gmail dot com> --- > (In reply to rguent...@suse.de from comment #3) > > The various patches to > > lower bitfield accesses made this work automagically. Thus this > > PR is probably a dup of some other(s). > > Interestingly, a slightly different code works fine: > return s->b || s->c; // || instead of | > This happens because it compiles to > (s->b != 0) || (s->c != 0) > Each component is converted to BIT_FIELD_REF by optimize_bit_field_compare and > results are folded to a single BIT_AND. > > With original use-case this does not work because we don't know that result > will be NE-ed when trying to fold IOR in fold_binary_loc. > > Ideally we want to detect generic patterns like > (s->f1 | s->f2 | ... | s->fN | other unrelated conds) != 0 // Or &, or == > sort fi's to groups according to their memory location and optimize from > there. > This should probly go to reassoc? Or better keep it in folder? As loads are involved it doesn't really fit reassoc. Likewise it doesn't really fit the folder. It kind-of matches if-combine but given that loads are involved it's difficult as well. Maybe the bswap pass (which is combining loads) can be enhanced here. Richard.