From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 6715A3858CDB for ; Thu, 12 Oct 2023 10:54:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6715A3858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D78A013D5; Thu, 12 Oct 2023 03:54:56 -0700 (PDT) Received: from localhost (unknown [10.32.110.65]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 86DB53F762; Thu, 12 Oct 2023 03:54:15 -0700 (PDT) From: Richard Sandiford To: Jakub Jelinek Mail-Followup-To: Jakub Jelinek ,Richard Biener , gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Cc: Richard Biener , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] wide-int: Allow up to 16320 bits wide_int and change widest_int precision to 32640 bits [PR102989] References: Date: Thu, 12 Oct 2023 11:54:14 +0100 In-Reply-To: (Jakub Jelinek's message of "Wed, 11 Oct 2023 18:47:39 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-18.2 required=5.0 tests=BAYES_00,KAM_DMARC_NONE,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Jakub Jelinek writes: > @@ -2036,11 +2075,20 @@ wi::lrshift_large (HOST_WIDE_INT *val, c > unsigned int xlen, unsigned int xprecision, > unsigned int precision, unsigned int shift) > { > - unsigned int len = rshift_large_common (val, xval, xlen, xprecision, shift); > + /* Work out how many blocks are needed to store the significant bits > + (excluding the upper zeros or signs). */ > + unsigned int blocks_needed = BLOCKS_NEEDED (xprecision - shift); > + unsigned int len = blocks_needed; > + if (UNLIKELY (len > WIDE_INT_MAX_INL_ELTS) > + && len > xlen > + && xval[xlen - 1] >= 0) > + len = xlen; I think here too it would be worth dropping the: UNLIKELY (len > WIDE_INT_MAX_INL_ELTS) part of the condition, since presumably the change should be safe regardless of that. > + > + rshift_large_common (val, xval, xlen, shift, len); > > /* The value we just created has precision XPRECISION - SHIFT. > Zero-extend it to wider precisions. */ > - if (precision > xprecision - shift) > + if (precision > xprecision - shift && len == blocks_needed) > { > unsigned int small_prec = (xprecision - shift) % HOST_BITS_PER_WIDE_INT; > if (small_prec) > @@ -2063,11 +2111,18 @@ wi::arshift_large (HOST_WIDE_INT *val, c > unsigned int xlen, unsigned int xprecision, > unsigned int precision, unsigned int shift) > { > - unsigned int len = rshift_large_common (val, xval, xlen, xprecision, shift); > + /* Work out how many blocks are needed to store the significant bits > + (excluding the upper zeros or signs). */ > + unsigned int blocks_needed = BLOCKS_NEEDED (xprecision - shift); > + unsigned int len = blocks_needed; > + if (UNLIKELY (len > WIDE_INT_MAX_INL_ELTS) && len > xlen) > + len = xlen; > + Same here. OK for thw wide-int parts with those changes. Thanks, Richard