From: "Kewen.Lin" <linkw@linux.ibm.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: Andrey Belevantsev <abel@ispras.ru>,
Alexander Monakov <amonakov@ispras.ru>,
Peter Bergner <bergner@linux.ibm.com>,
Segher Boessenkool <segher@kernel.crashing.org>
Subject: [PATCH] sel-sched: Verify change before replacing dest in EXPR_INSN_RTX [PR112995]
Date: Fri, 15 Dec 2023 16:52:01 +0800 [thread overview]
Message-ID: <834db636-da81-ded9-3385-ae65a4cb7c91@linux.ibm.com> (raw)
Hi,
PR112995 exposed one issue in current try_replace_dest_reg
that the result rtx insn after replace_dest_with_reg_in_expr
is probably unable to match any constraints. Although there
are some checks on the changes onto dest or src of orig_insn,
none is performed on the EXPR_INSN_RTX.
This patch is to add the check before actually replacing dest
in expr with reg.
Bootstrapped and regtested on x86_64-redhat-linux and
powerpc64{,le}-linux-gnu.
Is it ok for trunk?
BR,
Kewen
-----
PR rtl-optimization/112995
gcc/ChangeLog:
* sel-sched.cc (try_replace_dest_reg): Check the validity of the
replaced insn before actually replacing dest in expr.
gcc/testsuite/ChangeLog:
* gcc.target/powerpc/pr112995.c: New test.
---
gcc/sel-sched.cc | 10 +++++++++-
gcc/testsuite/gcc.target/powerpc/pr112995.c | 14 ++++++++++++++
2 files changed, 23 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.target/powerpc/pr112995.c
diff --git a/gcc/sel-sched.cc b/gcc/sel-sched.cc
index 1925f4a9461..a35b5e16c91 100644
--- a/gcc/sel-sched.cc
+++ b/gcc/sel-sched.cc
@@ -1614,7 +1614,15 @@ try_replace_dest_reg (ilist_t orig_insns, rtx best_reg, expr_t expr)
/* Make sure that EXPR has the right destination
register. */
if (expr_dest_regno (expr) != REGNO (best_reg))
- replace_dest_with_reg_in_expr (expr, best_reg);
+ {
+ rtx_insn *vinsn = EXPR_INSN_RTX (expr);
+ validate_change (vinsn, &SET_DEST (PATTERN (vinsn)), best_reg, 1);
+ bool res = verify_changes (0);
+ cancel_changes (0);
+ if (!res)
+ return false;
+ replace_dest_with_reg_in_expr (expr, best_reg);
+ }
else
EXPR_TARGET_AVAILABLE (expr) = 1;
diff --git a/gcc/testsuite/gcc.target/powerpc/pr112995.c b/gcc/testsuite/gcc.target/powerpc/pr112995.c
new file mode 100644
index 00000000000..4adcb5f3851
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr112995.c
@@ -0,0 +1,14 @@
+/* { dg-require-effective-target float128 } */
+/* { dg-options "-O2 -mdejagnu-cpu=power9 -fselective-scheduling2" } */
+
+/* Verify there is no ICE. */
+
+int a[10];
+int b(_Float128 e) {
+ int c;
+ _Float128 d;
+ c = e;
+ d = c;
+ d = a[c] + d;
+ return d;
+}
--
2.39.3
next reply other threads:[~2023-12-15 8:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-15 8:52 Kewen.Lin [this message]
2023-12-20 20:30 ` Jeff Law
2023-12-21 5:45 ` Kewen.Lin
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=834db636-da81-ded9-3385-ae65a4cb7c91@linux.ibm.com \
--to=linkw@linux.ibm.com \
--cc=abel@ispras.ru \
--cc=amonakov@ispras.ru \
--cc=bergner@linux.ibm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=segher@kernel.crashing.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).