public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/101366] New: x86 memset codegen for constant sized is suboptimal
@ 2021-07-07 14:21 kutdanila at yandex dot ru
2021-07-07 20:13 ` [Bug target/101366] memset codegen for constant sized does not use SSE instructions pinskia at gcc dot gnu.org
2021-07-08 13:03 ` hjl.tools at gmail dot com
0 siblings, 2 replies; 3+ messages in thread
From: kutdanila at yandex dot ru @ 2021-07-07 14:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101366
Bug ID: 101366
Summary: x86 memset codegen for constant sized is suboptimal
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: kutdanila at yandex dot ru
Target Milestone: ---
https://gcc.godbolt.org/z/hP99MYMEG
void Test(char* dst) {
__m128i pattern = _mm_set1_epi8(dst[-1]);
for (int i = 0; i < 4; i++) {
_mm_loadu_si128(reinterpret_cast<__m128i*>(dst + 16 * i), pattern);
}
}
vs
void TestStd(char* s) {
memset(s, s[-1], 64);
}
-O3 -msse4.2
Test(char*):
movzbl -1(%rdi), %eax
pxor %xmm1, %xmm1
movd %eax, %xmm0
pshufb %xmm1, %xmm0
movups %xmm0, (%rdi)
movups %xmm0, 16(%rdi)
movups %xmm0, 32(%rdi)
movups %xmm0, 48(%rdi)
ret
TestStd(char*):
movabsq $72340172838076673, %rdx
movzbl -1(%rdi), %eax
movq %rax, %rcx
imulq %rdx, %rcx
mulq %rdx
addq %rcx, %rdx
movq %rax, (%rdi)
movq %rdx, 8(%rdi)
movq %rax, 16(%rdi)
movq %rdx, 24(%rdi)
movq %rax, 32(%rdi)
movq %rdx, 40(%rdi)
movq %rax, 48(%rdi)
movq %rdx, 56(%rdi)
ret
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug target/101366] memset codegen for constant sized does not use SSE instructions
2021-07-07 14:21 [Bug rtl-optimization/101366] New: x86 memset codegen for constant sized is suboptimal kutdanila at yandex dot ru
@ 2021-07-07 20:13 ` pinskia at gcc dot gnu.org
2021-07-08 13:03 ` hjl.tools at gmail dot com
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-07 20:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101366
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |missed-optimization
Target| |x86_64-linux-gnu
Last reconfirmed| |2021-07-07
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Summary|x86 memset codegen for |memset codegen for constant
|constant sized is |sized does not use SSE
|suboptimal |instructions
Severity|normal |enhancement
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
AARCH64 is fine:
TestStd(char*):
ldr b0, [x0, -1]
dup v0.16b, v0.b[0]
stp q0, q0, [x0]
stp q0, q0, [x0, 32]
ret
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug target/101366] memset codegen for constant sized does not use SSE instructions
2021-07-07 14:21 [Bug rtl-optimization/101366] New: x86 memset codegen for constant sized is suboptimal kutdanila at yandex dot ru
2021-07-07 20:13 ` [Bug target/101366] memset codegen for constant sized does not use SSE instructions pinskia at gcc dot gnu.org
@ 2021-07-08 13:03 ` hjl.tools at gmail dot com
1 sibling, 0 replies; 3+ messages in thread
From: hjl.tools at gmail dot com @ 2021-07-08 13:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101366
H.J. Lu <hjl.tools at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hjl.tools at gmail dot com
--- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> ---
Should be fixed by
https://gcc.gnu.org/pipermail/gcc-patches/2021-July/574249.html
which generates:
movsbl -1(%rdi), %eax
pxor %xmm0, %xmm0
movd %eax, %xmm15
pshufb %xmm0, %xmm15
movups %xmm15, (%rdi)
movups %xmm15, 16(%rdi)
movups %xmm15, 32(%rdi)
movups %xmm15, 48(%rdi)
ret
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-07-08 13:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-07 14:21 [Bug rtl-optimization/101366] New: x86 memset codegen for constant sized is suboptimal kutdanila at yandex dot ru
2021-07-07 20:13 ` [Bug target/101366] memset codegen for constant sized does not use SSE instructions pinskia at gcc dot gnu.org
2021-07-08 13:03 ` hjl.tools at gmail dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).