[Bug c/89670] __builtin_ctz(_mm256_movemask_epi8(foo)) assumed to be <31 ?

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Mar 11 21:13:00 GMT 2019


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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |jakub at gcc dot gnu.org
         Resolution|---                         |INVALID

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
__builtin_ctz (0) is undefined behavior, anytime you invoke UB, all bets are
off.
The compiler optimizes based on the assumption that UB does not happen.
So, as all valid __builtin_ctz calls return values from 0 to 31, the compiler
does optimize away __builtin_ctz (x) == 32 into 0.


More information about the Gcc-bugs mailing list