[1/6] MIPSr6/math: Use builtin fma and fmaf

Message ID 20240513081429.1749898-2-syq@gcc.gnu.org
State New
Headers
Series MIPS: Improve math |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Testing passed
redhat-pt-bot/TryBot-still_applies warning Patch no longer applies to master

Commit Message

YunQiang Su May 13, 2024, 8:14 a.m. UTC
  MIPSr6 has MADDF.s/MADDF.d instructions, which are fused.

In MIPS ISA, double support can be subsetted.  Only FMAF is enabled
for this case.

	* sysdeps/mips/fpu/math-use-builtins-fma.h

Signed-off-by: YunQiang Su <syq@gcc.gnu.org>
---
 sysdeps/mips/fpu/math-use-builtins-fma.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644 sysdeps/mips/fpu/math-use-builtins-fma.h
  

Comments

Adhemerval Zanella Netto May 22, 2024, 1:42 p.m. UTC | #1
On 13/05/24 05:14, YunQiang Su wrote:
> MIPSr6 has MADDF.s/MADDF.d instructions, which are fused.
> 
> In MIPS ISA, double support can be subsetted.  Only FMAF is enabled
> for this case.
> 
> 	* sysdeps/mips/fpu/math-use-builtins-fma.h
> 
> Signed-off-by: YunQiang Su <syq@gcc.gnu.org>
> ---
>  sysdeps/mips/fpu/math-use-builtins-fma.h | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>  create mode 100644 sysdeps/mips/fpu/math-use-builtins-fma.h
> 
> diff --git a/sysdeps/mips/fpu/math-use-builtins-fma.h b/sysdeps/mips/fpu/math-use-builtins-fma.h
> new file mode 100644
> index 0000000000..6e296fd4c0
> --- /dev/null
> +++ b/sysdeps/mips/fpu/math-use-builtins-fma.h
> @@ -0,0 +1,13 @@
> +#if __mips_isa_rev >= 6
> +#  if defined(__mips_single_float)

Usually for a single case we write as '#ifdef __mips_single_float,
also the identation is a single space.

The rest look ok, gcc seems to emit the the MADDF.X even with
pretty old versions (gcc 5.5.0).

> +#    define USE_FMA_BUILTIN 0
> +#  else
> +#    define USE_FMA_BUILTIN 1
> +#  endif
> +#  define USE_FMAF_BUILTIN 1
> +#else
> +#  define USE_FMA_BUILTIN 0
> +#  define USE_FMAF_BUILTIN 0
> +#endif
> +#define USE_FMAL_BUILTIN 0
> +#define USE_FMAF128_BUILTIN 0
  
YunQiang Su May 25, 2024, 11:55 a.m. UTC | #2
Adhemerval Zanella Netto <adhemerval.zanella@linaro.org> 于2024年5月22日周三 21:42写道:
>
>
>
> On 13/05/24 05:14, YunQiang Su wrote:
> > MIPSr6 has MADDF.s/MADDF.d instructions, which are fused.
> >
> > In MIPS ISA, double support can be subsetted.  Only FMAF is enabled
> > for this case.
> >
> >       * sysdeps/mips/fpu/math-use-builtins-fma.h
> >
> > Signed-off-by: YunQiang Su <syq@gcc.gnu.org>
> > ---
> >  sysdeps/mips/fpu/math-use-builtins-fma.h | 13 +++++++++++++
> >  1 file changed, 13 insertions(+)
> >  create mode 100644 sysdeps/mips/fpu/math-use-builtins-fma.h
> >
> > diff --git a/sysdeps/mips/fpu/math-use-builtins-fma.h b/sysdeps/mips/fpu/math-use-builtins-fma.h
> > new file mode 100644
> > index 0000000000..6e296fd4c0
> > --- /dev/null
> > +++ b/sysdeps/mips/fpu/math-use-builtins-fma.h
> > @@ -0,0 +1,13 @@
> > +#if __mips_isa_rev >= 6
> > +#  if defined(__mips_single_float)
>
> Usually for a single case we write as '#ifdef __mips_single_float,
> also the identation is a single space.
>

In fact I sent V2, can you have a look at it?
https://sourceware.org/pipermail/libc-alpha/2024-May/156668.html

> The rest look ok, gcc seems to emit the the MADDF.X even with
> pretty old versions (gcc 5.5.0).
>
> > +#    define USE_FMA_BUILTIN 0
> > +#  else
> > +#    define USE_FMA_BUILTIN 1
> > +#  endif
> > +#  define USE_FMAF_BUILTIN 1
> > +#else
> > +#  define USE_FMA_BUILTIN 0
> > +#  define USE_FMAF_BUILTIN 0
> > +#endif
> > +#define USE_FMAL_BUILTIN 0
> > +#define USE_FMAF128_BUILTIN 0
  
YunQiang Su May 31, 2024, 3:53 p.m. UTC | #3
@Adhemerval Zanella can you help to merge it if the V2 is OK?
  

Patch

diff --git a/sysdeps/mips/fpu/math-use-builtins-fma.h b/sysdeps/mips/fpu/math-use-builtins-fma.h
new file mode 100644
index 0000000000..6e296fd4c0
--- /dev/null
+++ b/sysdeps/mips/fpu/math-use-builtins-fma.h
@@ -0,0 +1,13 @@ 
+#if __mips_isa_rev >= 6
+#  if defined(__mips_single_float)
+#    define USE_FMA_BUILTIN 0
+#  else
+#    define USE_FMA_BUILTIN 1
+#  endif
+#  define USE_FMAF_BUILTIN 1
+#else
+#  define USE_FMA_BUILTIN 0
+#  define USE_FMAF_BUILTIN 0
+#endif
+#define USE_FMAL_BUILTIN 0
+#define USE_FMAF128_BUILTIN 0