LoongArch: Use fcmp.caf.s instead of movgr2cf for zeroing a fcc

Message ID 20231017140706.21281-1-xry111@xry111.site
State Accepted
Headers
Series LoongArch: Use fcmp.caf.s instead of movgr2cf for zeroing a fcc |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Xi Ruoyao Oct. 17, 2023, 2:06 p.m. UTC
  During the review of a LLVM change [1], on LA464 we found that zeroing
a fcc with fcmp.caf.s is much faster than a movgr2cf from $r0.

[1]: https://github.com/llvm/llvm-project/pull/69300

gcc/ChangeLog:

	* config/loongarch/loongarch.md (movfcc): Use fcmp.caf.s for
	zeroing a fcc.
---

Bootstrapped and regtested on loongarch64-linux-gnu.  Ok for trunk?

 gcc/config/loongarch/loongarch.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

WANG Xuerui Oct. 17, 2023, 2:24 p.m. UTC | #1
On 10/17/23 22:06, Xi Ruoyao wrote:
> During the review of a LLVM change [1], on LA464 we found that zeroing
"an" LLVM change (because the word LLVM is pronounced letter-by-letter)
> a fcc with fcmp.caf.s is much faster than a movgr2cf from $r0.
Similarly, "an" fcc
>
> [1]: https://github.com/llvm/llvm-project/pull/69300
>
> gcc/ChangeLog:
>
> 	* config/loongarch/loongarch.md (movfcc): Use fcmp.caf.s for
> 	zeroing a fcc.
> ---
>
> Bootstrapped and regtested on loongarch64-linux-gnu.  Ok for trunk?
>
>   gcc/config/loongarch/loongarch.md | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gcc/config/loongarch/loongarch.md b/gcc/config/loongarch/loongarch.md
> index 68897799505..743e75907a6 100644
> --- a/gcc/config/loongarch/loongarch.md
> +++ b/gcc/config/loongarch/loongarch.md
> @@ -2151,7 +2151,7 @@ (define_insn "movfcc"
>     [(set (match_operand:FCC 0 "register_operand" "=z")
>   	(const_int 0))]
>     ""
> -  "movgr2cf\t%0,$r0")
> +  "fcmp.caf.s\t%0,$f0,$f0")
>   
>   ;; Conditional move instructions.
>   
Trivial enough, so this LGTM apart from the grammatical nits. (Whoever 
pushing this patch could simply amend it themselves so maybe there's no 
need for a v2.) Thanks!
  
chenglulu Oct. 18, 2023, 1:34 a.m. UTC | #2
在 2023/10/17 下午10:24, WANG Xuerui 写道:
>
> On 10/17/23 22:06, Xi Ruoyao wrote:
>> During the review of a LLVM change [1], on LA464 we found that zeroing
> "an" LLVM change (because the word LLVM is pronounced letter-by-letter)
>> a fcc with fcmp.caf.s is much faster than a movgr2cf from $r0.
> Similarly, "an" fcc
>>
>> [1]: https://github.com/llvm/llvm-project/pull/69300
>>
>> gcc/ChangeLog:
>>
>>     * config/loongarch/loongarch.md (movfcc): Use fcmp.caf.s for
>>     zeroing a fcc.
>> ---
>>
>> Bootstrapped and regtested on loongarch64-linux-gnu.  Ok for trunk?

Ok!

Thanks.

>>
>>   gcc/config/loongarch/loongarch.md | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/gcc/config/loongarch/loongarch.md 
>> b/gcc/config/loongarch/loongarch.md
>> index 68897799505..743e75907a6 100644
>> --- a/gcc/config/loongarch/loongarch.md
>> +++ b/gcc/config/loongarch/loongarch.md
>> @@ -2151,7 +2151,7 @@ (define_insn "movfcc"
>>     [(set (match_operand:FCC 0 "register_operand" "=z")
>>       (const_int 0))]
>>     ""
>> -  "movgr2cf\t%0,$r0")
>> +  "fcmp.caf.s\t%0,$f0,$f0")
>>     ;; Conditional move instructions.
> Trivial enough, so this LGTM apart from the grammatical nits. (Whoever 
> pushing this patch could simply amend it themselves so maybe there's 
> no need for a v2.) Thanks! \
  
Xi Ruoyao Oct. 18, 2023, 8:41 a.m. UTC | #3
On Wed, 2023-10-18 at 09:34 +0800, chenglulu wrote:
> 
> 在 2023/10/17 下午10:24, WANG Xuerui 写道:
> > 
> > On 10/17/23 22:06, Xi Ruoyao wrote:
> > > During the review of a LLVM change [1], on LA464 we found that zeroing
> > "an" LLVM change (because the word LLVM is pronounced letter-by-letter)
> > > a fcc with fcmp.caf.s is much faster than a movgr2cf from $r0.
> > Similarly, "an" fcc
> > > 
> > > [1]: https://github.com/llvm/llvm-project/pull/69300
> > > 
> > > gcc/ChangeLog:
> > > 
> > >     * config/loongarch/loongarch.md (movfcc): Use fcmp.caf.s for
> > >     zeroing a fcc.
> > > ---
> > > 
> > > Bootstrapped and regtested on loongarch64-linux-gnu.  Ok for trunk?
> 
> Ok!

Pushed r14-4712 with the commit message modified following Xuerui's
suggestion.
  

Patch

diff --git a/gcc/config/loongarch/loongarch.md b/gcc/config/loongarch/loongarch.md
index 68897799505..743e75907a6 100644
--- a/gcc/config/loongarch/loongarch.md
+++ b/gcc/config/loongarch/loongarch.md
@@ -2151,7 +2151,7 @@  (define_insn "movfcc"
   [(set (match_operand:FCC 0 "register_operand" "=z")
 	(const_int 0))]
   ""
-  "movgr2cf\t%0,$r0")
+  "fcmp.caf.s\t%0,$f0,$f0")
 
 ;; Conditional move instructions.