From patchwork Sat Feb 10 09:55:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1897333 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=hMoI6EDR; 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 4TX5hL5wswz23hc for ; Sat, 10 Feb 2024 20:56:02 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9183D3858C2A for ; Sat, 10 Feb 2024 09:56:00 +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.129.124]) by sourceware.org (Postfix) with ESMTPS id E41DF3858D32 for ; Sat, 10 Feb 2024 09:55:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E41DF3858D32 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 E41DF3858D32 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707558944; cv=none; b=tA2KZ1+wcd32QDmJ02wY5DawkP3CEQKBMmdkKuaY39q+N6e80ZXl4bmt/sxV3khn/P8wY7O1+nLaMJ1UX1Oc4cFvao6pqoXz6U9Gt8ta7AU5SCdJv3SwVpfrZK8SEoyIHKh5QoPxidUTlDGduyH9uXYn5Uw7zbivvkLlDxuQo3k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707558944; c=relaxed/simple; bh=i6gTaKgYoyrq7/FK+6lRMO4SGQBc8PX2AficJDzYM24=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=m0IRtFyzA8z7Grpw+ptPOlDYTIgcTXZ1JlRUahWVhStwAEAuSbvy0oYhSBm5g0pyb9/7rzbWSzIgqE08f/Zyruq64Z3HAZ1eyNdOU7+IppomSglnSfw3mSUmRAIAJgNupLI0GdhxLIwQ9fYSI6xxpB6++GLuceQwzZsZgU7uiVM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707558942; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=I6g1Pymm/EIUae4Y7ZbeuBK4ZuZ84+GOMj74bbA+kTs=; b=hMoI6EDRbq+UZtIh3FBzqhKedcZSbtNsGCL+i/cyUlbR+eHyxPqqUuBZpLtX2n927+KDsq Q8Y21saDVtVU86b2GdyFhKnBTgCM0UcKnPhXYt52/I2G7+pOP0s+SVtz7YEczfJfPQiLL7 lpSCP3own/lWJldLn5FQqaSQ7MWkPQ4= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-661-ow1bLxnsPd24kqwwLtecVA-1; Sat, 10 Feb 2024 04:55:41 -0500 X-MC-Unique: ow1bLxnsPd24kqwwLtecVA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 B0B903C0F1A9; Sat, 10 Feb 2024 09:55:40 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 61F4C492BC6; Sat, 10 Feb 2024 09:55:40 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 41A9tY5c4023473 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 10 Feb 2024 10:55:35 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 41A9tXa84023472; Sat, 10 Feb 2024 10:55:33 +0100 Date: Sat, 10 Feb 2024 10:55:33 +0100 From: Jakub Jelinek To: Richard Biener , "Joseph S. Myers" Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] libgcc: Fix a bug in _BitInt -> dfp conversions Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Hi! The ia32 _BitInt support revealed a bug in floatbitint?d.c. As can be even guessed from how the code is written in the loop, the intention was to set inexact to non-zero whenever the remainder after division wasn't zero, but I've ended up just checking whether the 2 least significant limbs of the remainder were non-zero. Now, in the dfp/bitint-4.c test in one case the remainder happens to have least significant 64 bits zero and then the higher limbs are non-zero; with 32-bit limbs that means 2 least significant limbs are zero and so the code acted as if it was exactly divisible. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux (including the _BitInt enablement there), ok for trunk? 2024-02-10 Jakub Jelinek * soft-fp/floatbitintdd.c (__bid_floatbitintdd): Or in all remainder limbs into inexact rather than just first two. * soft-fp/floatbitintsd.c (__bid_floatbitintsd): Likewise. * soft-fp/floatbitinttd.c (__bid_floatbitinttd): Likewise. Jakub --- libgcc/soft-fp/floatbitintdd.c.jj 2024-02-09 17:11:47.095675716 +0100 +++ libgcc/soft-fp/floatbitintdd.c 2024-02-09 18:22:25.786674139 +0100 @@ -114,7 +114,7 @@ __bid_floatbitintdd (const UBILtype *i, buf + BITINT_END (q_limbs - 1, 0), q_limbs); inexact = buf[q_limbs + pow10_limbs]; for (j = 1; j < pow10_limbs; ++j) - inexact |= buf[q_limbs + pow10_limbs + 1]; + inexact |= buf[q_limbs + pow10_limbs + j]; } else { --- libgcc/soft-fp/floatbitintsd.c.jj 2023-09-06 17:34:04.978510447 +0200 +++ libgcc/soft-fp/floatbitintsd.c 2024-02-09 18:21:50.949158569 +0100 @@ -113,7 +113,7 @@ __bid_floatbitintsd (const UBILtype *i, buf + BITINT_END (q_limbs - 1, 0), q_limbs); inexact = buf[q_limbs + pow10_limbs]; for (j = 1; j < pow10_limbs; ++j) - inexact |= buf[q_limbs + pow10_limbs + 1]; + inexact |= buf[q_limbs + pow10_limbs + j]; } else { --- libgcc/soft-fp/floatbitinttd.c.jj 2024-02-09 17:14:17.485578556 +0100 +++ libgcc/soft-fp/floatbitinttd.c 2024-02-09 18:21:34.409388566 +0100 @@ -113,7 +113,7 @@ __bid_floatbitinttd (const UBILtype *i, buf + BITINT_END (q_limbs - 1, 0), q_limbs); inexact = buf[q_limbs + pow10_limbs]; for (j = 1; j < pow10_limbs; ++j) - inexact |= buf[q_limbs + pow10_limbs + 1]; + inexact |= buf[q_limbs + pow10_limbs + j]; } else {