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

joern at purestorage dot com gcc-bugzilla@gcc.gnu.org
Tue Mar 12 18:16:00 GMT 2019


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

--- Comment #15 from Jörn Engel <joern at purestorage dot com> ---
> int foo (int x) { return __builtin_ctz (x); }
> 
> Without -mbmi, gcc emits:
>         xorl    %eax, %eax
>         rep bsfl        %edi, %eax
>         ret

That example convinces me.  Code would be broken with a zero-argument,
but if the compiler cannot decide whether that is possible and the
programmer can, it makes sense to generate less/faster code.

Thank you!


More information about the Gcc-bugs mailing list