[LLVMbugs] [Bug 7525] New: bswap optimization broken in InstCombine

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Jun 29 14:44:06 PDT 2010


           Summary: bswap optimization broken in InstCombine
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: echristo at gmail.com
                CC: llvmbugs at cs.uiuc.edu

Filing this so I don't forget about it.

With this small testcase:

int f(int n)
  return (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >>

We should be getting a 32-bit bswap, but instead are getting the long sequence
of ands, ors, and shifts.

        movl    %esp, %ebp
        movl    8(%ebp), %eax
        movl    %eax, %ecx
        sarl    $24, %ecx
        movl    %eax, %edx
        shll    $24, %edx
        orl     %ecx, %edx
        movl    %eax, %ecx
        shrl    $8, %ecx
        andl    $65280, %ecx            ## imm = 0xFF00
        orl     %edx, %ecx
        shll    $8, %eax
        andl    $16711680, %eax         ## imm = 0xFF0000
        orl     %ecx, %eax

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