[llvm-bugs] [Bug 34620] New: redundant pand after vector shift of a byte vector (psrlw)

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Sep 15 02:11:58 PDT 2017


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

            Bug ID: 34620
           Summary: redundant pand after vector shift of a byte vector
                    (psrlw)
           Product: libraries
           Version: 4.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: llvm at henning-thielemann.de
                CC: llvm-bugs at lists.llvm.org

I have a vector of bytes and want to increment the vector elements according to
certain bits of another vector like so:

define <16 x i8> @add_bitset_to_vector(<16 x i8>, <16 x i8>) {
_L1:
  %v0 = lshr <16 x i8> %0, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8
1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
  %v1 = and <16 x i8> %v0, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8
1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
  %v2 = add <16 x i8> %v1, %1
  ret <16 x i8> %v2
}


On X86-64 llc emits:

        .section        .rodata.cst16,"aM", at progbits,16
        .p2align        4
.LCPI2_0:
        .zero   16,127
.LCPI2_1:
        .zero   16,1
        .text
        .globl  add_bitset_to_vector
        .p2align        4, 0x90
        .type   add_bitset_to_vector, at function
add_bitset_to_vector:                   # @add_bitset_to_vector
# BB#0:                                 # %_L1
        psrlw   $1, %xmm0
        pand    .LCPI2_0(%rip), %xmm0
        pand    .LCPI2_1(%rip), %xmm0
        paddb   %xmm1, %xmm0
        retq
.Lfunc_end2:
        .size   add_bitset_to_vector, .Lfunc_end2-add_bitset_to_vector


That is, the X86 backend uses word vector shift (psrlw) plus pand in order to
perform the byte vector shift. However, my pand for masking the least
significant bits makes the pand generated by lshr redundant.

-- 
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/20170915/c03d59f6/attachment.html>


More information about the llvm-bugs mailing list