[llvm-bugs] [Bug 32815] New: [ppc] Slow code for 32-bit bit reversal

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Apr 26 12:39:51 PDT 2017


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

            Bug ID: 32815
           Summary: [ppc] Slow code for 32-bit bit reversal
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: PowerPC
          Assignee: unassignedbugs at nondot.org
          Reporter: echristo at gmail.com
                CC: llvm-bugs at lists.llvm.org

About half the speed of the equivalent gcc.

Simple testcase:

extern unsigned int bswap_64(unsigned int n);

unsigned int ReverseBits32(unsigned int n) {
  n = ((n >> 1) & 0x5555555555555555ULL) | ((n & 0x5555555555555555ULL) << 1);
  n = ((n >> 2) & 0x3333333333333333ULL) | ((n & 0x3333333333333333ULL) << 2);
  n = ((n >> 4) & 0x0F0F0F0F0F0F0F0FULL) | ((n & 0x0F0F0F0F0F0F0F0FULL) << 4);
  return bswap_64(n);
}

echristo at ghostwheel ~/tmp> ~/builds/build-llvm/bin/clang -target
powerpc64le-linux-gnu  foo.c -S -O2 -o -
        .text
        .abiversion 2
        .file   "foo.c"
        .globl  ReverseBits32
        .p2align        4
        .type   ReverseBits32, at function
ReverseBits32:                          # @ReverseBits32
.Lfunc_begin0:
.Lfunc_gep0:
        addis 2, 12, .TOC.-.Lfunc_gep0 at ha
        addi 2, 2, .TOC.-.Lfunc_gep0 at l
.Lfunc_lep0:
        .localentry     ReverseBits32, .Lfunc_lep0-.Lfunc_gep0
# BB#0:                                 # %entry
        mflr 0
        std 0, 16(1)
        stdu 1, -32(1)
        rlwinm 4, 3, 25, 0, 31
        rlwimi 4, 3, 27, 30, 30
        rlwimi 4, 3, 29, 29, 29
        rlwimi 4, 3, 31, 28, 28
        rlwimi 4, 3, 1, 27, 27
        rlwimi 4, 3, 3, 26, 26
        rlwimi 4, 3, 5, 25, 25
        rlwimi 4, 3, 7, 24, 24
        rlwimi 4, 3, 27, 22, 22
        rlwimi 4, 3, 29, 21, 21
        rlwimi 4, 3, 31, 20, 20
        rlwimi 4, 3, 1, 19, 19
        rlwimi 4, 3, 3, 18, 18
        rlwimi 4, 3, 5, 17, 17
        rlwimi 4, 3, 7, 16, 16
        rlwimi 4, 3, 27, 14, 14
        rlwimi 4, 3, 29, 13, 13
        rlwimi 4, 3, 31, 12, 12
        rlwimi 4, 3, 1, 11, 11
        rlwimi 4, 3, 3, 10, 10
        rlwimi 4, 3, 5, 9, 9
        rlwimi 4, 3, 7, 8, 8
        rlwimi 4, 3, 27, 6, 6
        rlwimi 4, 3, 29, 5, 5
        rlwimi 4, 3, 31, 4, 4
        rlwimi 4, 3, 1, 3, 3
        rlwimi 4, 3, 3, 2, 2
        rlwimi 4, 3, 5, 1, 1
        rlwimi 4, 3, 7, 0, 0
        mr 3, 4
        bl bswap_64
        nop
        addi 1, 1, 32
        ld 0, 16(1)
        mtlr 0
        blr
        .long   0
        .quad   0
.Lfunc_end0:
        .size   ReverseBits32, .Lfunc_end0-.Lfunc_begin0


        .ident  "clang version 5.0.0 (trunk 301364) (llvm/trunk 301363)"
        .section        ".note.GNU-stack","", at progbits

-- 
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/20170426/e79260a1/attachment.html>


More information about the llvm-bugs mailing list