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 target/110598] [14 Regression] wrong code on llvm-14.0.6 due to memcmp being miscompiled
Date: Wed, 12 Jul 2023 13:13:13 +0000	[thread overview]
Message-ID: <bug-110598-4-O5Gfd55xSs@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-110598-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Roger Sayle <sayle@gcc.gnu.org>:

https://gcc.gnu.org/g:d2c18b4a16f9e1a6ed271ec1efaf94533d1c4a94

commit r14-2465-gd2c18b4a16f9e1a6ed271ec1efaf94533d1c4a94
Author: Roger Sayle <roger@nextmovesoftware.com>
Date:   Wed Jul 12 14:12:34 2023 +0100

    PR target/110598: Fix rega = 0; rega ^= rega regression in i386.md

    This patch fixes the regression PR target/110598 caused by my recent
    addition of a peephole2.  The intention of that optimization was to
    simplify zeroing a register, followed by an IOR, XOR or PLUS operation
    on it into a move, or as described in the comment:
    ;; Peephole2 rega = 0; rega op= regb into rega = regb.

    The issue is that I'd failed to consider the (rare and unusual) case,
    where regb is rega, where the transformation leads to the incorrect
    "rega = rega", when it should be "rega = 0".  The minimal fix is to
    add a !reg_mentioned_p check to the recent peephole2.

    In addition to resolving the regression, I've added a second peephole2
    to optimize the problematic case above, which contains a false
    dependency and is therefore tricky to optimize elsewhere.  This is an
    improvement over GCC 13, for example, that generates the redundant:

            xorl    %edx, %edx
            xorq    %rdx, %rdx

    2023-07-12  Roger Sayle  <roger@nextmovesoftware.com>

    gcc/ChangeLog
            PR target/110598
            * config/i386/i386.md (peephole2): Check !reg_mentioned_p when
            optimizing rega = 0; rega op= regb for op in [XOR,IOR,PLUS].
            (peephole2): Simplify rega = 0; rega op= rega cases.

    gcc/testsuite/ChangeLog
            PR target/110598
            * gcc.target/i386/pr110598.c: New test case.

  parent reply	other threads:[~2023-07-12 13:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-08 17:00 [Bug c++/110598] New: [14 Regression] wrong code on llvm-14.0.6 slyfox at gcc dot gnu.org
2023-07-08 17:32 ` [Bug target/110598] [14 Regression] wrong code on llvm-14.0.6 due to memcmp being miscompiled pinskia at gcc dot gnu.org
2023-07-08 17:41 ` pinskia at gcc dot gnu.org
2023-07-08 20:31 ` slyfox at gcc dot gnu.org
2023-07-09 22:34 ` roger at nextmovesoftware dot com
2023-07-12 13:13 ` cvs-commit at gcc dot gnu.org [this message]
2023-07-12 16:15 ` slyfox at gcc dot gnu.org
2023-07-12 19:42 ` roger at nextmovesoftware dot com

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-110598-4-O5Gfd55xSs@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).