From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6E22B3856DE0; Wed, 3 May 2023 15:18:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6E22B3856DE0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683127128; bh=oPKpPOOHde5nVxAHVQmSU27j/ikUZNgmhuEdNcN7Xu0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=kbeuIOzNFCVztDL4CypBZa2CMofEq4sXAwpB9yIURJVzc9yqVcn8+uhLcuLLH7o6r l0vYkglPA8Y/TwlGZdjG0KVcnHi/r+/Bm7K8hM2anyGOHYqpR5s8NV8chYc45sx0Yk C11fvzcuRf53NHkJSKm+zW33YgElp6Jpjpi/bwF4= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/106144] wide_int shifted_mask() and mask() do not agree Date: Wed, 03 May 2023 15:18:48 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106144 --- Comment #7 from CVS Commits --- The releases/gcc-10 branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:6e7bf9bc3e51d2d0d0df3d810cb20624594573cf commit r10-11334-g6e7bf9bc3e51d2d0d0df3d810cb20624594573cf Author: Jakub Jelinek Date: Fri Jul 1 11:17:41 2022 +0200 wide-int: Fix up wi::shifted_mask [PR106144] As the following self-test testcase shows, wi::shifted_mask sometimes doesn't create canonicalized wide_ints, which then fail to compare equal to canonicalized wide_ints with the same value. In particular, wi::mask (128, false, 128) gives { -1 } with len 1 and p= rec 128, while wi::shifted_mask (0, 128, false, 128) gives { -1, -1 } with len 2 and prec 128. The problem is that the code is written with the assumption that there = are 3 bit blocks (or 2 if start is 0), but doesn't consider the possibility where there are 2 bit blocks (or 1 if start is 0) where the highest blo= ck isn't present. In that case, there is the optional block of negate ? 0= : -1 elts, followed by just one elt (either one from the if (shift) or just negate ? -1 : 0) and the rest is implicit sign-extension. Only if end < prec there is 1 or more bits above it that have different= bit value and so we need to emit all the elts till end and then one more el= t. if (end =3D=3D prec) would work too, because we have: if (width > prec - start) width =3D prec - start; unsigned int end =3D start + width; so end is guaranteed to be end <=3D prec, dunno what is preferred. 2022-07-01 Jakub Jelinek PR middle-end/106144 * wide-int.cc (wi::shifted_mask): If end >=3D prec, return right after emitting element for shift or if shift is 0 first element after start. (wide_int_cc_tests): Add tests for equivalency of wi::mask and wi::shifted_mask with 0 start. (cherry picked from commit e52592073f6df3d7a3acd9f0436dcc32a8b7493d)=