[LLVMbugs] [Bug 10328] New: Inefficient code for 64 bit shift and compare

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Jul 10 19:42:28 PDT 2011


           Summary: Inefficient code for 64 bit shift and compare
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: rafael.espindola at gmail.com
                CC: llvmbugs at cs.uiuc.edu


int foo(unsigned long l) {
  return (l>> 47) == 1;

we produce

  %shr.mask = and i64 %l, -140737488355328
  %cmp = icmp eq i64 %shr.mask, 140737488355328
  %conv = zext i1 %cmp to i32
  ret i32 %conv

which codegens to

movq    $0xffff800000000000,%rax
andq    %rdi,%rax
movq    $0x0000800000000000,%rcx
cmpq    %rcx,%rax
sete    %al
movzbl    %al,%eax

gcc produces

shrq    $0x2f,%rdi
xorl    %eax,%eax
cmpq    $0x01,%rdi
sete    %al

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list