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 E32A9385841D for ; Wed, 19 Oct 2022 09:02:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E32A9385841D 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=1666170136; 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=Qz87MdAEVJtFE+jCifXww+bN6RyL2DiTE9V6weUoVAEdiKBccj28DA2xHbjV+28+3Cz/F2 kQEn5Dk/pEZZbDldtUELM3qkpkX1zdx4+AG/366t5qiGUT5s/x2aKaGXqIAdc7oPdTISxu myQB4TOQVtjVsuIs6GwkjIbGpmZ6HWM= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-137-sROydPPmPyyyB2TGAAEnmg-1; Wed, 19 Oct 2022 05:02:13 -0400 X-MC-Unique: sROydPPmPyyyB2TGAAEnmg-1 Received: by mail-qt1-f197.google.com with SMTP id a19-20020a05622a02d300b0039a3711179dso12323604qtx.12 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=QfmSdz4M/hVZCIWseHzEs5PjnaM1DXhIuZCWOtEECMk0fDGZowSZPC1+1dw/ob9qR1 8iveUgKZdCi0D1K0lrUmhGgS42XNNrzBucwMJGWO2v7Ut4XkE3l6Y3bIlqF99HXlZVqm HOi++xR1mBQOQl3w6QKceP1yxY1N/8Lswf+l2ie2w7hF1GWXgJ2V3047qXruZFLsdG1+ qaNr4dw9c0WmXvdmY8f1I4Q1iHtSw3BBd3NLUJWPUziU20YM3W3W89NP2j3z1keKSlJv YTLmkBnNOwIukqHTJ4Ow/cUmG+OGqG33o+fTCY49NvT3ecOS7BVG+8MCJs2K7G5OMyEe NvkQ== X-Gm-Message-State: ACrzQf1dMtbxujSX7fp8NJDkhDVoNG8XObPqsRcXYvPurZKC/WrbMwQc LTAE06x1g0So6Zn0J3YV2ZzCnC7eld7Y2pSyp2eM76MZwq5lgy5qUkIKnkeJHkS7Cf5nqP4r9Li 1m6kVFjtb3+cob4C4aIifXhySIZ1sxYDwEQ== X-Received: by 2002:a05:620a:13f2:b0:6ec:597f:eda6 with SMTP id h18-20020a05620a13f200b006ec597feda6mr4734350qkl.287.1666170132972; 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.6 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 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.