This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/71016] [6/7 Regression] Redundant sign extension with conditional __builtin_clzl
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 02 Jan 2017 17:34:56 +0000
- Subject: [Bug tree-optimization/71016] [6/7 Regression] Redundant sign extension with conditional __builtin_clzl
- Auto-submitted: auto-generated
- References: <bug-71016-4@http.gcc.gnu.org/bugzilla/>
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