public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: chenglulu <chenglulu@loongson.cn>
To: Xi Ruoyao <xry111@xry111.site>, gcc-patches@gcc.gnu.org
Cc: Chenghui Pan <panchenghui@loongson.cn>,
	i@xen0n.name, xuchenghua@loongson.cn
Subject: Re: [PATCH] LoongArch: Use LSX and LASX for block move
Date: Sat, 9 Sep 2023 14:10:59 +0800	[thread overview]
Message-ID: <aab961ef-5c24-18df-7103-6a9ec67e1a20@loongson.cn> (raw)
In-Reply-To: <20230907161407.27338-2-xry111@xry111.site>


在 2023/9/8 上午12:14, Xi Ruoyao 写道:
> gcc/ChangeLog:
>
> 	* config/loongarch/loongarch.h (LARCH_MAX_MOVE_PER_INSN):
> 	Define to the maximum amount of bytes able to be loaded or
> 	stored with one machine instruction.
> 	* config/loongarch/loongarch.cc (loongarch_mode_for_move_size):
> 	New static function.
> 	(loongarch_block_move_straight): Call
> 	loongarch_mode_for_move_size for machine_mode to be moved.
> 	(loongarch_expand_block_move): Use LARCH_MAX_MOVE_PER_INSN
> 	instead of UNITS_PER_WORD.
> ---
>
> Bootstrapped and regtested on loongarch64-linux-gnu, with PR110939 patch
> applied, the "lib_build_self_spec = %<..." line in t-linux commented out
> (because it's silently making -mlasx in BOOT_CFLAGS ineffective, Yujie
> is working on a proper fix), and BOOT_CFLAGS="-O3 -mlasx".  Ok for trunk?

I think test cases need to be added here.

Otherwise OK, thanks!

>   gcc/config/loongarch/loongarch.cc | 22 ++++++++++++++++++----
>   gcc/config/loongarch/loongarch.h  |  3 +++
>   2 files changed, 21 insertions(+), 4 deletions(-)
>
> diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
> index 6698414281e..509ef2b97f1 100644
> --- a/gcc/config/loongarch/loongarch.cc
> +++ b/gcc/config/loongarch/loongarch.cc
> @@ -5191,6 +5191,20 @@ loongarch_function_ok_for_sibcall (tree decl ATTRIBUTE_UNUSED,
>     return true;
>   }
>   
> +static machine_mode
> +loongarch_mode_for_move_size (HOST_WIDE_INT size)
> +{
> +  switch (size)
> +    {
> +    case 32:
> +      return V32QImode;
> +    case 16:
> +      return V16QImode;
> +    }
> +
> +  return int_mode_for_size (size * BITS_PER_UNIT, 0).require ();
> +}
> +
>   /* Emit straight-line code to move LENGTH bytes from SRC to DEST.
>      Assume that the areas do not overlap.  */
>   
> @@ -5220,7 +5234,7 @@ loongarch_block_move_straight (rtx dest, rtx src, HOST_WIDE_INT length,
>   
>     for (delta_cur = delta, i = 0, offs = 0; offs < length; delta_cur /= 2)
>       {
> -      mode = int_mode_for_size (delta_cur * BITS_PER_UNIT, 0).require ();
> +      mode = loongarch_mode_for_move_size (delta_cur);
>   
>         for (; offs + delta_cur <= length; offs += delta_cur, i++)
>   	{
> @@ -5231,7 +5245,7 @@ loongarch_block_move_straight (rtx dest, rtx src, HOST_WIDE_INT length,
>   
>     for (delta_cur = delta, i = 0, offs = 0; offs < length; delta_cur /= 2)
>       {
> -      mode = int_mode_for_size (delta_cur * BITS_PER_UNIT, 0).require ();
> +      mode = loongarch_mode_for_move_size (delta_cur);
>   
>         for (; offs + delta_cur <= length; offs += delta_cur, i++)
>   	loongarch_emit_move (adjust_address (dest, mode, offs), regs[i]);
> @@ -5326,8 +5340,8 @@ loongarch_expand_block_move (rtx dest, rtx src, rtx r_length, rtx r_align)
>   
>     HOST_WIDE_INT align = INTVAL (r_align);
>   
> -  if (!TARGET_STRICT_ALIGN || align > UNITS_PER_WORD)
> -    align = UNITS_PER_WORD;
> +  if (!TARGET_STRICT_ALIGN || align > LARCH_MAX_MOVE_PER_INSN)
> +    align = LARCH_MAX_MOVE_PER_INSN;
>   
>     if (length <= align * LARCH_MAX_MOVE_OPS_STRAIGHT)
>       {
> diff --git a/gcc/config/loongarch/loongarch.h b/gcc/config/loongarch/loongarch.h
> index 3fc9dc43ab1..7e391205583 100644
> --- a/gcc/config/loongarch/loongarch.h
> +++ b/gcc/config/loongarch/loongarch.h
> @@ -1181,6 +1181,9 @@ typedef struct {
>      least twice.  */
>   #define LARCH_MAX_MOVE_OPS_STRAIGHT (LARCH_MAX_MOVE_OPS_PER_LOOP_ITER * 2)
>   
> +#define LARCH_MAX_MOVE_PER_INSN \
> +  (ISA_HAS_LASX ? 32 : (ISA_HAS_LSX ? 16 : UNITS_PER_WORD))
> +
>   /* The base cost of a memcpy call, for MOVE_RATIO and friends.  These
>      values were determined experimentally by benchmarking with CSiBE.
>   */


  reply	other threads:[~2023-09-09  6:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-07 16:14 Xi Ruoyao
2023-09-09  6:10 ` chenglulu [this message]
2023-09-09  7:03   ` Pushed: [PATCH v2] " Xi Ruoyao
2023-09-09  7:04 ` [PATCH] " chenglulu
2023-09-09  7:06   ` Xi Ruoyao
2023-09-09  7:14     ` chenglulu
2023-09-09  7:15       ` Xi Ruoyao

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=aab961ef-5c24-18df-7103-6a9ec67e1a20@loongson.cn \
    --to=chenglulu@loongson.cn \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=i@xen0n.name \
    --cc=panchenghui@loongson.cn \
    --cc=xry111@xry111.site \
    --cc=xuchenghua@loongson.cn \
    /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).