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 [email protected] 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?