public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/111926] New: RISC-V: Use vsetvl insn replace csrr vlenb insn
@ 2023-10-23 3:36 lehua.ding at rivai dot ai
2023-10-23 4:24 ` [Bug target/111926] " kito at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: lehua.ding at rivai dot ai @ 2023-10-23 3:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111926
Bug ID: 111926
Summary: RISC-V: Use vsetvl insn replace csrr vlenb insn
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: lehua.ding at rivai dot ai
Target Milestone: ---
We can use:
vsetvl a5, zero, e8, mf8, ta, ta
replace:
csrr a4,vlenb
srli a4,a4,3
The reason for this is that the performance of the vsetvl instruction tends to
be better optimised than the csrr instruction.
#include <riscv_vector.h>
#define exhaust_vector_regs()
\
asm volatile("#" ::
\
: "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9",
\
"v10", "v11", "v12", "v13", "v14", "v15", "v16", "v17",
\
"v18", "v19", "v20", "v21", "v22", "v23", "v24", "v25",
\
"v26", "v27", "v28", "v29", "v30", "v31");
void
spill_1 (int8_t *in, int8_t *out)
{
vint8mf8_t v1 = *(vint8mf8_t*)in;
exhaust_vector_regs ();
*(vint8mf8_t*)out = v1;
}
spill_1(signed char*, signed char*):
csrr a4,vlenb
srli a4,a4,3
csrr t0,vlenb
slli a3,a4,3
sub sp,sp,t0
sub a3,a3,a4
add a3,a3,sp
vsetvli a5,zero,e8,mf8,ta,ma
vle8.v v1,0(a0)
vse8.v v1,0(a3)
csrr a4,vlenb
srli a4,a4,3
slli a3,a4,3
sub a3,a3,a4
add a3,a3,sp
vle8.v v1,0(a3)
csrr t0,vlenb
vse8.v v1,0(a1)
add sp,sp,t0
jr ra
https://godbolt.org/z/TcKxbjnoh
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/111926] RISC-V: Use vsetvl insn replace csrr vlenb insn
2023-10-23 3:36 [Bug target/111926] New: RISC-V: Use vsetvl insn replace csrr vlenb insn lehua.ding at rivai dot ai
@ 2023-10-23 4:24 ` kito at gcc dot gnu.org
2023-10-23 4:25 ` kito at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: kito at gcc dot gnu.org @ 2023-10-23 4:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111926
Kito Cheng <kito at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kito at gcc dot gnu.org
--- Comment #1 from Kito Cheng <kito at gcc dot gnu.org> ---
Plz leave an option to let user has choice, performance things is hard to saw
which is absolutely better for all uarch, my thought is leaving an option and
let mtune and a command line option to control that.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/111926] RISC-V: Use vsetvl insn replace csrr vlenb insn
2023-10-23 3:36 [Bug target/111926] New: RISC-V: Use vsetvl insn replace csrr vlenb insn lehua.ding at rivai dot ai
2023-10-23 4:24 ` [Bug target/111926] " kito at gcc dot gnu.org
@ 2023-10-23 4:25 ` kito at gcc dot gnu.org
2023-10-24 3:00 ` lehua.ding at rivai dot ai
2023-11-13 0:11 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: kito at gcc dot gnu.org @ 2023-10-23 4:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111926
--- Comment #2 from Kito Cheng <kito at gcc dot gnu.org> ---
Forgot to mention, personally I love idea to simplify code gen, I could imagine
that's definitely an optimization for specific uarch :)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/111926] RISC-V: Use vsetvl insn replace csrr vlenb insn
2023-10-23 3:36 [Bug target/111926] New: RISC-V: Use vsetvl insn replace csrr vlenb insn lehua.ding at rivai dot ai
2023-10-23 4:24 ` [Bug target/111926] " kito at gcc dot gnu.org
2023-10-23 4:25 ` kito at gcc dot gnu.org
@ 2023-10-24 3:00 ` lehua.ding at rivai dot ai
2023-11-13 0:11 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: lehua.ding at rivai dot ai @ 2023-10-24 3:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111926
--- Comment #3 from Lehua Ding <lehua.ding at rivai dot ai> ---
(In reply to Kito Cheng from comment #1)
> Plz leave an option to let user has choice, performance things is hard to
> saw which is absolutely better for all uarch, my thought is leaving an
> option and let mtune and a command line option to control that.
Understood, I'll put the possible optimisation points I came across here. How
to do it is like you said still under consideration.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/111926] RISC-V: Use vsetvl insn replace csrr vlenb insn
2023-10-23 3:36 [Bug target/111926] New: RISC-V: Use vsetvl insn replace csrr vlenb insn lehua.ding at rivai dot ai
` (2 preceding siblings ...)
2023-10-24 3:00 ` lehua.ding at rivai dot ai
@ 2023-11-13 0:11 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-13 0:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111926
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-11-13 0:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-23 3:36 [Bug target/111926] New: RISC-V: Use vsetvl insn replace csrr vlenb insn lehua.ding at rivai dot ai
2023-10-23 4:24 ` [Bug target/111926] " kito at gcc dot gnu.org
2023-10-23 4:25 ` kito at gcc dot gnu.org
2023-10-24 3:00 ` lehua.ding at rivai dot ai
2023-11-13 0:11 ` pinskia 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).