On Wed, 27 Aug 2025 at 15:53, Tomasz Kamiński <tkami...@redhat.com> wrote:
>
> The patch r16-3414-gfcb3009a32dc33 changed the representation of unordered to
> optimize reversing of order, but it did not update implementation of reversing
> operator<=>(0, partial_order).
>
> libstdc++-v3/ChangeLog:
>
>         * libsupc++/compare
>         (operator<=>(__cmp_cat::__unspec, partial_ordering)):
>         Implement using _M_reverse.
>
> Signed-off-by: Tomasz Kamiński <tkami...@redhat.com>
> ---
> I have forgotten that we have reverse operation. It is used when
> operator<=> is rewriten by compiler, where b <=> a, becomes 0 <=> (a <=> b),
> so it should have real impact.
>
> Testing on x86_64-linux. OK for trunk?

Oh nice, so we might get better codegen thanks to the new
representation of partial_ordering::unordered.

If we remove the _Ncmp type (as I suggested in the other thread) then
this would need to use _Ord instead of _Ncmp but that's an easy
change.

OK for trunk.

>
>  libstdc++-v3/libsupc++/compare | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/libstdc++-v3/libsupc++/compare b/libstdc++-v3/libsupc++/compare
> index 2624fa9144f..ef0f0376964 100644
> --- a/libstdc++-v3/libsupc++/compare
> +++ b/libstdc++-v3/libsupc++/compare
> @@ -155,12 +155,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
>      [[nodiscard]]
>      friend constexpr partial_ordering
>      operator<=>(__cmp_cat::__unspec, partial_ordering __v) noexcept
> -    {
> -      if (__v._M_value & 1)
> -       return partial_ordering(__cmp_cat::_Ord(-__v._M_value));
> -      else
> -       return __v;
> -    }
> +    { return partial_ordering(__cmp_cat::_Ncmp(__v._M_reverse())); }
>    };
>
>    // valid values' definitions
> --
> 2.50.1
>

Reply via email to