From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 2EBC6385696F for ; Mon, 31 Oct 2022 10:17:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2EBC6385696F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667211428; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=VDqhmSVgGHOR/2MwwgZsPmGnkAKmbF9WjsuQwg3lt1w=; b=bCr4sNcETp7Pzixv002E7oKPuBnGXpZX0weqtaccLzivZY5YitBlGHAjWkXzJ3ubQq3gBf YJF1Eg77qU208VNQsdYW891wHeye6MQSsT1+oc412jovWE5xsc7uKTeklgp9prlKz+sKMX 1m+KsDsLNLJwTCccY+JUtuB/RGh+S58= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-259-QidVTM3XPRKsSZ9TVPfkkw-1; Mon, 31 Oct 2022 06:17:07 -0400 X-MC-Unique: QidVTM3XPRKsSZ9TVPfkkw-1 Received: by mail-ej1-f69.google.com with SMTP id xj11-20020a170906db0b00b0077b6ecb23fcso5572704ejb.5 for ; Mon, 31 Oct 2022 03:17:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VDqhmSVgGHOR/2MwwgZsPmGnkAKmbF9WjsuQwg3lt1w=; b=czOvH39lfeYLJCCxx7iSK/7F6Q2DyRq5gpVxqYennTXl90Bm8HuIqab81szIOxhj4V 9fmsjd2997/cQ33KBeswpChgs16WoI8jW4ub0D3DTveEsUu3Ms6BlbkUYfZCKho9ekW9 kOVMZnH48Y3BU/85mhkmfwWe4a/2i8wGskfcGxc9gtv6bBjfmHOV+ttJgCv6G7W0wE9v /OGWx5GQ63NdnYe2GgINvVhcNbyFfd69O5U0Sx9eiDoCrxvtBViwdNsZVH/QwjD643RT uj+6nElCJz2RoI9SkH9sb8e4u2cG9QTsQYCdendXr/HC4HtaYc2/n+biJ3XAipLNJifB 0Kgw== X-Gm-Message-State: ACrzQf1oMaTr7aEYhx3dy81bjqhRXcL3ieNDgf64JRg98TUHMpYCM9WO fuw1YfrWL4AmZyHKPU/n0ev6LPpD3j6N+wr+xW2Y/1ml73kOo9m7vT2MZTZ2IXs3mngv0USnuPh Xo492XNq9iDrqTq9kvMB1tJPqOfmukaDZOQ== X-Received: by 2002:a17:907:7e9a:b0:796:7a21:1520 with SMTP id qb26-20020a1709077e9a00b007967a211520mr12280813ejc.236.1667211426455; Mon, 31 Oct 2022 03:17:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6G80OnTIq7j/DzCemsF6t1w+jk/QUmVF9oFiqe2D6hWkEreW9q+GsbvAznXH5E43xcuCIYqRF1kYXPGbDENE4= X-Received: by 2002:a17:907:7e9a:b0:796:7a21:1520 with SMTP id qb26-20020a1709077e9a00b007967a211520mr12280784ejc.236.1667211426100; Mon, 31 Oct 2022 03:17:06 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Mon, 31 Oct 2022 10:16:54 +0000 Message-ID: Subject: Re: [PATCH] libstdc++: Small extended float support tweaks To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Fri, 21 Oct 2022 at 08:29, Jakub Jelinek wrote: > > Hi! > > The following patch isn't for immediate commit, as it has several > dependencies, in particular: > https://gcc.gnu.org/pipermail/gcc-patches/2022-October/603665.html > https://gcc.gnu.org/pipermail/gcc-patches/2022-October/604080.html > https://gcc.gnu.org/pipermail/libstdc++/2022-October/054849.html > On top of those, this patch > 1) enables the std::float128_t overloads for x86 with glibc 2.26+ > 2) makes std::nextafter(std::float16_t, std::float16_t) and > std::nextafter(std::bfloat16_t, std::bfloat16_t) constexpr > 3) adds (small) testsuite coverage for that > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk > if/when the above dependencies are in? Yes, thanks. > > 2022-10-21 Jakub Jelinek > > * config/os/gnu-linux/os_defines.h (_GLIBCXX_HAVE_FLOAT128_MATH): > Uncomment. > * include/c_global/cmath (nextafter(_Float16, _Float16)): Make it constexpr. > If std::__is_constant_evaluated() call __builtin_nextafterf16. > (nextafter(__gnu_cxx::__bfloat16_t, __gnu_cxx::__bfloat16_t): Similarly > but call __builtin_nextafterf16b. > * testsuite/26_numerics/headers/cmath/nextafter_c++23.cc (test): Add > static assertions to test constexpr nextafter. > > --- libstdc++-v3/config/os/gnu-linux/os_defines.h.jj 2022-10-18 11:35:55.514865483 +0200 > +++ libstdc++-v3/config/os/gnu-linux/os_defines.h 2022-10-20 16:57:59.715681664 +0200 > @@ -57,7 +57,7 @@ > || (defined(__powerpc__) && defined(_ARCH_PWR8) \ > && defined(__LITTLE_ENDIAN__) && (_CALL_ELF == 2) \ > && defined(__FLOAT128__))) > -//# define _GLIBCXX_HAVE_FLOAT128_MATH 1 > +# define _GLIBCXX_HAVE_FLOAT128_MATH 1 > #endif > > #if __GLIBC_PREREQ(2, 27) > --- libstdc++-v3/include/c_global/cmath.jj 2022-10-19 11:23:51.484488161 +0200 > +++ libstdc++-v3/include/c_global/cmath 2022-10-20 17:03:56.760805581 +0200 > @@ -2755,9 +2755,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > nearbyint(_Float16 __x) > { return _Float16(__builtin_nearbyintf(__x)); } > > - inline _Float16 > + constexpr _Float16 > nextafter(_Float16 __x, _Float16 __y) > { > + if (std::__is_constant_evaluated()) > + return __builtin_nextafterf16(__x, __y); > #ifdef __INT16_TYPE__ > using __float16_int_type = __INT16_TYPE__; > #else > @@ -3471,9 +3473,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > nearbyint(__gnu_cxx::__bfloat16_t __x) > { return __gnu_cxx::__bfloat16_t(__builtin_nearbyintf(__x)); } > > - inline __gnu_cxx::__bfloat16_t > + constexpr __gnu_cxx::__bfloat16_t > nextafter(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y) > { > + if (std::__is_constant_evaluated()) > + return __builtin_nextafterf16b(__x, __y); > #ifdef __INT16_TYPE__ > using __bfloat16_int_type = __INT16_TYPE__; > #else > --- libstdc++-v3/testsuite/26_numerics/headers/cmath/nextafter_c++23.cc.jj 2022-10-20 16:57:29.940088318 +0200 > +++ libstdc++-v3/testsuite/26_numerics/headers/cmath/nextafter_c++23.cc 2022-10-20 17:19:40.141923257 +0200 > @@ -100,6 +100,8 @@ test () > VERIFY( std::fpclassify(t36) == FP_NAN ); > T t37 = std::nextafter(T(-0.0), T()); > VERIFY( t37 == T() && !std::signbit(t37) ); > + static_assert(std::nextafter(T(1.0), T(2.0)) > T(1.0)); > + static_assert(std::nextafter(std::nextafter(T(1.0), T(5.0)), T(0.0)) == T(1.0)); > } > > int > > Jakub >