[LLVMbugs] [Bug 20054] New: constant vector value splatted at runtime with broadcast instruction instead of loaded (only core-avx2 target?)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jun 16 11:17:03 PDT 2014


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

            Bug ID: 20054
           Summary: constant vector value splatted at runtime with
                    broadcast instruction instead of loaded (only
                    core-avx2 target?)
           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

$ ./clang -v
clang version 3.5.0 (210980)
Target: x86_64-apple-darwin13.2.0
Thread model: posix

$ cat splat.c 
#include <xmmintrin.h>

__m128 splat(__m128 x) {
    return _mm_add_ps(x, _mm_set1_ps(1.0f));
}

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

That "1.0f" constant vector is being loaded as a scalar value and then splatted
across the xmm register for the core-avx2 target:


$ ./clang -O1 -fomit-frame-pointer splat.c -march=core-avx2 -S -o -
    .section    __TEXT,__text,regular,pure_instructions
    .macosx_version_min 10, 9
    .section    __TEXT,__literal4,4byte_literals
    .align    2
LCPI0_0:
    .long    1065353216              ## float 1
    .section    __TEXT,__text,regular,pure_instructions
    .globl    _splat
    .align    4, 0x90
_splat:                                 ## @splat
    .cfi_startproc
## BB#0:                                ## %entry
    vbroadcastss    LCPI0_0(%rip), %xmm1
    vaddps    %xmm1, %xmm0, %xmm0
    retq
    .cfi_endproc


.subsections_via_symbols

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

But with any (?) other x86 targets, we make the size-speed tradeoff and just
load a full 128-bit vector:


$ ./clang -O1 -fomit-frame-pointer splat.c -march=corei7-avx -S -o -
    .section    __TEXT,__text,regular,pure_instructions
    .macosx_version_min 10, 9
    .section    __TEXT,__literal16,16byte_literals
    .align    4
LCPI0_0:
    .long    1065353216              ## float 1.000000e+00
    .long    1065353216              ## float 1.000000e+00
    .long    1065353216              ## float 1.000000e+00
    .long    1065353216              ## float 1.000000e+00
    .section    __TEXT,__text,regular,pure_instructions
    .globl    _splat
    .align    4, 0x90
_splat:                                 ## @splat
    .cfi_startproc
## BB#0:                                ## %entry
    vaddps    LCPI0_0(%rip), %xmm0, %xmm0
    retq
    .cfi_endproc

-- 
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/20140616/6a810e8c/attachment.html>


More information about the llvm-bugs mailing list