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/103431] [12 Regression] wrong code with -O -fno-tree-bit-ccp -fno-tree-dominator-opts since r12-4853-g2a83259f837e5cbd
Date: Sat, 27 Nov 2021 12:02:46 +0000	[thread overview]
Message-ID: <bug-103431-4-V257BSBXvk@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-103431-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103431

--- Comment #7 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:f7e4f57f1c7883721b6f5ad48953e10ebfb5a756

commit r12-5558-gf7e4f57f1c7883721b6f5ad48953e10ebfb5a756
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sat Nov 27 13:02:06 2021 +0100

    x86: Fix up x86_{,64_}sh{l,r}d patterns [PR103431]

    The following testcase is miscompiled because the x86_{,64_}sh{l,r}d
    patterns don't properly describe what the instructions do.  One thing
    is left out, in particular that there is initial count &= 63 for
    sh{l,r}dq and initial count &= 31 for sh{l,r}d{l,w}.  And another thing
    not described properly, in particular the behavior when count (after the
    masking) is 0.  The pattern says it is e.g.
    res = (op0 << op2) | (op1 >> (64 - op2))
    but that triggers UB on op1 >> 64.  For op2 0 we actually want
    res = (op0 << op2) | 0
    When constants are propagated to these patterns during RTL optimizations,
    both such problems trigger wrong-code issues.
    This patch represents the patterns as e.g.
    res = (op0 << (op2 & 63)) | (unsigned long long) ((uint128_t) op1 >> (64 -
(op2 & 63)))
    so there is both the initial masking and op2 == 0 behavior results in
    zero being ored.
    The patch introduces alternate patterns for constant op2 where
    simplify-rtx.c will fold those expressions into simple numbers,
    and define_insn_and_split pre-reload splitter for how the patterns
    looked before into the new form, so that it can pattern match during
    combine even computations that assumed the shift amount will be in
    the range of 1 .. bitsize-1.

    2021-11-27  Jakub Jelinek  <jakub@redhat.com>

            PR middle-end/103431
            * config/i386/i386.md (x86_64_shld, x86_shld, x86_64_shrd,
x86_shrd):
            Change insn pattern to accurately describe the instructions.
            (*x86_64_shld_1, *x86_shld_1, *x86_64_shrd_1, *x86_shrd_1): New
            define_insn patterns.
            (*x86_64_shld_2, *x86_shld_2, *x86_64_shrd_2, *x86_shrd_2): New
            define_insn_and_split patterns.
            (*ashl<dwi>3_doubleword_mask, *ashl<dwi>3_doubleword_mask_1,
            *<insn><dwi>3_doubleword_mask, *<insn><dwi>3_doubleword_mask_1,
            ix86_rotl<dwi>3_doubleword, ix86_rotr<dwi>3_doubleword): Adjust
            splitters for x86_{,64_}sh{l,r}d pattern changes.

            * gcc.dg/pr103431.c: New test.

  parent reply	other threads:[~2021-11-27 12:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-25 21:11 [Bug rtl-optimization/103431] New: [12 Regression] wrong code with -O -fno-tree-bit-ccp -fno-tree-dominator-opts zsojka at seznam dot cz
2021-11-25 21:31 ` [Bug middle-end/103431] " pinskia at gcc dot gnu.org
2021-11-26  7:23 ` rguenth at gcc dot gnu.org
2021-11-26  9:38 ` [Bug middle-end/103431] [12 Regression] wrong code with -O -fno-tree-bit-ccp -fno-tree-dominator-opts since r12-4853-g2a83259f837e5cbd marxin at gcc dot gnu.org
2021-11-26 10:21 ` jakub at gcc dot gnu.org
2021-11-26 11:40 ` jakub at gcc dot gnu.org
2021-11-26 13:34 ` jakub at gcc dot gnu.org
2021-11-26 15:39 ` jakub at gcc dot gnu.org
2021-11-27 12:02 ` cvs-commit at gcc dot gnu.org [this message]
2021-11-27 12:03 ` 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-103431-4-V257BSBXvk@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: link
Be 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).