https://bugs.llvm.org/show_bug.cgi?id=43217
Bug ID: 43217
Summary: [X86][SSE] Access a scalar float/double as a free
extract from a broadcast load
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: X86
Assignee: unassignedb...@nondot.org
Reporter: llvm-...@redking.me.uk
CC: andrea.dibia...@gmail.com, craig.top...@gmail.com,
llvm-bugs@lists.llvm.org, llvm-...@redking.me.uk,
spatel+l...@rotateright.com
Current Codegen: https://godbolt.org/z/nm4NKg
#include <x86intrin.h>
__m256 broadcast_scl(float *src, float *dst) {
float f = *src;
*dst = f;
return _mm256_set1_ps(f);
}
__m256 broadcast_vec(float *src, float *dst) {
__m256 v = _mm256_set1_ps(*src);
*dst = _mm256_cvtss_f32(v);
return v;
}
Both these result in a scalar load, scalar store and a broadcast (on AVX1 split
across 2 instruction):
vmovss (%rdi), %xmm1 # xmm1 = mem[0],zero,zero,zero
vpermilps $0, %xmm1, %xmm0 # xmm0 = xmm1[0,0,0,0]
vmovss %xmm1, (%rsi)
vinsertf128 $1, %xmm0, %ymm0, %ymm0
retq
But we could do this more efficiently as:
vbroadcastss (%rdi), %ymm0
vmovss %xmm0, (%rsi)
retq
We could probably achieve this in DAG by just replacing other uses of the
loaded scalar as a (free) extract of the broadcast.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs