From: Vladimir Makarov <vmakarov@redhat.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: [committed] [PR106462] LRA: Check hard reg availability of pseudo and its subreg for pseudo reload
Date: Fri, 2 Dec 2022 08:30:32 -0500 [thread overview]
Message-ID: <1c654090-4263-a2f5-3651-312694a8f786@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 147 bytes --]
The following patch solves
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106462
The patch was successfully bootstrapped and tested on x86-64.
[-- Attachment #2: pr106462.patch --]
[-- Type: text/x-patch, Size: 2123 bytes --]
commit 70596a0fb2a2ec072e1e97e37616e05041dfa4e5
Author: Vladimir N. Makarov <vmakarov@redhat.com>
Date: Fri Dec 2 08:18:04 2022 -0500
LRA: Check hard reg availability of pseudo and its subreg for pseudo reload
Do not reload subreg pseudo if there are hard regs for subreg mode
but there are no hard regs for pseudo mode.
PR target/106462
gcc/ChangeLog:
* lra-constraints.cc (curr_insn_transform): Check available hard
regs for pseudo and its subreg to decide what to reload.
gcc/testsuite/ChangeLog:
* gcc.target/mips/pr106462.c: New test.
diff --git a/gcc/lra-constraints.cc b/gcc/lra-constraints.cc
index d92ab76908c..02b5ab4a316 100644
--- a/gcc/lra-constraints.cc
+++ b/gcc/lra-constraints.cc
@@ -4582,7 +4582,18 @@ curr_insn_transform (bool check_only_p)
|| (partial_subreg_p (mode, GET_MODE (reg))
&& known_le (GET_MODE_SIZE (GET_MODE (reg)),
UNITS_PER_WORD)
- && WORD_REGISTER_OPERATIONS)))
+ && WORD_REGISTER_OPERATIONS))
+ /* Avoid the situation when there are no available hard regs
+ for the pseudo mode but there are ones for the subreg
+ mode: */
+ && !(goal_alt[i] != NO_REGS
+ && REGNO (reg) >= FIRST_PSEUDO_REGISTER
+ && (prohibited_class_reg_set_mode_p
+ (goal_alt[i], reg_class_contents[goal_alt[i]],
+ GET_MODE (reg)))
+ && !(prohibited_class_reg_set_mode_p
+ (goal_alt[i], reg_class_contents[goal_alt[i]],
+ mode))))
{
/* An OP_INOUT is required when reloading a subreg of a
mode wider than a word to ensure that data beyond the
diff --git a/gcc/testsuite/gcc.target/mips/pr106462.c b/gcc/testsuite/gcc.target/mips/pr106462.c
new file mode 100644
index 00000000000..c9105409524
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/pr106462.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-mabi=64 -msingle-float" } */
+
+extern void bar (float x, short y);
+
+void foo (int argc)
+{
+ short c = argc * 2;
+ float a = (float)(short)c, b = 9.5;
+
+ bar (b/a, c);
+}
reply other threads:[~2022-12-02 13:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1c654090-4263-a2f5-3651-312694a8f786@redhat.com \
--to=vmakarov@redhat.com \
--cc=gcc-patches@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).