https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120724

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2025-06-20
          Component|target                      |tree-optimization
                 CC|                            |rguenth at gcc dot gnu.org
           Keywords|                            |missed-optimization
             Status|UNCONFIRMED                 |NEW
             Target|X86_64                      |x86_64-*-*
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
bool isvalid3(uint64_t state) {
    return ((state & state<<1) & 0x8888888888888888ull) == 0;
}

is what the reporter expects this to reduce to.  While this might be
viewed as a reduction and thus fit to be handled in SCCP pattern detection
we have the issue is that the "reduction" result is control computed.

For better vectorizing this we'd have to think of 'state' in state & 0xf as
input and >>= 4 / & 0xf as indexing.  Then in principle we could "unpack"
the nibbles to bytes and have a vector compare against 11 so there's the
chance that this could be more generally useful for vectorizing a loop
working on some bits of a scalar at a time.

I do not see a very good place to handle the whole thing as pattern.  The
loop is dead apart from the PHI <0, 1> that's dependent on the two exits,
so it still would be SCCP of some sorts.

Reply via email to