[Bug tree-optimization/67731] Combine of OR'ed bitfields should use bit-test
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67731 Andrew Pinski changed: What|Removed |Added Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org Status|NEW |ASSIGNED --- Comment #8 from Andrew Pinski --- Mine, this is bit-field lowering related. I am hoping to get the bit-field lowering into GCC 12.
[Bug tree-optimization/67731] Combine of OR'ed bitfields should use bit-test
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67731 --- Comment #7 from 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 > > --- Comment #6 from Yuri Gribov --- > (In reply to rguent...@suse.de from comment #5) > > On Fri, 9 Jun 2017, tetra2005 at gmail dot com wrote: > > > > > 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. > > The || case is optimized by the folder. Yes, but that's quite premature and doesn't work for if (..) else if (..)
[Bug tree-optimization/67731] Combine of OR'ed bitfields should use bit-test
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67731 --- Comment #6 from Yuri Gribov --- (In reply to rguent...@suse.de from comment #5) > On Fri, 9 Jun 2017, tetra2005 at gmail dot com wrote: > > > 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. The || case is optimized by the folder.
[Bug tree-optimization/67731] Combine of OR'ed bitfields should use bit-test
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67731 --- Comment #5 from 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 changed: > >What|Removed |Added > > CC||tetra2005 at gmail dot com > > --- Comment #4 from Yuri Gribov --- > (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.
[Bug tree-optimization/67731] Combine of OR'ed bitfields should use bit-test
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67731 Yuri Gribov changed: What|Removed |Added CC||tetra2005 at gmail dot com --- Comment #4 from Yuri Gribov --- (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?
[Bug tree-optimization/67731] Combine of OR'ed bitfields should use bit-test
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67731 Andrew Pinski changed: What|Removed |Added Keywords||missed-optimization Component|rtl-optimization|tree-optimization Severity|normal |enhancement