https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78037
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org, | |uros at gcc dot gnu.org --- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> --- That is because _tzcnt_u64 is expanded as __builtin_ctzll, which is explicitly UB with zero argument. So, either we need to expand it like x ? __builtin_ctzll (x) : 64 and make sure at RTL level we optimize this into just tzcnt instruction if available (though, that is questionable, because if you run tzcntq instruction on non-BMI CPUs, it will just be BSF with undefined result for 0), or add a new builtin, or unconditionally expand to the conditional.