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/114605] [14 Regression] wrong code with -march=z13 -O0 since r14-5831
Date: Mon, 08 Apr 2024 14:22:52 +0000	[thread overview]
Message-ID: <bug-114605-4-ZW3GiwxEIs@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-114605-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #3 from GCC 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:d5d84487dec06186fd9246b505f44ef68a66d6a2

commit r14-9834-gd5d84487dec06186fd9246b505f44ef68a66d6a2
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Mon Apr 8 16:22:13 2024 +0200

    s390: Fix s390_const_int_pool_entry_p and movdi peephole2 [PR114605]

    The following testcase is miscompiled, because we have initially
    a movti which loads the 0x3f8000003f800000ULL TImode constant
    from constant pool.  Later on we split it into a pair of DImode
    loads.  Now, for the first load (why just that?, though not stage4
    material) we trigger the peephole2 which uses s390_const_int_pool_entry_p.
    That function doesn't check at all the constant pool mode though, sees
    the constant pool at that address has a CONST_INT value and just assumes
    that is the value to return, which is especially wrong for big-endian,
    if it is a DImode load from offset 0, it should be loading 0 rather than
    0x3f8000003f800000ULL.
    The following patch adds checks if we are extracing a MODE_INT mode,
    if the constant pool has MODE_INT mode as well, punts if constant pool
    has smaller mode size than the extraction one (then it would be UB),
    if it has the same mode as before keeps using what it did before,
    if constant pool has a larger mode than the one being extracted, uses
    simplify_subreg.  I'd have used avoid_constant_pool_reference
    instead which can handle also offsets into the constant pool constants,
    but it can't handle UNSPEC_LTREF.

    Another thing is that once that is fixed, we ICE when we extract constant
    like 0, ior insn predicate require non-0 constant.  So, the patch also
    fixes the peephole2 so that if either 32-bit half is zero, it uses a mere
    load of the constant into register rather than a pair of such load and ior.

    2024-04-08  Jakub Jelinek  <jakub@redhat.com>

            PR target/114605
            * config/s390/s390.cc (s390_const_int_pool_entry_p): Punt
            if mem doesn't have MODE_INT mode, or pool constant doesn't
            have MODE_INT mode, or if pool constant mode is smaller than
            mem mode.  If mem mode is different from pool constant mode,
            try to simplify subreg.  If that doesn't work, punt, if it
            does, use the simplified constant instead of the constant pool
            constant.
            * config/s390/s390.md (movdi from const pool peephole): If
            either low or high 32-bit part is zero, just emit move insn
            instead of move + ior.

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

  parent reply	other threads:[~2024-04-08 14:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-05 13:23 [Bug target/114605] New: " jakub at gcc dot gnu.org
2024-04-05 13:23 ` [Bug target/114605] " jakub at gcc dot gnu.org
2024-04-05 13:46 ` jakub at gcc dot gnu.org
2024-04-05 14:29 ` jakub at gcc dot gnu.org
2024-04-08 14:22 ` cvs-commit at gcc dot gnu.org [this message]
2024-04-08 14:23 ` 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-114605-4-ZW3GiwxEIs@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).