From: "Li, Pan2" <pan2.li@intel.com>
To: Jeff Law <jeffreyalaw@gmail.com>,
"juzhe.zhong@rivai.ai" <juzhe.zhong@rivai.ai>,
"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Cc: "kito.cheng@sifive.com" <kito.cheng@sifive.com>,
"palmer@rivosinc.com" <palmer@rivosinc.com>,
"rdapp.gcc@gmail.com" <rdapp.gcc@gmail.com>
Subject: RE: [PATCH V2] RISC-V: Enhance RVV VLA SLP auto-vectorization with decompress operation
Date: Tue, 13 Jun 2023 01:28:52 +0000 [thread overview]
Message-ID: <MW5PR11MB5908E630CD87576E41B8D675A955A@MW5PR11MB5908.namprd11.prod.outlook.com> (raw)
In-Reply-To: <c0051fb8-ae42-9feb-c2ca-f0067e9b88fd@gmail.com>
Committed, thanks Jeff.
Pan
-----Original Message-----
From: Gcc-patches <gcc-patches-bounces+pan2.li=intel.com@gcc.gnu.org> On Behalf Of Jeff Law via Gcc-patches
Sent: Tuesday, June 13, 2023 3:43 AM
To: juzhe.zhong@rivai.ai; gcc-patches@gcc.gnu.org
Cc: kito.cheng@sifive.com; palmer@rivosinc.com; rdapp.gcc@gmail.com
Subject: Re: [PATCH V2] RISC-V: Enhance RVV VLA SLP auto-vectorization with decompress operation
On 6/12/23 09:11, juzhe.zhong@rivai.ai wrote:
> From: Juzhe-Zhong <juzhe.zhong@rivai.ai>
>
> According to RVV ISA:
> https://github.com/riscv/riscv-v-spec/blob/master/v-spec.adoc
>
> We can enhance VLA SLP auto-vectorization with (16.5.1. Synthesizing
> vdecompress) Decompress operation.
>
> Case 1 (nunits = POLY_INT_CST [16, 16]):
> _48 = VEC_PERM_EXPR <_37, _35, { 0, POLY_INT_CST [16, 16], 1,
> POLY_INT_CST [17, 16], 2, POLY_INT_CST [18, 16], ... }>; We can optimize such VLA SLP permuation pattern into:
> _48 = vdecompress (_37, _35, mask = { 0, 1, 0, 1, ... };
>
> Case 2 (nunits = POLY_INT_CST [16, 16]):
> _23 = VEC_PERM_EXPR <_46, _44, { POLY_INT_CST [1, 1], POLY_INT_CST [3,
> 3], POLY_INT_CST [2, 1], POLY_INT_CST [4, 3], POLY_INT_CST [3, 1], POLY_INT_CST [5, 3], ... }>; We can optimize such VLA SLP permuation pattern into:
> _48 = vdecompress (slidedown(_46, 1/2 nunits), slidedown(_44, 1/2
> nunits), mask = { 0, 1, 0, 1, ... };
>
> For example:
> void __attribute__ ((noinline, noclone)) vec_slp (uint64_t *restrict
> a, uint64_t b, uint64_t c, int n) {
> for (int i = 0; i < n; ++i)
> {
> a[i * 2] += b;
> a[i * 2 + 1] += c;
> }
> }
>
> ASM:
> ...
> vid.v v0
> vand.vi v0,v0,1
> vmseq.vi v0,v0,1 ===> mask = { 0, 1, 0, 1, ... }
> vdecompress:
> viota.m v3,v0
> vrgather.vv v2,v1,v3,v0.t
> Loop:
> vsetvli zero,a5,e64,m1,ta,ma
> vle64.v v1,0(a0)
> vsetvli a6,zero,e64,m1,ta,ma
> vadd.vv v1,v2,v1
> vsetvli zero,a5,e64,m1,ta,ma
> mv a5,a3
> vse64.v v1,0(a0)
> add a3,a3,a1
> add a0,a0,a2
> bgtu a5,a4,.L4
>
>
> gcc/ChangeLog:
>
> * config/riscv/riscv-v.cc (emit_vlmax_decompress_insn): New function.
> (shuffle_decompress_patterns): New function.
> (expand_vec_perm_const_1): Add decompress optimization.
>
> gcc/testsuite/ChangeLog:
>
> * gcc.target/riscv/rvv/autovec/partial/slp-8.c: New test.
> * gcc.target/riscv/rvv/autovec/partial/slp-9.c: New test.
> * gcc.target/riscv/rvv/autovec/partial/slp_run-8.c: New test.
> * gcc.target/riscv/rvv/autovec/partial/slp_run-9.c: New test.
I've been wanting to get inside expand_vec_perm_const to see what opportunities might exist to improve code in there. We had good success mining this space at a prior employer. While we had a lot of weird idioms and costs to consider it was well worth the time.
So quite happy to see you diving into this code.
OK for the trunk,
Jeff
prev parent reply other threads:[~2023-06-13 1:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-12 15:11 juzhe.zhong
2023-06-12 19:42 ` Jeff Law
2023-06-13 1:28 ` Li, Pan2 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=MW5PR11MB5908E630CD87576E41B8D675A955A@MW5PR11MB5908.namprd11.prod.outlook.com \
--to=pan2.li@intel.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jeffreyalaw@gmail.com \
--cc=juzhe.zhong@rivai.ai \
--cc=kito.cheng@sifive.com \
--cc=palmer@rivosinc.com \
--cc=rdapp.gcc@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).