https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78037
--- Comment #6 from Uroš Bizjak <ubizjak at gmail dot com> --- (In reply to Jakub Jelinek from comment #5) > 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. A new UNSPEC insn pattern should be added and expanded from __tzcnt_u{16,32,64} builtin.