public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] LoongArch: Fix incorrect return type for frecipe/frsqrte intrinsic functions
@ 2024-01-24  9:19 Jiahao Xu
  2024-01-24  9:48 ` Xi Ruoyao
  2024-02-02  2:15 ` [pushed][PATCH] " chenglulu
  0 siblings, 2 replies; 5+ messages in thread
From: Jiahao Xu @ 2024-01-24  9:19 UTC (permalink / raw)
  To: gcc-patches; +Cc: xry111, i, chenglulu, xuchenghua, Jiahao Xu

gcc/ChangeLog:

	* config/loongarch/larchintrin.h
	(__frecipe_s): Update function return type.
	(__frecipe_d): Ditto.
	(__frsqrte_s): Ditto.
	(__frsqrte_d): Ditto.

gcc/testsuite/ChangeLog:

	* gcc.target/loongarch/larch-frecipe-intrinsic.c: New test.

diff --git a/gcc/config/loongarch/larchintrin.h b/gcc/config/loongarch/larchintrin.h
index 7692415e04d..ff2c9f460ac 100644
--- a/gcc/config/loongarch/larchintrin.h
+++ b/gcc/config/loongarch/larchintrin.h
@@ -336,38 +336,38 @@ __iocsrwr_d (unsigned long int _1, unsigned int _2)
 #ifdef __loongarch_frecipe
 /* Assembly instruction format: fd, fj.  */
 /* Data types in instruction templates:  SF, SF.  */
-extern __inline void
+extern __inline float
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 __frecipe_s (float _1)
 {
-  __builtin_loongarch_frecipe_s ((float) _1);
+  return (float) __builtin_loongarch_frecipe_s ((float) _1);
 }
 
 /* Assembly instruction format: fd, fj.  */
 /* Data types in instruction templates:  DF, DF.  */
-extern __inline void
+extern __inline double
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 __frecipe_d (double _1)
 {
-  __builtin_loongarch_frecipe_d ((double) _1);
+  return (double) __builtin_loongarch_frecipe_d ((double) _1);
 }
 
 /* Assembly instruction format: fd, fj.  */
 /* Data types in instruction templates:  SF, SF.  */
-extern __inline void
+extern __inline float
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 __frsqrte_s (float _1)
 {
-  __builtin_loongarch_frsqrte_s ((float) _1);
+  return (float) __builtin_loongarch_frsqrte_s ((float) _1);
 }
 
 /* Assembly instruction format: fd, fj.  */
 /* Data types in instruction templates:  DF, DF.  */
-extern __inline void
+extern __inline double
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 __frsqrte_d (double _1)
 {
-  __builtin_loongarch_frsqrte_d ((double) _1);
+  return (double) __builtin_loongarch_frsqrte_d ((double) _1);
 }
 #endif
 
diff --git a/gcc/testsuite/gcc.target/loongarch/larch-frecipe-intrinsic.c b/gcc/testsuite/gcc.target/loongarch/larch-frecipe-intrinsic.c
new file mode 100644
index 00000000000..6ce2bde0acf
--- /dev/null
+++ b/gcc/testsuite/gcc.target/loongarch/larch-frecipe-intrinsic.c
@@ -0,0 +1,30 @@
+/* Test intrinsics for frecipe.{s/d} and frsqrte.{s/d} instructions */
+/* { dg-do compile } */
+/* { dg-options "-mfrecipe -O2" } */
+/* { dg-final { scan-assembler-times "test_frecipe_s:.*frecipe\\.s.*test_frecipe_s" 1 } } */
+/* { dg-final { scan-assembler-times "test_frecipe_d:.*frecipe\\.d.*test_frecipe_d" 1 } } */
+/* { dg-final { scan-assembler-times "test_frsqrte_s:.*frsqrte\\.s.*test_frsqrte_s" 1 } } */
+/* { dg-final { scan-assembler-times "test_frsqrte_d:.*frsqrte\\.d.*test_frsqrte_d" 1 } } */
+
+#include <larchintrin.h>
+
+float
+test_frecipe_s (float _1)
+{
+  return __frecipe_s (_1);
+}
+double
+test_frecipe_d (double _1)
+{
+  return __frecipe_d (_1);
+}
+float
+test_frsqrte_s (float _1)
+{
+  return __frsqrte_s (_1);
+}
+double
+test_frsqrte_d (double _1)
+{
+  return __frsqrte_d (_1);
+}
-- 
2.20.1


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

* Re: [PATCH] LoongArch: Fix incorrect return type for frecipe/frsqrte intrinsic functions
  2024-01-24  9:19 [PATCH] LoongArch: Fix incorrect return type for frecipe/frsqrte intrinsic functions Jiahao Xu
@ 2024-01-24  9:48 ` Xi Ruoyao
  2024-01-24  9:58   ` Jiahao Xu
  2024-02-02  2:15 ` [pushed][PATCH] " chenglulu
  1 sibling, 1 reply; 5+ messages in thread
From: Xi Ruoyao @ 2024-01-24  9:48 UTC (permalink / raw)
  To: Jiahao Xu, gcc-patches; +Cc: i, chenglulu, xuchenghua

On Wed, 2024-01-24 at 17:19 +0800, Jiahao Xu wrote:
> gcc/ChangeLog:
> 
> 	* config/loongarch/larchintrin.h
> 	(__frecipe_s): Update function return type.
> 	(__frecipe_d): Ditto.
> 	(__frsqrte_s): Ditto.
> 	(__frsqrte_d): Ditto.
> 
> gcc/testsuite/ChangeLog:
> 
> 	* gcc.target/loongarch/larch-frecipe-intrinsic.c: New test.
> 
> diff --git a/gcc/config/loongarch/larchintrin.h b/gcc/config/loongarch/larchintrin.h
> index 7692415e04d..ff2c9f460ac 100644
> --- a/gcc/config/loongarch/larchintrin.h
> +++ b/gcc/config/loongarch/larchintrin.h
> @@ -336,38 +336,38 @@ __iocsrwr_d (unsigned long int _1, unsigned int _2)
>  #ifdef __loongarch_frecipe
>  /* Assembly instruction format: fd, fj.  */
>  /* Data types in instruction templates:  SF, SF.  */
> -extern __inline void
> +extern __inline float
>  __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
>  __frecipe_s (float _1)
>  {
> -  __builtin_loongarch_frecipe_s ((float) _1);
> +  return (float) __builtin_loongarch_frecipe_s ((float) _1);

I don't think the (float) conversion is needed.


-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

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

* Re: [PATCH] LoongArch: Fix incorrect return type for frecipe/frsqrte intrinsic functions
  2024-01-24  9:48 ` Xi Ruoyao
@ 2024-01-24  9:58   ` Jiahao Xu
  2024-01-25  6:12     ` chenglulu
  0 siblings, 1 reply; 5+ messages in thread
From: Jiahao Xu @ 2024-01-24  9:58 UTC (permalink / raw)
  To: Xi Ruoyao, gcc-patches; +Cc: i, chenglulu, xuchenghua


在 2024/1/24 下午5:48, Xi Ruoyao 写道:
> On Wed, 2024-01-24 at 17:19 +0800, Jiahao Xu wrote:
>> gcc/ChangeLog:
>>
>> 	* config/loongarch/larchintrin.h
>> 	(__frecipe_s): Update function return type.
>> 	(__frecipe_d): Ditto.
>> 	(__frsqrte_s): Ditto.
>> 	(__frsqrte_d): Ditto.
>>
>> gcc/testsuite/ChangeLog:
>>
>> 	* gcc.target/loongarch/larch-frecipe-intrinsic.c: New test.
>>
>> diff --git a/gcc/config/loongarch/larchintrin.h b/gcc/config/loongarch/larchintrin.h
>> index 7692415e04d..ff2c9f460ac 100644
>> --- a/gcc/config/loongarch/larchintrin.h
>> +++ b/gcc/config/loongarch/larchintrin.h
>> @@ -336,38 +336,38 @@ __iocsrwr_d (unsigned long int _1, unsigned int _2)
>>   #ifdef __loongarch_frecipe
>>   /* Assembly instruction format: fd, fj.  */
>>   /* Data types in instruction templates:  SF, SF.  */
>> -extern __inline void
>> +extern __inline float
>>   __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
>>   __frecipe_s (float _1)
>>   {
>> -  __builtin_loongarch_frecipe_s ((float) _1);
>> +  return (float) __builtin_loongarch_frecipe_s ((float) _1);
> I don't think the (float) conversion is needed.
>
>
Indeed, this float conversion is unnecessary; I simply included it to 
align with the definitions of other intrinsic functions.


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

* Re: [PATCH] LoongArch: Fix incorrect return type for frecipe/frsqrte intrinsic functions
  2024-01-24  9:58   ` Jiahao Xu
@ 2024-01-25  6:12     ` chenglulu
  0 siblings, 0 replies; 5+ messages in thread
From: chenglulu @ 2024-01-25  6:12 UTC (permalink / raw)
  To: Jiahao Xu, Xi Ruoyao, gcc-patches; +Cc: i, xuchenghua


在 2024/1/24 下午5:58, Jiahao Xu 写道:
>
> 在 2024/1/24 下午5:48, Xi Ruoyao 写道:
>> On Wed, 2024-01-24 at 17:19 +0800, Jiahao Xu wrote:
>>> gcc/ChangeLog:
>>>
>>>     * config/loongarch/larchintrin.h
>>>     (__frecipe_s): Update function return type.
>>>     (__frecipe_d): Ditto.
>>>     (__frsqrte_s): Ditto.
>>>     (__frsqrte_d): Ditto.
>>>
>>> gcc/testsuite/ChangeLog:
>>>
>>>     * gcc.target/loongarch/larch-frecipe-intrinsic.c: New test.
>>>
>>> diff --git a/gcc/config/loongarch/larchintrin.h 
>>> b/gcc/config/loongarch/larchintrin.h
>>> index 7692415e04d..ff2c9f460ac 100644
>>> --- a/gcc/config/loongarch/larchintrin.h
>>> +++ b/gcc/config/loongarch/larchintrin.h
>>> @@ -336,38 +336,38 @@ __iocsrwr_d (unsigned long int _1, unsigned 
>>> int _2)
>>>   #ifdef __loongarch_frecipe
>>>   /* Assembly instruction format: fd, fj.  */
>>>   /* Data types in instruction templates:  SF, SF.  */
>>> -extern __inline void
>>> +extern __inline float
>>>   __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
>>>   __frecipe_s (float _1)
>>>   {
>>> -  __builtin_loongarch_frecipe_s ((float) _1);
>>> +  return (float) __builtin_loongarch_frecipe_s ((float) _1);
>> I don't think the (float) conversion is needed.
>>
>>
> Indeed, this float conversion is unnecessary; I simply included it to 
> align with the definitions of other intrinsic functions.

This is generated in batches like vectors, so there will be such 
redundant symbol type conversion.

We will remove the redundant types later.



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

* Re: [pushed][PATCH] LoongArch: Fix incorrect return type for frecipe/frsqrte intrinsic functions
  2024-01-24  9:19 [PATCH] LoongArch: Fix incorrect return type for frecipe/frsqrte intrinsic functions Jiahao Xu
  2024-01-24  9:48 ` Xi Ruoyao
@ 2024-02-02  2:15 ` chenglulu
  1 sibling, 0 replies; 5+ messages in thread
From: chenglulu @ 2024-02-02  2:15 UTC (permalink / raw)
  To: Jiahao Xu, gcc-patches; +Cc: xry111, i, xuchenghua

Pushed to r14-8723.

在 2024/1/24 下午5:19, Jiahao Xu 写道:
> gcc/ChangeLog:
>
> 	* config/loongarch/larchintrin.h
> 	(__frecipe_s): Update function return type.
> 	(__frecipe_d): Ditto.
> 	(__frsqrte_s): Ditto.
> 	(__frsqrte_d): Ditto.
>
> gcc/testsuite/ChangeLog:
>
> 	* gcc.target/loongarch/larch-frecipe-intrinsic.c: New test.
>
> diff --git a/gcc/config/loongarch/larchintrin.h b/gcc/config/loongarch/larchintrin.h
> index 7692415e04d..ff2c9f460ac 100644
> --- a/gcc/config/loongarch/larchintrin.h
> +++ b/gcc/config/loongarch/larchintrin.h
> @@ -336,38 +336,38 @@ __iocsrwr_d (unsigned long int _1, unsigned int _2)
>   #ifdef __loongarch_frecipe
>   /* Assembly instruction format: fd, fj.  */
>   /* Data types in instruction templates:  SF, SF.  */
> -extern __inline void
> +extern __inline float
>   __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
>   __frecipe_s (float _1)
>   {
> -  __builtin_loongarch_frecipe_s ((float) _1);
> +  return (float) __builtin_loongarch_frecipe_s ((float) _1);
>   }
>   
>   /* Assembly instruction format: fd, fj.  */
>   /* Data types in instruction templates:  DF, DF.  */
> -extern __inline void
> +extern __inline double
>   __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
>   __frecipe_d (double _1)
>   {
> -  __builtin_loongarch_frecipe_d ((double) _1);
> +  return (double) __builtin_loongarch_frecipe_d ((double) _1);
>   }
>   
>   /* Assembly instruction format: fd, fj.  */
>   /* Data types in instruction templates:  SF, SF.  */
> -extern __inline void
> +extern __inline float
>   __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
>   __frsqrte_s (float _1)
>   {
> -  __builtin_loongarch_frsqrte_s ((float) _1);
> +  return (float) __builtin_loongarch_frsqrte_s ((float) _1);
>   }
>   
>   /* Assembly instruction format: fd, fj.  */
>   /* Data types in instruction templates:  DF, DF.  */
> -extern __inline void
> +extern __inline double
>   __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
>   __frsqrte_d (double _1)
>   {
> -  __builtin_loongarch_frsqrte_d ((double) _1);
> +  return (double) __builtin_loongarch_frsqrte_d ((double) _1);
>   }
>   #endif
>   
> diff --git a/gcc/testsuite/gcc.target/loongarch/larch-frecipe-intrinsic.c b/gcc/testsuite/gcc.target/loongarch/larch-frecipe-intrinsic.c
> new file mode 100644
> index 00000000000..6ce2bde0acf
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/loongarch/larch-frecipe-intrinsic.c
> @@ -0,0 +1,30 @@
> +/* Test intrinsics for frecipe.{s/d} and frsqrte.{s/d} instructions */
> +/* { dg-do compile } */
> +/* { dg-options "-mfrecipe -O2" } */
> +/* { dg-final { scan-assembler-times "test_frecipe_s:.*frecipe\\.s.*test_frecipe_s" 1 } } */
> +/* { dg-final { scan-assembler-times "test_frecipe_d:.*frecipe\\.d.*test_frecipe_d" 1 } } */
> +/* { dg-final { scan-assembler-times "test_frsqrte_s:.*frsqrte\\.s.*test_frsqrte_s" 1 } } */
> +/* { dg-final { scan-assembler-times "test_frsqrte_d:.*frsqrte\\.d.*test_frsqrte_d" 1 } } */
> +
> +#include <larchintrin.h>
> +
> +float
> +test_frecipe_s (float _1)
> +{
> +  return __frecipe_s (_1);
> +}
> +double
> +test_frecipe_d (double _1)
> +{
> +  return __frecipe_d (_1);
> +}
> +float
> +test_frsqrte_s (float _1)
> +{
> +  return __frsqrte_s (_1);
> +}
> +double
> +test_frsqrte_d (double _1)
> +{
> +  return __frsqrte_d (_1);
> +}


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

end of thread, other threads:[~2024-02-02  2:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-24  9:19 [PATCH] LoongArch: Fix incorrect return type for frecipe/frsqrte intrinsic functions Jiahao Xu
2024-01-24  9:48 ` Xi Ruoyao
2024-01-24  9:58   ` Jiahao Xu
2024-01-25  6:12     ` chenglulu
2024-02-02  2:15 ` [pushed][PATCH] " 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).