From patchwork Tue May 7 13:49:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1932487 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=WUk8QJh+; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VYfn64sl5z1xnS for ; Tue, 7 May 2024 23:50:50 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BB1FC384AB66 for ; Tue, 7 May 2024 13:50:48 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 968923858288 for ; Tue, 7 May 2024 13:50:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 968923858288 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 968923858288 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715089825; cv=none; b=nwUhusshRL7q/5BuEzDAt5mFw25I708b/R8MLhF0rZNJwy+kcKO3lnDqBZGqhcCZEHGzGx/9SPkGX1Qit2Inini+mne/bd6MyP9hAio/xioPVLQ+PjjvuybWnafEw1XAhLvu/r2B1KFcZqUx6WlfOsVS6jKJ6PJG9RGdb91vjcc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715089825; c=relaxed/simple; bh=RUYvIx18e34fC1WloQMwyjA2utKNneE99v+BpN/hI20=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=eCOAc1qmYyDyzoz2s8RSlymhc5hqVjvG5mSEDgpT74RII9PG748ThMoAG4gxeJ2dkeqEkPBmR2BMTiYnEz6ziwzUDu+rRsExfhlQd/AFhahZYumOOKuXldsLXxYr5E6NeD4BrP3t/LWEAJO4Mj7qu3bjgoxpXhOUfV8MzThY4SA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1715089824; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Fh85eEO0B76I9SK5I9j+U98Ua9wDPHJAwSZ8mWwlUO0=; b=WUk8QJh+4IcTZFFxKFSE37uD1G4fOm5wl2e9Sm70l71PPRDkq+9HxCDuPkrsvQRQafbJMy PLXkZn+03xkm7uDINNmQF9tyAZ2wrfqMAmXDAnY19nThCqIgHLHxmbBvPJyNzYuzc9Hwno 6jOeKVQxFwLZSPdaLEOyHmVMxpIMWO8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-690-16Nam6ZzPx-ZiwtDgPusgA-1; Tue, 07 May 2024 09:50:21 -0400 X-MC-Unique: 16Nam6ZzPx-ZiwtDgPusgA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 13FE48015D7; Tue, 7 May 2024 13:50:21 +0000 (UTC) Received: from localhost (unknown [10.42.28.238]) by smtp.corp.redhat.com (Postfix) with ESMTP id C4349492CAB; Tue, 7 May 2024 13:50:20 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH][risc-v] libstdc++: Preserve signbit of nan when converting float to double [PR113578] Date: Tue, 7 May 2024 14:49:33 +0100 Message-ID: <20240507135019.3821031-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Do we want this change for RISC-V, to fix PR113578? I haven't tested it on RISC-V, only on x86_64-linux (where it doesn't do anything). -- >8 -- libstdc++-v3/ChangeLog: PR libstdc++/113578 * include/std/ostream (operator<<(basic_ostream&, float)): Restore signbit after converting to double. Reviewed-by: Palmer Dabbelt Acked-by: Palmer Dabbelt --- libstdc++-v3/include/std/ostream | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libstdc++-v3/include/std/ostream b/libstdc++-v3/include/std/ostream index 8a21758d0a3..d492168ca0e 100644 --- a/libstdc++-v3/include/std/ostream +++ b/libstdc++-v3/include/std/ostream @@ -233,7 +233,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 117. basic_ostream uses nonexistent num_put member functions. +#ifdef __riscv + return _M_insert(__builtin_copysign((double)__f, + (double)-__builtin_signbit(__f)); +#else return _M_insert(static_cast(__f)); +#endif } __ostream_type&