public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: Juzhe-Zhong <juzhe.zhong@rivai.ai>, gcc-patches@gcc.gnu.org
Cc: kito.cheng@gmail.com, kito.cheng@sifive.com, rdapp.gcc@gmail.com
Subject: Re: [PATCH] RISC-V: Support MASK_LEN_{LOAD_LANES,STORE_LANES}
Date: Tue, 15 Aug 2023 08:19:04 -0600	[thread overview]
Message-ID: <9554fab8-e2a8-4f20-1f55-7f0c2c56dffe@gmail.com> (raw)
In-Reply-To: <20230814121527.3482525-1-juzhe.zhong@rivai.ai>



On 8/14/23 06:15, Juzhe-Zhong wrote:
> This patch is depending on middle-end support:
> https://gcc.gnu.org/pipermail/gcc-patches/2023-August/627305.html
> 
> This patch allow us auto-vectorize this following case:
> 
> #define TEST_LOOP(NAME, OUTTYPE, INTYPE, MASKTYPE)                             \
>    void __attribute__ ((noinline, noclone))                                     \
>    NAME##_8 (OUTTYPE *__restrict dest, INTYPE *__restrict src,                  \
> 	    MASKTYPE *__restrict cond, intptr_t n)                             \
>    {                                                                            \
>      for (intptr_t i = 0; i < n; ++i)                                           \
>        if (cond[i])                                                             \
> 	dest[i] = (src[i * 8] + src[i * 8 + 1] + src[i * 8 + 2]                \
> 		   + src[i * 8 + 3] + src[i * 8 + 4] + src[i * 8 + 5]          \
> 		   + src[i * 8 + 6] + src[i * 8 + 7]);                         \
>    }
> 
> #define TEST2(NAME, OUTTYPE, INTYPE)                                           \
>    TEST_LOOP (NAME##_f32, OUTTYPE, INTYPE, int32_t)                               \
> 
> #define TEST1(NAME, OUTTYPE)                                                   \
>    TEST2 (NAME##_i32, OUTTYPE, int32_t)                                         \
> 
> #define TEST(NAME)                                                             \
>    TEST1 (NAME##_i32, int32_t)                                                  \
> 
> TEST (test)
> 
> ASM:
> 
> test_i32_i32_f32_8:
> 	ble	a3,zero,.L5
> .L3:
> 	vsetvli	a4,a3,e8,mf4,ta,ma
> 	vle32.v	v0,0(a2)
> 	vsetvli	a5,zero,e32,m1,ta,ma
> 	vmsne.vi	v0,v0,0
> 	vsetvli	zero,a4,e32,m1,ta,ma
> 	vlseg8e32.v	v8,(a1),v0.t
> 	vsetvli	a5,zero,e32,m1,ta,ma
> 	slli	a6,a4,2
> 	vadd.vv	v1,v9,v8
> 	slli	a7,a4,5
> 	vadd.vv	v1,v1,v10
> 	sub	a3,a3,a4
> 	vadd.vv	v1,v1,v11
> 	vadd.vv	v1,v1,v12
> 	vadd.vv	v1,v1,v13
> 	vadd.vv	v1,v1,v14
> 	vadd.vv	v1,v1,v15
> 	vsetvli	zero,a4,e32,m1,ta,ma
> 	vse32.v	v1,0(a0),v0.t
> 	add	a2,a2,a6
> 	add	a1,a1,a7
> 	add	a0,a0,a6
> 	bne	a3,zero,.L3
> .L5:
> 	ret
> 
> gcc/ChangeLog:
> 
>          * config/riscv/autovec.md (vec_mask_len_load_lanes<mode><vsingle>): New pattern.
>          (vec_mask_len_store_lanes<mode><vsingle>): Ditto.
>          (<optab><v_quad_trunc><mode>2): Fix pattern for ICE.
>          (<optab><v_oct_trunc><mode>2): Ditto.
>          * config/riscv/riscv-protos.h (expand_lanes_load_store): New function.
>          * config/riscv/riscv-v.cc (get_mask_mode): Add tuple mode mask mode.
>          (expand_lanes_load_store): New function.
>          * config/riscv/vector-iterators.md: New iterator.
I would generally recommend sending independent fixes separately.  In 
particular the quad_trunc, oct_trunc changes seem like they should have 
been a separate patch.  But no need to resend this time.  Just try to 
break out distinct changes like those into their own patch.

OK, but obviously hold off committing until the generic support is 
approved and committed.

Thanks,
jeff


      parent reply	other threads:[~2023-08-15 14:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-14 12:15 Juzhe-Zhong
2023-08-15 14:18 ` Jeff Law
2023-08-16  1:22   ` juzhe.zhong
2023-08-16  6:10     ` Li, Pan2
2023-08-15 14:19 ` Jeff Law [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=9554fab8-e2a8-4f20-1f55-7f0c2c56dffe@gmail.com \
    --to=jeffreyalaw@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=juzhe.zhong@rivai.ai \
    --cc=kito.cheng@gmail.com \
    --cc=kito.cheng@sifive.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).