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, palmer@dabbelt.com,
	palmer@rivosinc.com, rdapp.gcc@gmail.com
Subject: Re: [PATCH V2] RISC-V: Enable len_mask{load, store} and remove len_{load, store}
Date: Sun, 25 Jun 2023 06:52:35 -0600	[thread overview]
Message-ID: <b398ae2a-35aa-28bc-93f3-d25ead22e11e@gmail.com> (raw)
In-Reply-To: <20230625083952.9771-1-juzhe.zhong@rivai.ai>



On 6/25/23 02:39, Juzhe-Zhong wrote:
> This patch enable len_mask_{load,store} to support flow-control in RVV auto-vectorization.
> 
> Consider this following case:
> void
> f (int32_t *__restrict a,
>     int32_t *__restrict b,
>     int32_t *__restrict cond,
>     int n)
> {
>    for (int i = 0; i < n; i++)
>      if (cond[i])
>        a[i] = b[i];
> }
> 
> Before this patch:
> <source>:9:21: missed: couldn't vectorize loop
> <source>:9:21: missed: not vectorized: control flow in loop.
> 
> After this patch:
> f:
>          ble     a3,zero,.L5
> .L3:
>          vsetvli a5,a3,e32,m1,ta,ma
>          vle32.v v0,0(a2)
>          vsetvli a6,zero,e32,m1,ta,ma
>          slli    a4,a5,2
>          vmsne.vi        v0,v0,0
>          sub     a3,a3,a5
>          vsetvli zero,a5,e32,m1,ta,ma
>          vle32.v v1,0(a1),v0.t
>          vse32.v v1,0(a0),v0.t
>          add     a2,a2,a4
>          add     a1,a1,a4
>          add     a0,a0,a4
>          bne     a3,zero,.L3
> .L5:
>          ret
> 
> 
> gcc/ChangeLog:
> 
>          * config/riscv/autovec.md (len_load_<mode>): Remove.
>          (len_maskload<mode><vm>): Remove.
>          (len_store_<mode>): New pattern.
>          (len_maskstore<mode><vm>): New pattern.
>          * config/riscv/predicates.md (autovec_length_operand): New predicate.
>          * config/riscv/riscv-protos.h (enum insn_type): New enum.
>          (expand_load_store): New function.
>          * config/riscv/riscv-v.cc (emit_vlmax_masked_insn): Ditto.
>          (emit_nonvlmax_masked_insn): Ditto.
>          (expand_load_store): Ditto.
>          * config/riscv/riscv-vector-builtins.cc (function_expander::use_contiguous_store_insn): Add avl_type operand into pred_store.
>          * config/riscv/vector.md: Ditto.
OK
jeff

  reply	other threads:[~2023-06-25 12:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-25  8:39 Juzhe-Zhong
2023-06-25 12:52 ` Jeff Law [this message]
2023-06-25 13:52   ` Li, Pan2

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=b398ae2a-35aa-28bc-93f3-d25ead22e11e@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=palmer@dabbelt.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).