This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/54115] New: Unnecessary sign extensions for __builtin_ctz et al.
- From: "neleai at seznam dot cz" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 29 Jul 2012 08:08:13 +0000
- Subject: [Bug target/54115] New: Unnecessary sign extensions for __builtin_ctz et al.
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54115
Bug #: 54115
Summary: Unnecessary sign extensions for __builtin_ctz et al.
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: neleai@seznam.cz
Instructions bsf,bsr,bsfq... return integer in range 0..63.
When used in 64 bit computations an unnecessary sign extension is emitted as
following example shows:
#include <stdint.h>
uint64_t foo(long x){
return __builtin_ctzl(x);
}
Output:
.file "exa.c"
.text
.p2align 4,,15
.globl foo
.type foo, @function
foo:
.LFB0:
.cfi_startproc
bsfq %rdi, %rax
cltq
ret
.cfi_endproc
.LFE0:
.size foo, .-foo
.ident "GCC: (Debian 4.7.1-2) 4.7.1"
.section .note.GNU-stack,"",@progbits