[LLVMbugs] [Bug 2164] New: Codegen doesn't optimize 16-bit divide into multiply

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Wed Mar 19 14:19:15 PDT 2008


           Summary: Codegen doesn't optimize 16-bit divide into multiply
           Product: new-bugs
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: sharparrow1 at yahoo.com
                CC: llvmbugs at cs.uiuc.edu

Created an attachment (id=1549)
 --> (http://llvm.org/bugs/attachment.cgi?id=1549)
Patch to apintify magicu

Simple testcase:
unsigned t(unsigned short x) {return x/255;}

llvm-gcc currently produces:
        movw    $255, %cx
        xorw    %dx, %dx
        movw    4(%esp), %ax
        divw    %cx
        movzwl  %ax, %eax

vs. gcc:

        movzwl  4(%esp), %eax
        imull   $32897, %eax, %eax
        shrl    $23, %eax

Attached is a patch that improves this case to the following:
        movw    $32897, %ax
        mulw    4(%esp)
        shrw    $7, %dx
        movzwl  %dx, %eax

This isn't perfect, but the rest probably belongs in lib/Target/README.txt.
(I'm not really how to deal with this.)

I haven't converted the signed division case yet.

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