This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/54115] New: Unnecessary sign extensions for __builtin_ctz et al.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]