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 084773857BAB for ; Wed, 19 Oct 2022 09:02:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 084773857BAB 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=1666170134; 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=PFds5o+xHtLA3Ubcl4yHknybl3uOEnVZBuXAV/ft7EE=; b=YVWe7UemZVZYQhjaLrc4XpL2innRQ9p/QcVjC0KUcupzyDqWFG90UbJZOkpAbG+iHVS37W IxasViH1Ita/2Yj8ylQ4Un/eM3h4FrymW//6jlLH8jFI274rR1dauDMSCOi6qfA/x2TEn6 up+IdSox4IIWZ/bcf/bdnDPfl/IXnyc= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-137-0u0I6k2ON4y3xe_0O2-BoA-1; Wed, 19 Oct 2022 05:02:13 -0400 X-MC-Unique: 0u0I6k2ON4y3xe_0O2-BoA-1 Received: by mail-qv1-f69.google.com with SMTP id y2-20020a0ce802000000b004b1ce1c4a70so10156120qvn.9 for ; Wed, 19 Oct 2022 02:02:13 -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=PFds5o+xHtLA3Ubcl4yHknybl3uOEnVZBuXAV/ft7EE=; b=tzXry273AVoqS7iUcmczYYzTRT5/nusUZ4rG5dTDnglxAhrju8A9D5KJm05Kz6zFdp VHFLIty6Pb1xtrhB/vlbOtJgXdwDw9cUDgZq5O9hLI7JX/dk7O4c5uCR/Fp3PSRvtWRc MXi85olDyY9jPhRJAhSikWIFaGDDFIWB9YDTBMVlV6um/+1sV3cVa2CfJJ+V3/9hjN6O pmyPCmyNhgP526wj6BmBuLSvUicH8bZ9eQgcyoxSqpTUK/3IKhPZP4AhDq0mOLjz/sqP K6ty4nQxTmywNiit25DH5Exu5fRVHrPHXAUpWx26SZw/B6fasr+f9fiWUu4R99xjbPfD 4sEg== X-Gm-Message-State: ACrzQf0Y8/2uKt8JTYj4QIuwIqGjKkSzWpwceXTIoRA7JUqjm2EEeMBa NH8KPJnHJleNPbeyk0iUuYR334d/0tg8dO/dTvSp5M3XPolVJ73qCqOqF/34HjWmkQHY230IGsF D4292z248vTcOAU2XqvxcxMpg9g23oz8= X-Received: by 2002:a05:620a:13f2:b0:6ec:597f:eda6 with SMTP id h18-20020a05620a13f200b006ec597feda6mr4734349qkl.287.1666170132970; Wed, 19 Oct 2022 02:02:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5JQFWhz7AONR0oNrR0wmG0u7enYXtH+o4DC7Qd499xB8LGkHUHsNH/rtzRJDPjVYC9e8BeUh8YXZ70iy1QUKA= X-Received: by 2002:a05:620a:13f2:b0:6ec:597f:eda6 with SMTP id h18-20020a05620a13f200b006ec597feda6mr4734341qkl.287.1666170132729; Wed, 19 Oct 2022 02:02:12 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Wed, 19 Oct 2022 10:02:01 +0100 Message-ID: Subject: Re: [PATCH] libstdc++-v3: Implement {,b}float16_t nextafter and some fixes [PR106652] 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=-6.5 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=ham 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 Wed, 19 Oct 2022 at 09:23, Jakub Jelinek wrote: > > Hi! > > The following patch implements nextafter for std::{,b}float16_t, > though right now only without constexpr support, and adds a testcase for it. > The testcase unfortunately relevealed I've screwed up testing of my last > patch. I've tested earlier version of the patch with > --target_board=unix/-std=c++23 > but didn't test the final version with that RUNTESTFLAGS, so missed > an invalid call to std::sph_neumann (too many arguments) in the test. > And, I've made a typo in the guard for numeric_limits (the reason > for the guard is I wanted to avoid defining a large macro that nothing > will then use because the std::{,b}float*_t types are C++23 only) and > so numeric_limits wasn't specialized for the types at all but > testsuite/18_support/headers/limits/synopsis_cxx23.cc test didn't > detect that. > In the nextafter implementation I'm calling __builtin_nextafterf > to get various required side-effects for nextafter from 0/-0, or from max > to inf or from min to largest subnormal to avoid needing to set errno > inline, or use inline asm specific for each processor to force math > evaluation barriers. Dunno if > #ifdef __INT16_TYPE__ > using __float16_int_type = __INT16_TYPE__; > #else > using __float16_int_type = short int; > #endif > isn't too ugly, perhaps we could just blindly use short int and hope > or even assert it has the same size as _Float16 or __gnu_cxx::__bfloat16_t? I'm happy with the preprocessor conditions above, but using short int and a static assert would be OK too. > Only aarch64, arm, csky, gcn, x86, nvptx and riscv support these types > and all of them have 16-bit short (I think the only target with some > other short size is avr with certain command line switches where both > short and int are 8-bit, but such mode isn't compatible with C and C++ > requirements). It's not, but we do try to support avr, especially for something like which requires no OS support and has always been required for freestanding. But will it have float16 anyway? I suppose it might do, so maybe the preprocessor dance for __INT16_TYPE__ is better. It's only needed in two places, so isn't too bad. > --- libstdc++-v3/testsuite/26_numerics/headers/cmath/nextafter_c++23.cc.jj 2022-10-18 17:18:32.237061706 +0200 > +++ libstdc++-v3/testsuite/26_numerics/headers/cmath/nextafter_c++23.cc 2022-10-18 18:51:21.465258133 +0200 > @@ -0,0 +1,124 @@ > +// Copyright (C) 2022 Free Software Foundation, Inc. > +// > +// This file is part of the GNU ISO C++ Library. This library is free > +// software; you can redistribute it and/or modify it under the > +// terms of the GNU General Public License as published by the > +// Free Software Foundation; either version 3, or (at your option) > +// any later version. > + > +// This library is distributed in the hope that it will be useful, > +// but WITHOUT ANY WARRANTY; without even the implied warranty of > +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +// GNU General Public License for more details. > + > +// You should have received a copy of the GNU General Public License along > +// with this library; see the file COPYING3. If not see > +// . > + > +// { dg-do run { target c++23 } } This should have { dg-options "-std=gnu++2b" } before the dg-do. OK with that change.