https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101175
--- Comment #4 from Mikael Pettersson <mikpelinux at gmail dot com> --- (In reply to Uroš Bizjak from comment #3) > (In reply to Mikael Pettersson from comment #2) > > (In reply to Iru Cai from comment #0) > > > Built with '-march=x86-64-v3 -O1', the following code generates a bsr > > > instruction, which has undefined behavior when the source operand is zero, > > > thus gives wrong result > > > > The documentation for __builtin_clz(x) states "If x is 0, the result is > > undefined". > > The testcase from Comment #0 does: > > if (value != 0) { > return __builtin_clz(value); Yes I just noticed. My mistake.