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/108892] [13 Regression] unable to generate reloads for at -Og on riscv64 since r13-4907
Date: Wed, 05 Apr 2023 15:19:52 +0000	[thread overview]
Message-ID: <bug-108892-4-NQCacGMZlu@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108892-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jeff Law <law@gcc.gnu.org>:

https://gcc.gnu.org/g:4a45f5d6a9b53f7f5446dee47e25b07d413bb7eb

commit r13-7013-g4a45f5d6a9b53f7f5446dee47e25b07d413bb7eb
Author: Jeff Law <jlaw@ventanamicro>
Date:   Wed Apr 5 09:16:29 2023 -0600

    [RFA][Bug target/108892 ][13 regression] Force re-recognition after
changing RTL structure of an insn

    So as mentioned in the PR the underlying issue here is combine changes the
form of an existing insn, but fails to force re-recognition.  As a result other
parts of the compiler blow up.

    >                   /* Temporarily replace the set's source with the
    >                      contents of the REG_EQUAL note.  The insn will
    >                      be deleted or recognized by try_combine.  */
    >                   rtx orig_src = SET_SRC (set);                   rtx
orig_dest = SET_DEST (set);                   if (GET_CODE (SET_DEST (set)) ==
ZERO_EXTRACT)
    >                     SET_DEST (set) = XEXP (SET_DEST (set), 0);
    >                   SET_SRC (set) = note;
    >                   i2mod = temp;
    >                   i2mod_old_rhs = copy_rtx (orig_src);
    >                   i2mod_new_rhs = copy_rtx (note);
    >                   next = try_combine (insn, i2mod, NULL, NULL,
    >                                       &new_direct_jump_p,                
                      last_combined_insn);
    >                   i2mod = NULL;
    >                   if (next)
    >                     {
    >                       statistics_counter_event (cfun, "insn-with-note
combine", 1);
    >                       goto retry;
    >                     }                   SET_SRC (set) = orig_src;
    >                   SET_DEST (set) = orig_dest;

    This code replaces the SET_SRC of an insn in the RTL stream with the
contents of a REG_EQUAL note.  So given an insn like this:

    > (insn 122 117 127 2 (set (reg:DI 157 [ _46 ])
    >         (ior:DI (reg:DI 200)
    >             (reg:DI 251))) "j.c":14:5 -1
    >      (expr_list:REG_EQUAL (const_int 25769803782 [0x600000006])
    >         (nil)))

    It replaces the (ior ...) with a (const_int ...).  The resulting insn is
passed to try_combine which will try to recognize it, then use it in a
combination attempt.  Recognition succeeds with the special
define_insn_and_split pattern in the risc-v backend resulting in:

    > (insn 122 117 127 2 (set (reg:DI 157 [ _46 ])
    >         (const_int 25769803782 [0x600000006])) "j.c":14:5 177
{*mvconst_internal}
    >      (expr_list:REG_EQUAL (const_int 25769803782 [0x600000006])
    >         (nil)))

    This is as-expected.  Now assume we were unable to combine anything, so
try_combine returns NULL_RTX.  The quoted code above restores SET_SRC (and
SET_DEST) resulting in:

    > (insn 122 117 127 2 (set (reg:DI 157 [ _46 ])
    >         (ior:DI (reg:DI 200)
    >             (reg:DI 251))) "j.c":14:5 177 {*mvconst_internal}
    >      (expr_list:REG_EQUAL (const_int 25769803782 [0x600000006])
    >         (nil)))

    But this doesn't get re-recognized and we ICE later in LRA.

    The fix is trivial, reset the INSN_CODE to force re-recognition in the case
where try_combine fails.

            PR target/108892
    gcc/
            * combine.cc (combine_instructions): Force re-recognition when
            after restoring the body of an insn to its original form.

    gcc/testsuite/
            * gcc.c-torture/compile/pr108892.c: New test.

  parent reply	other threads:[~2023-04-05 15:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-22 19:52 [Bug rtl-optimization/108892] New: [13 Regression] ICE: in curr_insn_transform, at lra-constraints.cc:4168 (unable to generate reloads for: {*mvconst_internal}) at -Og on riscv64 zsojka at seznam dot cz
2023-02-23  8:39 ` [Bug target/108892] " rguenth at gcc dot gnu.org
2023-02-23 21:20 ` pinskia at gcc dot gnu.org
2023-02-23 21:21 ` [Bug target/108892] [13 Regression] unable to generate reloads for at -Og on riscv64 since r13-4907 pinskia at gcc dot gnu.org
2023-03-10 12:29 ` law at gcc dot gnu.org
2023-03-27 10:59 ` [Bug middle-end/108892] " rguenth at gcc dot gnu.org
2023-03-27 13:16 ` law at gcc dot gnu.org
2023-04-05 15:19 ` cvs-commit at gcc dot gnu.org [this message]
2023-04-05 15:20 ` law 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-108892-4-NQCacGMZlu@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).