[LLVMbugs] [Bug 9809] New: optimizing integer power of 2

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Apr 28 14:33:02 PDT 2011


http://llvm.org/bugs/show_bug.cgi?id=9809

           Summary: optimizing integer power of 2
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: castet.matthieu at free.fr
                CC: llvmbugs at cs.uiuc.edu


For
int divu5(uint a, uint b)
{
        return a / ((1<<b) * 4);
}

gcc -S -Os -fomit-frame-pointer -mregparm=3 generate
divu5:
        leal    2(%edx), %ecx
        shrl    %cl, %eax
        ret

clang -S -Os -fomit-frame-pointer -mregparm=3 generate
divu5:                                  # @divu5
# BB#0:                                 # %entry
    pushl   %esi
    movb    %dl, %cl
    movl    $1, %esi
    shll    %cl, %esi
    shll    $2, %esi
    xorl    %edx, %edx
    divl    %esi, %eax
    popl    %esi
    ret

-- 
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