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: [email protected]
Reporter: [email protected]
CC: [email protected]
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs