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/97073] [8/9/10/11 Regression] Miscompilation with -m32 -O1 -march=i686
Date: Sun, 27 Sep 2020 21:24:09 +0000	[thread overview]
Message-ID: <bug-97073-4-M69X4WPlqh@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-97073-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #10 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:9389e3abc1fc4881f22c7376aae2dd650af2b792

commit r10-8804-g9389e3abc1fc4881f22c7376aae2dd650af2b792
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sun Sep 27 23:18:26 2020 +0200

    optabs: Don't reuse target for multi-word expansions if it overlaps
operand(s) [PR97073]

    The following testcase is miscompiled on i686-linux, because
    we try to expand a double-word bitwise logic operation with op0
    being a (mem:DI u) and target (mem:DI u+4), i.e. partial overlap, and
    thus end up with:
            movl    4(%esp), %eax
            andl    u, %eax
            movl    %eax, u+4
    ! movl u+4, %eax optimized out
            andl    8(%esp), %eax
            movl    %eax, u+8
    rather than with the desired:
            movl    4(%esp), %edx
            movl    8(%esp), %eax
            andl    u, %edx
            andl    u+4, %eax
            movl    %eax, u+8
            movl    %edx, u+4
    because the store of the first word to target overwrites the second word of
    the operand.
    expand_binop for this (and several similar places) already check for target
    == op0 or target == op1, this patch just adds reg_overlap_mentioned_p calls
    next to it.
    Pedantically, at least for some of these it might be sufficient to force
    a different target if there is overlap but target is not rtx_equal_p to
    the operand (e.g. in this bitwise logical case, but e.g. not in the shift
    cases where there is reordering), though that would go against the
    preexisting target == op? checks and the rationale that REG_EQUAL notes in
    that case isn't correct.

    2020-09-27  Jakub Jelinek  <jakub@redhat.com>

            PR middle-end/97073
            * optabs.c (expand_binop, expand_absneg_bit, expand_unop,
            expand_copysign_bit): Check reg_overlap_mentioned_p between target
            and operand(s) and if it returns true, force a pseudo as target.

            * gcc.c-torture/execute/pr97073.c: New test.

    (cherry picked from commit a4b31d5807f2bc67c8999b3d53369cf2a5c6e1ec)

  parent reply	other threads:[~2020-09-27 21:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-16 17:04 [Bug c/97073] New: " sirl at gcc dot gnu.org
2020-09-17  6:26 ` [Bug target/97073] [8/9/10/11 Regression] " rguenth at gcc dot gnu.org
2020-09-17  8:47 ` [Bug middle-end/97073] " ubizjak at gmail dot com
2020-09-17 19:40 ` jakub at gcc dot gnu.org
2020-09-17 20:11 ` jakub at gcc dot gnu.org
2020-09-18  9:01 ` sirl at gcc dot gnu.org
2020-09-18  9:06 ` jakub at gcc dot gnu.org
2020-09-18  9:28 ` sirl at gcc dot gnu.org
2020-09-18 12:49 ` sirl at gcc dot gnu.org
2020-09-27 21:20 ` cvs-commit at gcc dot gnu.org
2020-09-27 21:24 ` cvs-commit at gcc dot gnu.org [this message]
2020-09-27 21:26 ` cvs-commit at gcc dot gnu.org
2020-09-27 21:27 ` cvs-commit at gcc dot gnu.org
2020-09-27 21:54 ` 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-97073-4-M69X4WPlqh@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).