[llvm-bugs] [Bug 35127] New: Missed opportunity for store narrowing

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Oct 29 20:12:37 PDT 2017


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

            Bug ID: 35127
           Summary: Missed opportunity for store narrowing
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: listmail at philipreames.com
                CC: llvm-bugs at lists.llvm.org

The following test cases store a vector with only one element defined.  We
should be able to use narrower stores to only update the defined bytes and
leave the other bytes undefined.  

define void @store_anyext_i32(<2 x i32>* %p, i32 %v) {
  %vec = insertelement <2 x i32> undef, i32 %v, i32 0
  store <2 x i32> %vec, <2 x i32>* %p
  ret void
}

define void @store_anyext_i16(<4 x i16>* %p, i16 %v) {
  %vec = insertelement <4 x i16> undef, i16 %v, i32 0
  store <4 x i16> %vec, <4 x i16>* %p
  ret void
}

define void @store_anyext_i8(<8 x i8>* %p, i8 %v) {
  %vec = insertelement <8 x i8> undef, i8 %v, i32 0
  store <8 x i8> %vec, <8 x i8>* %p
  ret void
}

Today, these produce:
        .text
        .file   "<stdin>"
        .globl  store_anyext_i32        # -- Begin function store_anyext_i32
        .p2align        4, 0x90
        .type   store_anyext_i32, at function
store_anyext_i32:                       # @store_anyext_i32
        .cfi_startproc
# BB#0:
        movd    %esi, %xmm0
        movq    %xmm0, (%rdi)
        retq
.Lfunc_end0:
        .size   store_anyext_i32, .Lfunc_end0-store_anyext_i32
        .cfi_endproc
                                        # -- End function
        .globl  store_anyext_i16        # -- Begin function store_anyext_i16
        .p2align        4, 0x90
        .type   store_anyext_i16, at function
store_anyext_i16:                       # @store_anyext_i16
        .cfi_startproc
# BB#0:
        movd    %esi, %xmm0
        pxor    %xmm1, %xmm1
        punpcklwd       %xmm1, %xmm0    # xmm0 =
xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3]
        punpckldq       %xmm1, %xmm0    # xmm0 =
xmm0[0],xmm1[0],xmm0[1],xmm1[1]
        movq    %xmm0, (%rdi)
        retq
.Lfunc_end1:
        .size   store_anyext_i16, .Lfunc_end1-store_anyext_i16
        .cfi_endproc
                                        # -- End function
        .globl  store_anyext_i8         # -- Begin function store_anyext_i8
        .p2align        4, 0x90
        .type   store_anyext_i8, at function
store_anyext_i8:                        # @store_anyext_i8
        .cfi_startproc
# BB#0:
        movd    %esi, %xmm0
        movq    %xmm0, (%rdi)
        retq
.Lfunc_end2:
        .size   store_anyext_i8, .Lfunc_end2-store_anyext_i8
        .cfi_endproc
                                        # -- End function

        .section        ".note.GNU-stack","", at progbits

I came up with these while trying to write test cases for an issue around
store(anyext) noticed in an unrelated patch, but looking through the isel debug
output, this looks to be something else.  (Possibly a problem with build_vector
canonicalization?)

-- 
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/20171030/942f0314/attachment.html>


More information about the llvm-bugs mailing list