public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/112327] New: RVV: Redundant vmv1r for widen reduction
@ 2023-11-01 6:17 juzhe.zhong at rivai dot ai
2023-11-02 0:51 ` [Bug target/112327] " cvs-commit at gcc dot gnu.org
2023-11-02 0:52 ` juzhe.zhong at rivai dot ai
0 siblings, 2 replies; 3+ messages in thread
From: juzhe.zhong at rivai dot ai @ 2023-11-01 6:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112327
Bug ID: 112327
Summary: RVV: Redundant vmv1r for widen reduction
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: juzhe.zhong at rivai dot ai
Target Milestone: ---
#include "riscv_vector.h"
void rvv_dot_prod(int16_t *pSrcA, int16_t *pSrcB, uint32_t n, int64_t *result)
{
size_t vl;
vint16m4_t vSrcA, vSrcB;
vint64m1_t vSum = __riscv_vmv_s_x_i64m1(0, 1);
while (n > 0) {
vl = __riscv_vsetvl_e16m4(n);
vSrcA = __riscv_vle16_v_i16m4(pSrcA, vl);
vSrcB = __riscv_vle16_v_i16m4(pSrcB, vl);
vSum = __riscv_vwredsum_vs_i32m8_i64m1(__riscv_vwmul_vv_i32m8(vSrcA,
vSrcB, vl), vSum, vl);
pSrcA += vl;
pSrcB += vl;
n -= vl;
}
*result = __riscv_vmv_x_s_i64m1_i64(vSum);
}
https://godbolt.org/z/sb8G7ExKP
GCC:
...
vmv1r.v v2,v1
...
vwredsum.vs v1,v8,v2
Clang:
vwredsum.vs v8, v24, v8
The root cause is that we don't allow vwredsum.vs vd,vs2,vs1, vs1 overlaps vd.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug target/112327] RVV: Redundant vmv1r for widen reduction
2023-11-01 6:17 [Bug c/112327] New: RVV: Redundant vmv1r for widen reduction juzhe.zhong at rivai dot ai
@ 2023-11-02 0:51 ` cvs-commit at gcc dot gnu.org
2023-11-02 0:52 ` juzhe.zhong at rivai dot ai
1 sibling, 0 replies; 3+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-11-02 0:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112327
--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Pan Li <panli@gcc.gnu.org>:
https://gcc.gnu.org/g:1a0af6e5a99cd895a663f0221c25321ae802413f
commit r14-5067-g1a0af6e5a99cd895a663f0221c25321ae802413f
Author: Juzhe-Zhong <juzhe.zhong@rivai.ai>
Date: Wed Nov 1 14:56:39 2023 +0800
RISC-V: Allow dest operand and accumulator operand overlap of widen
reduction instruction[PR112327]
Consider this following intrinsic code:
void rvv_dot_prod(int16_t *pSrcA, int16_t *pSrcB, uint32_t n, int64_t
*result)
{
size_t vl;
vint16m4_t vSrcA, vSrcB;
vint64m1_t vSum = __riscv_vmv_s_x_i64m1(0, 1);
while (n > 0) {
vl = __riscv_vsetvl_e16m4(n);
vSrcA = __riscv_vle16_v_i16m4(pSrcA, vl);
vSrcB = __riscv_vle16_v_i16m4(pSrcB, vl);
vSum =
__riscv_vwredsum_vs_i32m8_i64m1(__riscv_vwmul_vv_i32m8(vSrcA, vSrcB, vl), vSum,
vl);
pSrcA += vl;
pSrcB += vl;
n -= vl;
}
*result = __riscv_vmv_x_s_i64m1_i64(vSum);
}
https://godbolt.org/z/vWd35W7G6
Before this patch:
...
Loop:
...
vmv1r.v v2,v1
...
vwredsum.vs v1,v8,v2
...
After this patch:
...
Loop:
...
vwredsum.vs v1,v8,v1
...
PR target/112327
gcc/ChangeLog:
* config/riscv/vector.md: Add '0'.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/base/pr112327-1.c: New test.
* gcc.target/riscv/rvv/base/pr112327-2.c: New test.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug target/112327] RVV: Redundant vmv1r for widen reduction
2023-11-01 6:17 [Bug c/112327] New: RVV: Redundant vmv1r for widen reduction juzhe.zhong at rivai dot ai
2023-11-02 0:51 ` [Bug target/112327] " cvs-commit at gcc dot gnu.org
@ 2023-11-02 0:52 ` juzhe.zhong at rivai dot ai
1 sibling, 0 replies; 3+ messages in thread
From: juzhe.zhong at rivai dot ai @ 2023-11-02 0:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112327
JuzheZhong <juzhe.zhong at rivai dot ai> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|UNCONFIRMED |RESOLVED
--- Comment #2 from JuzheZhong <juzhe.zhong at rivai dot ai> ---
Fixed
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-11-02 0:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-01 6:17 [Bug c/112327] New: RVV: Redundant vmv1r for widen reduction juzhe.zhong at rivai dot ai
2023-11-02 0:51 ` [Bug target/112327] " cvs-commit at gcc dot gnu.org
2023-11-02 0:52 ` juzhe.zhong at rivai dot ai
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).