[LLVMbugs] [Bug 23863] New: DAGCombiner missing byte swap idioms

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Jun 16 15:26:59 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=23863

            Bug ID: 23863
           Summary: DAGCombiner missing byte swap idioms
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: charlesturner7c5 at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

LLVM is missing an opportunity to reduce the following byte-swap routine into
(when available) target-specific byte swap routines:

uint32_t bswap(uint32_t x)
{
  x = (x & 0x0000FFFF) << 16 | (x & 0xFFFF0000) >> 16;
  x = (x & 0x00FF00FF) << 8 | (x & 0xFF00FF00) >> 8;
  return x;
}

Also noticed this one mentioned in lib/Target/README.txt that I'll add here,

unsigned long reverse(unsigned v) {
    unsigned t;
    t = v ^ ((v << 16) | (v >> 16));
    t &= ~0xff0000;
    v = (v << 24) | (v >> 8);
    return v ^ (t >> 8);
}

DAGCombiner should be taught about the first one at least, since GCC does
recognise that idiom. Whether LLVM should ever recognise the second one is left
to taste.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150616/355bdba9/attachment.html>


More information about the llvm-bugs mailing list