From: pan2.li@intel.com
To: gcc-patches@gcc.gnu.org
Cc: juzhe.zhong@rivai.ai, kito.cheng@sifive.com, pan2.li@intel.com,
yanzhang.wang@intel.com, jeffreyalaw@gmail.com
Subject: [PATCH v4] Mode-Switching: Fix SET_SRC ICE for create_pre_exit
Date: Sun, 13 Aug 2023 08:56:21 +0800 [thread overview]
Message-ID: <20230813005621.591927-1-pan2.li@intel.com> (raw)
In-Reply-To: <20230807122247.1881775-1-pan2.li@intel.com>
From: Pan Li <pan2.li@intel.com>
In same cases, like gcc/testsuite/gcc.dg/pr78148.c in RISC-V, there will
be only 1 operand when SET_SRC in create_pre_exit. For example as below.
(insn 13 9 14 2 (clobber (reg/i:TI 10 a0)) "gcc/testsuite/gcc.dg/pr78148.c":24:1 -1
(expr_list:REG_UNUSED (reg/i:TI 10 a0)
(nil)))
Unfortunately, SET_SRC requires at least 2 operands and then Segment
Fault here. For SH4 part result in Segment Fault, it looks like only
valid when the return_copy_pat is load or something like that. Thus,
this patch try to fix it by restrict the SET insn for SET_SRC.
Signed-off-by: Pan Li <pan2.li@intel.com>
gcc/ChangeLog:
* mode-switching.cc (create_pre_exit): Add SET insn check.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/mode-switch-ice-1.c: New test.
---
gcc/mode-switching.cc | 1 +
.../gcc.target/riscv/mode-switch-ice-1.c | 22 +++++++++++++++++++
2 files changed, 23 insertions(+)
create mode 100644 gcc/testsuite/gcc.target/riscv/mode-switch-ice-1.c
diff --git a/gcc/mode-switching.cc b/gcc/mode-switching.cc
index 64ae2bc29c3..f483c831c35 100644
--- a/gcc/mode-switching.cc
+++ b/gcc/mode-switching.cc
@@ -411,6 +411,7 @@ create_pre_exit (int n_entities, int *entity_map, const int *num_modes)
conflict with address reloads. */
if (copy_start >= ret_start
&& copy_start + copy_num <= ret_end
+ && GET_CODE (return_copy_pat) == SET
&& OBJECT_P (SET_SRC (return_copy_pat)))
forced_late_switch = true;
break;
diff --git a/gcc/testsuite/gcc.target/riscv/mode-switch-ice-1.c b/gcc/testsuite/gcc.target/riscv/mode-switch-ice-1.c
new file mode 100644
index 00000000000..1b34a471904
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/mode-switch-ice-1.c
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+struct A { char e, f; };
+
+struct B
+{
+ int g;
+ struct A h[4];
+};
+
+extern void bar (int, int);
+
+struct B foo (void)
+{
+ bar (2, 1);
+}
+
+void baz ()
+{
+ foo ();
+}
--
2.34.1
next prev parent reply other threads:[~2023-08-13 0:56 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-07 12:22 [PATCH v1] Mode-Switching: Fix SET_SRC ICE when only one operand pan2.li
2023-08-07 13:13 ` Richard Biener
2023-08-07 13:19 ` Li, Pan2
2023-08-07 16:31 ` Jeff Law
2023-08-08 3:14 ` Li, Pan2
2023-08-08 3:09 ` [PATCH v2] Mode-Switching: Fix SET_SRC ICE when USE or CLOBBER pan2.li
2023-08-08 7:54 ` Richard Biener
2023-08-08 9:34 ` Li, Pan2
2023-08-08 9:42 ` Robin Dapp
2023-08-08 14:03 ` Li, Pan2
2023-08-09 3:05 ` [PATCH v3] Mode-Switching: Fix SET_SRC ICE when CLOBBER insn pan2.li
2023-08-11 20:56 ` Jeff Law
2023-08-12 4:53 ` Li, Pan2
2023-08-13 0:56 ` pan2.li [this message]
2023-08-14 17:20 ` [PATCH v4] Mode-Switching: Fix SET_SRC ICE for create_pre_exit Jeff Law
2023-08-15 2:29 ` Li, Pan2
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=20230813005621.591927-1-pan2.li@intel.com \
--to=pan2.li@intel.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jeffreyalaw@gmail.com \
--cc=juzhe.zhong@rivai.ai \
--cc=kito.cheng@sifive.com \
--cc=yanzhang.wang@intel.com \
/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).