diff mbox series

libsupc++: Fix handling of m68k extended real in <compare>

Message ID mvmed6277ir.fsf@suse.de
State New
Headers show
Series libsupc++: Fix handling of m68k extended real in <compare> | expand

Commit Message

Andreas Schwab Sept. 2, 2024, 9:02 a.m. UTC
PR libstdc++/116513
	* libsupc++/compare (_S_fp_bits) [__fmt == _M68k_80bit]: Shift
	padding out of exponent word.
---
 libstdc++-v3/libsupc++/compare | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Jonathan Wakely Sept. 2, 2024, 9:39 a.m. UTC | #1
On Mon, 2 Sept 2024 at 10:02, Andreas Schwab wrote:
>
>         PR libstdc++/116513
>         * libsupc++/compare (_S_fp_bits) [__fmt == _M68k_80bit]: Shift
>         padding out of exponent word.

OK for trunk.

The code is present since GCC 12.1 so it's your call as target
maintainer which branches you want to backport it to. I'm happy for
you to backport it all the way back to gcc-12 if you want.


> ---
>  libstdc++-v3/libsupc++/compare | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/libstdc++-v3/libsupc++/compare b/libstdc++-v3/libsupc++/compare
> index 686aa6d218f..63ad6b5c23e 100644
> --- a/libstdc++-v3/libsupc++/compare
> +++ b/libstdc++-v3/libsupc++/compare
> @@ -838,7 +838,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
>               using enum _Fp_fmt;
>  #endif
>               constexpr auto __fmt = _S_fp_fmt<_Tp>();
> -             if constexpr (__fmt == _X86_80bit || __fmt == _M68k_80bit)
> +             if constexpr (__fmt == _X86_80bit)
>                 {
>                   if constexpr (sizeof(_Tp) == 3 * sizeof(int32_t))
>                     {
> @@ -851,6 +851,11 @@ namespace std _GLIBCXX_VISIBILITY(default)
>                       return _Int<int16_t>(__ival._M_hi, __ival._M_lo);
>                     }
>                 }
> +             else if constexpr (__fmt == _M68k_80bit)
> +               {
> +                 auto __ival = __builtin_bit_cast(_Int<int32_t>, __val);
> +                 return _Int<int16_t>(__ival._M_hi >> 16, __ival._M_lo);
> +               }
>               else if constexpr (sizeof(_Tp) == 2 * sizeof(int64_t))
>                 {
>  #if __SIZEOF_INT128__
> --
> 2.46.0
>
>
> --
> Andreas Schwab, SUSE Labs, schwab@suse.de
> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
> "And now for something completely different."
>
diff mbox series

Patch

diff --git a/libstdc++-v3/libsupc++/compare b/libstdc++-v3/libsupc++/compare
index 686aa6d218f..63ad6b5c23e 100644
--- a/libstdc++-v3/libsupc++/compare
+++ b/libstdc++-v3/libsupc++/compare
@@ -838,7 +838,7 @@  namespace std _GLIBCXX_VISIBILITY(default)
 	      using enum _Fp_fmt;
 #endif
 	      constexpr auto __fmt = _S_fp_fmt<_Tp>();
-	      if constexpr (__fmt == _X86_80bit || __fmt == _M68k_80bit)
+	      if constexpr (__fmt == _X86_80bit)
 		{
 		  if constexpr (sizeof(_Tp) == 3 * sizeof(int32_t))
 		    {
@@ -851,6 +851,11 @@  namespace std _GLIBCXX_VISIBILITY(default)
 		      return _Int<int16_t>(__ival._M_hi, __ival._M_lo);
 		    }
 		}
+	      else if constexpr (__fmt == _M68k_80bit)
+		{
+		  auto __ival = __builtin_bit_cast(_Int<int32_t>, __val);
+		  return _Int<int16_t>(__ival._M_hi >> 16, __ival._M_lo);
+		}
 	      else if constexpr (sizeof(_Tp) == 2 * sizeof(int64_t))
 		{
 #if __SIZEOF_INT128__