public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] LoongArch: Fix lo_sum rtx cost
@ 2023-09-16  9:16 mengqinggang
  2023-09-16 14:52 ` WANG Xuerui
  0 siblings, 1 reply; 3+ messages in thread
From: mengqinggang @ 2023-09-16  9:16 UTC (permalink / raw)
  To: gcc-patches; +Cc: chenglulu, xry111, i, xuchenghua, mengqinggang

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.

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;
+
     case LT:
     case LTU:
     case LE:
-- 
2.36.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] LoongArch: Fix lo_sum rtx cost
  2023-09-16  9:16 [PATCH] LoongArch: Fix lo_sum rtx cost mengqinggang
@ 2023-09-16 14:52 ` WANG Xuerui
  2023-09-17  1:42   ` chenglulu
  0 siblings, 1 reply; 3+ messages in thread
From: WANG Xuerui @ 2023-09-16 14:52 UTC (permalink / raw)
  To: mengqinggang, gcc-patches; +Cc: chenglulu, xry111, xuchenghua

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:

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] LoongArch: Fix lo_sum rtx cost
  2023-09-16 14:52 ` WANG Xuerui
@ 2023-09-17  1:42   ` chenglulu
  0 siblings, 0 replies; 3+ messages in thread
From: chenglulu @ 2023-09-17  1:42 UTC (permalink / raw)
  To: WANG Xuerui, mengqinggang, gcc-patches; +Cc: xry111, xuchenghua


在 2023/9/16 下午10:52, WANG Xuerui 写道:
> 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.)

This is a performance optimization problem discovered by Meng Qinggang 
when he was debugging the spec. The specific test cases are not easy to 
extract.

We will try to extract simple test cases to reproduce this optimization. 
If not, we will mark the description information.

Thanks!

>
>>
>> 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:


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-09-17  1:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-16  9:16 [PATCH] LoongArch: Fix lo_sum rtx cost mengqinggang
2023-09-16 14:52 ` WANG Xuerui
2023-09-17  1:42   ` chenglulu

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).