public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: WANG Xuerui <i@xen0n.name>
To: mengqinggang <mengqinggang@loongson.cn>, gcc-patches@gcc.gnu.org
Cc: chenglulu@loongson.cn, xry111@xry111.site, xuchenghua@loongson.cn
Subject: Re: [PATCH] LoongArch: Fix lo_sum rtx cost
Date: Sat, 16 Sep 2023 22:52:02 +0800	[thread overview]
Message-ID: <b9785a47-d71f-82b4-069c-b5474b76f7e0@xen0n.name> (raw)
In-Reply-To: <20230916091643.3160525-1-mengqinggang@loongson.cn>

Hi,

On 9/16/23 17:16, mengqinggang wrote:
> The cost of lo_sum rtx for addi.d instruction my be a very big number if
> computed by common function. It may cause some symbols saving to stack and
> loading from stack if there no enough registers during loop optimization.

Thanks for the patch! It seems though this change is done in order to 
optimize some previously pathetic codegen, am I right? If so, it's 
appreciated to have a minimal test case attached, in order to ensure 
that codegen never regresses. (You can have your teammates help you if 
you're not familiar with that.)

>
> gcc/ChangeLog:
>
> 	* config/loongarch/loongarch.cc (loongarch_rtx_costs): Add lo_sum cost.
> ---
>   gcc/config/loongarch/loongarch.cc | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
> index 845fad5a8e8..0e57f09379c 100644
> --- a/gcc/config/loongarch/loongarch.cc
> +++ b/gcc/config/loongarch/loongarch.cc
> @@ -3648,6 +3648,10 @@ loongarch_rtx_costs (rtx x, machine_mode mode, int outer_code,
>   	*total = COSTS_N_INSNS (4);
>         return false;
>   
> +    case LO_SUM:
> +      *total = set_src_cost (XEXP (x, 0), mode, speed);
> +      return true;
> +
In order for the code to be more maintainable, it may be better to 
duplicate some of the change reasons here, just in case someone in the 
future questions this piece of code that's without any explanation, and 
regresses things (because there's no test case).
>       case LT:
>       case LTU:
>       case LE:

  reply	other threads:[~2023-09-16 14:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-16  9:16 mengqinggang
2023-09-16 14:52 ` WANG Xuerui [this message]
2023-09-17  1:42   ` chenglulu

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=b9785a47-d71f-82b4-069c-b5474b76f7e0@xen0n.name \
    --to=i@xen0n.name \
    --cc=chenglulu@loongson.cn \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mengqinggang@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).