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 tree-optimization/97764] [10/11 Regression] wrong code at -O1 and above on x86_64-pc-linux-gnu since r10-6809 Date: Tue, 10 Nov 2020 10:18:45 +0000 [thread overview] Message-ID: <bug-97764-4-VOP72C2rPm@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-97764-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97764 --- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>: https://gcc.gnu.org/g:c69325a5db450dbac198f76f1162734af05a1061 commit r11-4867-gc69325a5db450dbac198f76f1162734af05a1061 Author: Jakub Jelinek <jakub@redhat.com> Date: Tue Nov 10 11:17:46 2020 +0100 sccvn: Fix up push_partial_def little-endian bitfield handling [PR97764] This patch fixes a thinko in the left-endian push_partial_def path. As the testcase shows, we have 3 bitfields in the struct, bitoff bitsize 0 3 3 28 31 1 the corresponding read is the byte at offset 3 (i.e. 24 bits) and push_partial_def first handles the full store ({}) to all bits and then is processing the store to the middle bitfield with value of -1. Here are the interesting spots: pd.offset -= offseti; this adjusts the pd to { -21, 28 }, the (for little-endian lowest) 21 bits aren't interesting to us, we only care about the upper 7. len = native_encode_expr (pd.rhs, this_buffer, bufsize, MAX (0, -pd.offset) / BITS_PER_UNIT); native_encode_expr has the offset parameter in bytes and we tell it that we aren't interested in the first (lowest) two bytes of the number. It encodes 0xff, 0xff with len == 2 then. HOST_WIDE_INT size = pd.size; if (pd.offset < 0) size -= ROUND_DOWN (-pd.offset, BITS_PER_UNIT); we get 28 - 16, i.e. 12 - the 16 is subtracting those 2 bytes that we omitted in native_encode_expr. size = MIN (size, (HOST_WIDE_INT) needed_len * BITS_PER_UNIT); needed_len is how many bytes the read at most needs, and that is 1, so we get size 8 and copy all 8 bits (i.e. a single byte plus nothing) from the native_encode_expr filled this_buffer; this incorrectly sets the byte to 0xff when we want 0x7f. The above line is correct for the pd.offset >= 0 case when we don't skip anything, but for the pd.offset < 0 case we need to subtract also the remainder of the bits we aren't interested in (the code shifts the bytes by that number of bits). If it weren't for the big-endian path, we could as well do if (pd.offset < 0) size += pd.offset; but the big-endian path needs it differently. With the following patch, amnt is 3 and we subtract from 12 the (8 - 3) bits and thus get the 7 which is the value we want. 2020-11-10 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/97764 * tree-ssa-sccvn.c (vn_walk_cb_data::push_partial_def): For little-endian stores with negative pd.offset, subtract BITS_PER_UNIT - amnt from size if amnt is non-zero. * gcc.c-torture/execute/pr97764.c: New test.
next prev parent reply other threads:[~2020-11-10 10:18 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-11-09 11:39 [Bug tree-optimization/97764] New: wrong code at -O1 and above on x86_64-pc-linux-gnu zhendong.su at inf dot ethz.ch 2020-11-09 11:50 ` [Bug tree-optimization/97764] [10/11 Regression] wrong code at -O1 and above on x86_64-pc-linux-gnu since r10-6809 jakub at gcc dot gnu.org 2020-11-09 12:21 ` rguenth at gcc dot gnu.org 2020-11-09 13:53 ` jakub at gcc dot gnu.org 2020-11-10 10:18 ` cvs-commit at gcc dot gnu.org [this message] 2020-11-10 10:21 ` cvs-commit at gcc dot gnu.org 2020-11-10 10:33 ` rguenth at gcc dot gnu.org 2020-11-10 10:35 ` jakub at gcc dot gnu.org 2020-12-01 11:29 ` 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-97764-4-VOP72C2rPm@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).