public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "linkw at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/112995] sel-sched2 ICE without checking verify_changes
Date: Wed, 13 Dec 2023 06:46:13 +0000	[thread overview]
Message-ID: <bug-112995-4-2fuMMgPdWC@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-112995-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #1 from Kewen Lin <linkw at gcc dot gnu.org> ---
Initially we have:

(insn 31 6 10 2 (set (reg/v:SI 9 9 [orig:119 c ] [119])
        (reg/v:SI 64 0 [orig:119 c ] [119])) "test.i":5:5 555
{*movsi_internal1}
     (expr_list:REG_DEAD (reg/v:SI 64 0 [orig:119 c ] [119])
        (nil)))
(insn 10 31 25 2 (set (reg:DI 10 10 [128])
        (ashift:DI (sign_extend:DI (reg/v:SI 9 9 [orig:119 c ] [119]))
            (const_int 2 [0x2]))) "test.i":7:8 278 {ashdi3_extswsli}
     (nil))
(insn 25 10 27 2 (set (reg:DI 64 0 [135])
        (sign_extend:DI (reg/v:SI 9 9 [orig:119 c ] [119]))) "test.i":6:5 31
{extendsidi2}
     (expr_list:REG_DEAD (reg/v:SI 9 9 [orig:119 c ] [119])
        (nil)))

with moving up, we have:

(insn 46 0 0 (set (reg:DI 64 0 [135])
        (sign_extend:DI (reg/v:SI 64 0 [orig:119 c ] [119]))) 31 {extendsidi2}
     (expr_list:REG_DEAD (reg/v:SI 9 9 [orig:119 c ] [119])
        (nil)))

in try_replace_dest_reg, we updated the above EXPR_INSN_RTX to:

(insn 48 0 0 (set (reg:DI 32 0)
        (sign_extend:DI (reg/v:SI 64 0 [orig:119 c ] [119]))) 31 {extendsidi2}
     (nil))

This doesn't match any constraint and it's an unexpected modification.

Unfortunately function try_replace_dest_reg just checks the orig insn with:

      if (REGNO (best_reg) != REGNO (INSN_LHS (orig_insn))
          && (! replace_src_with_reg_ok_p (orig_insn, best_reg)
              || ! replace_dest_with_reg_ok_p (orig_insn, best_reg)))

But it doesn't check EXPR_INSN_RTX, I think it's under the assumption that if
the original insn is able to be replaced then the change on EXPR_INSN_RTX is
fine, but this isn't true as the given test case shows.

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

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-13  6:35 [Bug rtl-optimization/112995] New: " linkw at gcc dot gnu.org
2023-12-13  6:38 ` [Bug rtl-optimization/112995] " linkw at gcc dot gnu.org
2023-12-13  6:46 ` linkw at gcc dot gnu.org [this message]
2023-12-13  7:03 ` pinskia at gcc dot gnu.org
2023-12-13  7:30 ` linkw at gcc dot gnu.org
2023-12-21  5:32 ` cvs-commit at gcc dot gnu.org
2023-12-21  6:30 ` linkw 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-112995-4-2fuMMgPdWC@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).