public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/109465] New: LoongArch: The expansion of memcpy is slow and bloated for some sizes
@ 2023-04-10 15:05 xry111 at gcc dot gnu.org
2023-04-10 15:07 ` [Bug target/109465] " xry111 at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-04-10 15:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109465
Bug ID: 109465
Summary: LoongArch: The expansion of memcpy is slow and bloated
for some sizes
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: xry111 at gcc dot gnu.org
Target Milestone: ---
extern char *a, *b;
void test() { __builtin_memcpy(a, b, 15); }
With -mno-strict-align, this is compiled to 15 ld.bu/st.b pairs instead of the
optimal (4 pairs).
All size values >= 19 (except 24) seem affected.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/109465] LoongArch: The expansion of memcpy is slow and bloated for some sizes
2023-04-10 15:05 [Bug target/109465] New: LoongArch: The expansion of memcpy is slow and bloated for some sizes xry111 at gcc dot gnu.org
@ 2023-04-10 15:07 ` xry111 at gcc dot gnu.org
2023-04-19 10:17 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-04-10 15:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109465
Xi Ruoyao <xry111 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2023-04-10
CC| |chenglulu at loongson dot cn
Target| |loongarch64-linux-gnu
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
--- Comment #1 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
Not a regression nor "serious" issue, the fix can be deferred into GCC 14 stage
1.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/109465] LoongArch: The expansion of memcpy is slow and bloated for some sizes
2023-04-10 15:05 [Bug target/109465] New: LoongArch: The expansion of memcpy is slow and bloated for some sizes xry111 at gcc dot gnu.org
2023-04-10 15:07 ` [Bug target/109465] " xry111 at gcc dot gnu.org
@ 2023-04-19 10:17 ` cvs-commit at gcc dot gnu.org
2023-04-19 10:22 ` xry111 at gcc dot gnu.org
2023-08-04 15:51 ` xry111 at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-19 10:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109465
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Xi Ruoyao <xry111@gcc.gnu.org>:
https://gcc.gnu.org/g:6d7e0bcfa49e4ddc84dabe520bba8a023bc52692
commit r14-70-g6d7e0bcfa49e4ddc84dabe520bba8a023bc52692
Author: Xi Ruoyao <xry111@xry111.site>
Date: Wed Apr 12 11:45:48 2023 +0000
LoongArch: Improve cpymemsi expansion [PR109465]
We'd been generating really bad block move sequences which is recently
complained by kernel developers who tried __builtin_memcpy. To improve
it:
1. Take the advantage of -mno-strict-align. When it is set, set mode
size to UNITS_PER_WORD regardless of the alignment.
2. Half the mode size when (block size) % (mode size) != 0, instead of
falling back to ld.bu/st.b at once.
3. Limit the length of block move sequence considering the number of
instructions, not the size of block. When -mstrict-align is set and
the block is not aligned, the old size limit for straight-line
implementation (64 bytes) was definitely too large (we don't have 64
registers anyway).
Change since v1: add a comment about the calculation of num_reg.
gcc/ChangeLog:
PR target/109465
* config/loongarch/loongarch-protos.h
(loongarch_expand_block_move): Add a parameter as alignment RTX.
* config/loongarch/loongarch.h:
(LARCH_MAX_MOVE_BYTES_PER_LOOP_ITER): Remove.
(LARCH_MAX_MOVE_BYTES_STRAIGHT): Remove.
(LARCH_MAX_MOVE_OPS_PER_LOOP_ITER): Define.
(LARCH_MAX_MOVE_OPS_STRAIGHT): Define.
(MOVE_RATIO): Use LARCH_MAX_MOVE_OPS_PER_LOOP_ITER instead of
LARCH_MAX_MOVE_BYTES_PER_LOOP_ITER.
* config/loongarch/loongarch.cc (loongarch_expand_block_move):
Take the alignment from the parameter, but set it to
UNITS_PER_WORD if !TARGET_STRICT_ALIGN. Limit the length of
straight-line implementation with LARCH_MAX_MOVE_OPS_STRAIGHT
instead of LARCH_MAX_MOVE_BYTES_STRAIGHT.
(loongarch_block_move_straight): When there are left-over bytes,
half the mode size instead of falling back to byte mode at once.
(loongarch_block_move_loop): Limit the length of loop body with
LARCH_MAX_MOVE_OPS_PER_LOOP_ITER instead of
LARCH_MAX_MOVE_BYTES_PER_LOOP_ITER.
* config/loongarch/loongarch.md (cpymemsi): Pass the alignment
to loongarch_expand_block_move.
gcc/testsuite/ChangeLog:
PR target/109465
* gcc.target/loongarch/pr109465-1.c: New test.
* gcc.target/loongarch/pr109465-2.c: New test.
* gcc.target/loongarch/pr109465-3.c: New test.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/109465] LoongArch: The expansion of memcpy is slow and bloated for some sizes
2023-04-10 15:05 [Bug target/109465] New: LoongArch: The expansion of memcpy is slow and bloated for some sizes xry111 at gcc dot gnu.org
2023-04-10 15:07 ` [Bug target/109465] " xry111 at gcc dot gnu.org
2023-04-19 10:17 ` cvs-commit at gcc dot gnu.org
@ 2023-04-19 10:22 ` xry111 at gcc dot gnu.org
2023-08-04 15:51 ` xry111 at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-04-19 10:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109465
Xi Ruoyao <xry111 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #3 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
Fixed for GCC 14. Not suitable for backporting.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/109465] LoongArch: The expansion of memcpy is slow and bloated for some sizes
2023-04-10 15:05 [Bug target/109465] New: LoongArch: The expansion of memcpy is slow and bloated for some sizes xry111 at gcc dot gnu.org
` (2 preceding siblings ...)
2023-04-19 10:22 ` xry111 at gcc dot gnu.org
@ 2023-08-04 15:51 ` xry111 at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-08-04 15:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109465
Xi Ruoyao <xry111 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |14.0
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-08-04 15:51 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-10 15:05 [Bug target/109465] New: LoongArch: The expansion of memcpy is slow and bloated for some sizes xry111 at gcc dot gnu.org
2023-04-10 15:07 ` [Bug target/109465] " xry111 at gcc dot gnu.org
2023-04-19 10:17 ` cvs-commit at gcc dot gnu.org
2023-04-19 10:22 ` xry111 at gcc dot gnu.org
2023-08-04 15:51 ` xry111 at gcc dot gnu.org
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).