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

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Actually, on x86_64-linux without -mbmi{,2} -mlzcnt the CLZ and CTZ is actually
undefined at zero, so there is nothing to do with that I'm afraid.  With those
additional options foo is optimized:
-       xorl    %edx, %edx
-       movl    $17, %eax
-       lzcntq  %rdi, %rdx
+       xorl    %eax, %eax
+       movl    $17, %edx
+       lzcntq  %rdi, %rax
        testq   %rdi, %rdi
-       cmovne  %edx, %eax
-       cltq
+       cmove   %rdx, %rax
with the patch and similarly baz:
-       xorl    %edx, %edx
-       movl    $17, %eax
-       tzcntq  %rdi, %rdx
-       addq    $1, %rdx
+       xorl    %eax, %eax
+       movl    $17, %edx
+       tzcntq  %rdi, %rax
+       addq    $1, %rax
        testq   %rdi, %rdi
-       cmovne  %edx, %eax
-       cltq
+       cmove   %rdx, %rax

Reply via email to