[Bug c/124838] __builtin_clzl(0) overoptimization even on targets with native lzcnt instruction
zoltan at hidvegi dot com
gcc-bugzilla@gcc.gnu.org
Fri Apr 10 07:33:52 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124838
--- Comment #7 from Zoltan Hidvegi <zoltan at hidvegi dot com> ---
clang generates a single lzcnt for both. And it seems that clearing EAX before
lzcnt is unnecessary, I thought that unlike bsr, lzcnt does not have the false
dependency on the old value of EAX. clang skips clearing eax. The testcase in
#0 returns a different value at 0, so the cmov cannot be optimized.
More information about the Gcc-bugs
mailing list