public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.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 [thread overview] Message-ID: <bug-106144-4-AFu7m8mwEc@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-106144-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106144 --- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-10 branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>: https://gcc.gnu.org/g:6e7bf9bc3e51d2d0d0df3d810cb20624594573cf commit r10-11334-g6e7bf9bc3e51d2d0d0df3d810cb20624594573cf Author: Jakub Jelinek <jakub@redhat.com> 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 prec 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 block 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 elt. if (end == prec) would work too, because we have: if (width > prec - start) width = prec - start; unsigned int end = start + width; so end is guaranteed to be end <= prec, dunno what is preferred. 2022-07-01 Jakub Jelinek <jakub@redhat.com> PR middle-end/106144 * wide-int.cc (wi::shifted_mask): If end >= 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)
next prev parent reply other threads:[~2023-05-03 15:18 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-06-30 11:03 [Bug middle-end/106144] New: " aldyh at gcc dot gnu.org 2022-06-30 18:18 ` [Bug middle-end/106144] " jakub at gcc dot gnu.org 2022-06-30 18:50 ` jakub at gcc dot gnu.org 2022-07-01 8:09 ` aldyh at gcc dot gnu.org 2022-07-01 9:19 ` cvs-commit at gcc dot gnu.org 2022-07-30 9:34 ` cvs-commit at gcc dot gnu.org 2022-11-04 8:30 ` cvs-commit at gcc dot gnu.org 2023-05-03 15:18 ` cvs-commit at gcc dot gnu.org [this message] 2023-05-04 7:18 ` jakub at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-106144-4-AFu7m8mwEc@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).