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 1C20A3858C41 for ; Fri, 15 Mar 2024 17:05:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1C20A3858C41 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 1C20A3858C41 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=1710522368; cv=none; b=wO0NP6A2FqxIVS+dNl8KZ7MZpvgJ41zZKB/6Gm+TIWfkMKhEUy/pl+8WSLg7i6crZWI6HRXwSAv3s3GMJCFhvfnv8kQ0LH21H6Pf9yKwThq0/xNvWAatBaFQwsjGNcb6HEURehso9iGbYVMmUreaYUuK9QdkL/5F2kiumPzuYVM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710522368; c=relaxed/simple; bh=+9rdVrRvmNxyu4aYhSB2gRUyWa6qy9MndPpUEre09KQ=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=f/eg62kSzHExyILZduKmRQ7YQoMfXQ+0plc40Wvb2jY8I/yNv7MXGlayZA97aMtnZIW8RNg2Y+ehsradZoWKOFHUVIzU9xd0KvR/gTH8CI3tKoW2Z1hFRgiDETiWqfuSqG6uDbyJJAcubmXA4wuzfbiU5Yzwj4yI3fMUQiUpEc0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710522357; 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=ITfT8GRaDZii+KUDjo2Tkcn2qqCqqHy2KIt2VLnSDiY=; b=QopXCqgTunC6fkc1KDuK53M34Vqws1uT/zT+nfYjaRzK7XVjpUxhlCEjXLJQzhjhEHg2zI 1p369o2FTMTNLeV5z4hkERi1z2i0M9bXlBtVPJr0UDBIcYeakEfdKW3PDPoQYJlQIiqtl6 84BqCM19UBsmdIBvu0Ik5R099Rav7uc= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-459-KHRe7sEnNk6MiWswhNxsiA-1; Fri, 15 Mar 2024 13:05:55 -0400 X-MC-Unique: KHRe7sEnNk6MiWswhNxsiA-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4140408c7faso2322635e9.1 for ; Fri, 15 Mar 2024 10:05:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710522354; x=1711127154; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ITfT8GRaDZii+KUDjo2Tkcn2qqCqqHy2KIt2VLnSDiY=; b=aWbGX8kZMG9pzNSbuZX3fD+f+RBWA6yXKEJ7Tlg3UbFMhYk5J4Gc2Y1ikZJCKxpMf6 UDv+jDAkKpTmHA5M+cLTasV52So9nzv8IGRxRroGhELYLfDYTL6iJXqx0wRr71hpP1lq k12O7zWCkHjMyEOVkwNHgAK+YnRWDfumx6DOfdnC/zUURVe5AyelOhM5IUBbVCQoQTC/ yEynKHdeogkHtZekYb4iXduKfF7EAP1g6fZchX92aFjonqGJxrhnKIb144ed3+E054QF +lGNWg1DrSM+Ze6z2MIB7fdTV7U6sZNhWXu8gCUI/Bxh9RDKBTQCSJ9VxHmv550Uy7Ti B8Cg== X-Forwarded-Encrypted: i=1; AJvYcCVTZH5V7knwG0aEna2rF/LfK3mykuxyUojeSXWVcCgMKWvgpwYWRQPtPdgchybw9Ow3Gjc5pB5TRenkHckO92BpjRp0+NN9tw== X-Gm-Message-State: AOJu0Yy9Ys/+mWjmBjR3QDvN7cWbCozCDO1g14xkC8pZel45wDpqry0w k5+efeNI51eDFcEpQa6b3d7gKZqhnRNDyQGzQ7yoRYgxyXmowr/+TTJlvUT+Lz3FrnOSVhHohEu YPasuzA5fUmPGGJWgbbp+oH3ukx31d0xT1Cz4JfZAUBA5KN9Rd6qPuQ8= X-Received: by 2002:a05:600c:b86:b0:412:e0a2:5b72 with SMTP id fl6-20020a05600c0b8600b00412e0a25b72mr4087247wmb.29.1710522353868; Fri, 15 Mar 2024 10:05:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGTBiLm0t9v+FGVEk4a74B2VTu47IWtk47IaAVr+UUhhy/1eqNmoDmkpcFzjVEQZm316Y5wCA== X-Received: by 2002:a05:600c:b86:b0:412:e0a2:5b72 with SMTP id fl6-20020a05600c0b8600b00412e0a25b72mr4087238wmb.29.1710522353511; Fri, 15 Mar 2024 10:05:53 -0700 (PDT) Received: from digraph.polyomino.org.uk (digraph.polyomino.org.uk. [2001:8b0:bf73:93f7::51bb:e332]) by smtp.gmail.com with ESMTPSA id fm23-20020a05600c0c1700b00413e4cf0c42sm9395706wmb.25.2024.03.15.10.05.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 10:05:53 -0700 (PDT) Received: from jsm28 (helo=localhost) by digraph.polyomino.org.uk with local-esmtp (Exim 4.95) (envelope-from ) id 1rlAzW-001vnz-6w; Fri, 15 Mar 2024 17:05:10 +0000 Date: Fri, 15 Mar 2024 17:05:10 +0000 (UTC) From: Joseph Myers To: Jakub Jelinek cc: Richard Biener , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] libgcc: Fix quotient and/or remainder negation in __divmodbitint4 [PR114327] In-Reply-To: Message-ID: <735c4854-c957-20d1-ff39-c447830831a@redhat.com> References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII 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_H4,RCVD_IN_MSPIKE_WL,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 List-Id: On Fri, 15 Mar 2024, Jakub Jelinek wrote: > Hi! > > While for __mulbitint3 we actually don't negate anything and perform the > multiplication in unsigned style always, for __divmodbitint4 if the operands > aren't unsigned and are negative, we negate them first and then try to > negate them as needed at the end. > quotient is negated if just one of the operands was negated and the other > wasn't or vice versa, and remainder is negated if the first operand was > negated. > The case which doesn't work correctly is if due to limited range of the > operands we perform the division/modulo in some smaller number of limbs > and then extend it to the desired precision of the quotient and/or > remainder results. If they aren't negated, the extension is done with > memset to 0, if they are negated, the extension was done with memset > to -1. The problem is that if the quotient or remainder is zero, > then bitint_negate negates it again to zero (that is ok), but we should > then extend with memset to 0, not memset to -1. > > The following patch achieves that by letting bitint_negate also check if > the negated operand is zero and changes the memset argument based on that. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? OK. -- Joseph S. Myers josmyers@redhat.com