On Mon, 2023-03-13 at 11:52 +0800, Lulu Cheng wrote:
> diff --git a/gcc/config/loongarch/larchintrin.h
> b/gcc/config/loongarch/larchintrin.h
> index e571ed27b37..09f9a5db846 100644
> --- a/gcc/config/loongarch/larchintrin.h
> +++ b/gcc/config/loongarch/larchintrin.h
> @@ -145,6 +145,7 @@ __asrtgt_d (long int _1, long int _2)
>  #error "Unsupported ABI."
>  #endif
>  
> +#ifdef __loongarch64

Use __loongarch_lp64.

__loongarch64 is deemed as "for Compatibility with Historical Code" now,
and it's defined "as-is" (__loongarch_grlen == 64).  But we are using
"long int" in some of these functions, which is only OK in LP64 ABI.

Or maybe we can handle this better like...

#if __loongarch_grlen == 64 /* the hardware supports crc.w.d.w */

#if __loongarch_lp64
extern __inline int
__crc_w_d_w (long int _1, int _2)
{
  return (int) __builtin_loongarch_crc_w_d_w (_1, _2);
}
#else /* __loongarch_lp64 */
extern __inline int
__crc_w_d_w (long long int _1, int _2)
{
  return (int) __builtin_loongarch_crc_w_d_w (_1, _2);
}
#endif /* __loongarch_lp64 */

#endif /* __loongarch_grlen */

(BTW I'm pretty sure the casts for arguments are not needed; the casts
for the return value may be needed to suppress -Wconversion if
__builtin_loongarch_crc_w_d_w does not return an int, but why not change
__builtin_loongarch_crc_w_d_w to return int then?)

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

Reply via email to