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

--- Comment #6 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
As for Valgrind false positive, it handles this SSSE3 code really well and
misses the key point by a very narrow margin. We have

  found = m1 + (m2 << 16);

where both m1 and m2 hold 16-bit masks from pmovmskb, so 'found' is just the
32-bit concatenation of those masks.

Suppose m1 has uninit bits. In that case, its highest known bit is guaranteed
to be non-zero (because our character stream always ends with a newline), in
'm2 << 16' the lower 16 bits are known, and therefore 'found' has a known
non-zero bit, making the branch on found != 0 well-defined.

If we instead combine the halves with an OR instead of PLUS:

  found = m1 | (m2 << 16);

Valgrind properly computes known bits in 'found' and does not complain.

I can see the difficulty in computing known bits after addition in the general
case though.

Reply via email to