[LLVMbugs] [Bug 23022] New: [X86][AVX] suboptimal splat loads

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Mar 25 11:55:12 PDT 2015


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

            Bug ID: 23022
           Summary: [X86][AVX] suboptimal splat loads
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

$ cat splat_loads.ll 
define <2 x double> @splat_load_2f64(<2 x double>* %ptr) {
  %x = load <2 x double>, <2 x double>* %ptr
  %x1 = shufflevector <2 x double> %x, <2 x double> undef, <2 x i32> <i32 0,
i32 0> 
  ret <2 x double> %x1
}

define <4 x double> @splat_load_4f64(<4 x double>* %ptr) {
  %x = load <4 x double>, <4 x double>* %ptr
  %x1 = shufflevector <4 x double> %x, <4 x double> undef, <4 x i32> <i32 0,
i32 0, i32 0, i32 0> 
  ret <4 x double> %x1
}

define <4 x float> @splat_load_4f32(<4 x float>* %ptr) {
  %x = load <4 x float>, <4 x float>* %ptr
  %x1 = shufflevector <4 x float> %x, <4 x float> undef, <4 x i32> <i32 0, i32
0, i32 0, i32 0> 
  ret <4 x float> %x1
}

define <8 x float> @splat_load_8f32(<8 x float>* %ptr) {
  %x = load <8 x float>, <8 x float>* %ptr
  %x1 = shufflevector <8 x float> %x, <8 x float> undef, <8 x i32> <i32 0, i32
0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0> 
  ret <8 x float> %x1
}

-------------------------------------------------------------------------------

Testing with llc built from r233098:

$ ./llc -o - -mattr=avx splat_loads.ll 
_splat_load_2f64:                       ## @splat_load_2f64
    vmovddup    (%rdi), %xmm0   ## xmm0 = mem[0,0]
    retq
...    
_splat_load_4f64:                       ## @splat_load_4f64
    vmovapd    (%rdi), %ymm0
    vmovddup    %xmm0, %xmm0    ## xmm0 = xmm0[0,0]
    vinsertf128    $1, %xmm0, %ymm0, %ymm0
    retq
...
_splat_load_4f32:                       ## @splat_load_4f32
    vpermilps    $0, (%rdi), %xmm0 ## xmm0 = mem[0,0,0,0]
    retq    
...
_splat_load_8f32:                       ## @splat_load_8f32
    vmovaps    (%rdi), %ymm0
    vpermilps    $0, %xmm0, %xmm0 ## xmm0 = xmm0[0,0,0,0]
    vinsertf128    $1, %xmm0, %ymm0, %ymm0
    retq

-------------------------------------------------------------------------------

I don't remember whether the vmovddup in the 1st test is somehow better than a
vbroadcast, but I think all of these could be single vbroadcast load
instructions.

-- 
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/20150325/6cd41def/attachment.html>


More information about the llvm-bugs mailing list