From: Lehua Ding <lehua.ding@rivai.ai>
To: gcc-patches@gcc.gnu.org
Cc: vmakarov@redhat.com, richard.sandiford@arm.com,
juzhe.zhong@rivai.ai, lehua.ding@rivai.ai
Subject: [PATCH 5/7] ira: Add all nregs >= 2 pseudos to tracke subreg list
Date: Wed, 8 Nov 2023 11:47:38 +0800 [thread overview]
Message-ID: <20231108034740.834590-6-lehua.ding@rivai.ai> (raw)
In-Reply-To: <20231108034740.834590-1-lehua.ding@rivai.ai>
This patch completely relax to track all eligible subregs.
gcc/ChangeLog:
* ira-build.cc (get_reg_unit_size): New.
(has_same_nregs): New.
(ira_set_allocno_class): Relax.
---
gcc/ira-build.cc | 41 ++++++++++++++++++++++++++++++++++++-----
1 file changed, 36 insertions(+), 5 deletions(-)
diff --git a/gcc/ira-build.cc b/gcc/ira-build.cc
index 1c47f81ce9d..379f877ca67 100644
--- a/gcc/ira-build.cc
+++ b/gcc/ira-build.cc
@@ -607,6 +607,37 @@ ira_create_allocno (int regno, bool cap_p,
return a;
}
+/* Return single register size of allocno A. */
+static poly_int64
+get_reg_unit_size (ira_allocno_t a)
+{
+ enum reg_class aclass = ALLOCNO_CLASS (a);
+ gcc_assert (aclass != NO_REGS);
+ machine_mode mode = ALLOCNO_MODE (a);
+ int nregs = ALLOCNO_NREGS (a);
+ poly_int64 block_size = REGMODE_NATURAL_SIZE (mode);
+ int nblocks = get_nblocks (mode);
+ gcc_assert (nblocks % nregs == 0);
+ return block_size * (nblocks / nregs);
+}
+
+/* Return true if TARGET_CLASS_MAX_NREGS and TARGET_HARD_REGNO_NREGS results is
+ same. It should be noted that some targets may not implement these two very
+ uniformly, and need to be debugged step by step. For example, in V3x1DI mode
+ in AArch64, TARGET_CLASS_MAX_NREGS returns 2 but TARGET_HARD_REGNO_NREGS
+ returns 3. They are in conflict and need to be repaired in the Hook of
+ AArch64. */
+static bool
+has_same_nregs (ira_allocno_t a)
+{
+ for (int i = 0; i < FIRST_PSEUDO_REGISTER; i++)
+ if (REGNO_REG_CLASS (i) != NO_REGS
+ && reg_class_subset_p (REGNO_REG_CLASS (i), ALLOCNO_CLASS (a))
+ && ALLOCNO_NREGS (a) != hard_regno_nregs (i, ALLOCNO_MODE (a)))
+ return false;
+ return true;
+}
+
/* Set up register class for A and update its conflict hard
registers. */
void
@@ -624,12 +655,12 @@ ira_set_allocno_class (ira_allocno_t a, enum reg_class aclass)
if (aclass == NO_REGS)
return;
- /* SET the unit_size of one register. */
- machine_mode mode = ALLOCNO_MODE (a);
- int nregs = ira_reg_class_max_nregs[aclass][mode];
- if (nregs == 2 && maybe_eq (GET_MODE_SIZE (mode), nregs * UNITS_PER_WORD))
+ gcc_assert (!ALLOCNO_TRACK_SUBREG_P (a));
+ /* Set unit size and track_subreg_p flag for pseudo which need occupied multi
+ hard regs. */
+ if (ALLOCNO_NREGS (a) > 1 && has_same_nregs (a))
{
- ALLOCNO_UNIT_SIZE (a) = UNITS_PER_WORD;
+ ALLOCNO_UNIT_SIZE (a) = get_reg_unit_size (a);
ALLOCNO_TRACK_SUBREG_P (a) = true;
return;
}
--
2.36.3
next prev parent reply other threads:[~2023-11-08 3:48 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-08 3:47 [PATCH 0/7] ira/lra: Support subreg coalesce Lehua Ding
2023-11-08 3:47 ` [PATCH 1/7] ira: Refactor the handling of register conflicts to make it more general Lehua Ding
2023-11-08 7:57 ` Richard Biener
2023-11-08 8:34 ` Lehua Ding
2023-11-08 3:47 ` [PATCH 2/7] ira: Add live_subreg problem and apply to ira pass Lehua Ding
2023-11-08 3:47 ` [PATCH 3/7] ira: Support subreg live range track Lehua Ding
2023-11-08 3:47 ` [PATCH 4/7] ira: Support subreg copy Lehua Ding
2023-11-08 3:47 ` Lehua Ding [this message]
2023-11-08 3:47 ` [PATCH 6/7] lra: Apply live_subreg df_problem to lra pass Lehua Ding
2023-11-08 3:47 ` [PATCH 7/7] lra: Support subreg live range track and conflict detect Lehua Ding
2023-11-08 3:55 ` [PATCH 0/7] ira/lra: Support subreg coalesce juzhe.zhong
2023-11-10 9:29 ` Lehua Ding
2023-11-08 9:40 ` Richard Sandiford
2023-11-08 19:13 ` Jeff Law
2023-11-10 9:43 ` Lehua Ding
2023-11-11 15:33 ` Richard Sandiford
2023-11-11 17:46 ` Jeff Law
2023-11-12 1:16 ` 钟居哲
2023-11-12 11:53 ` Richard Sandiford
2023-11-13 1:11 ` juzhe.zhong
2023-11-13 3:34 ` Lehua Ding
2023-11-10 9:26 ` Lehua Ding
2023-11-10 10:16 ` Richard Sandiford
2023-11-10 10:30 ` Lehua Ding
2023-11-10 10:39 ` Richard Sandiford
2023-11-10 14:28 ` Jeff Law
2023-11-08 16:56 ` Dimitar Dimitrov
2023-11-10 8:46 ` Lehua Ding
2023-11-10 8:53 ` Lehua Ding
2023-11-10 16:00 ` Dimitar Dimitrov
2023-11-12 6:06 ` Lehua Ding
2023-11-12 10:08 ` Lehua Ding
2023-11-09 20:24 ` Vladimir Makarov
2023-11-10 7:59 ` Richard Biener
2023-11-12 12:01 ` Lehua Ding
2023-11-12 12:12 ` Lehua Ding
2023-11-13 19:25 ` Vladimir Makarov
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=20231108034740.834590-6-lehua.ding@rivai.ai \
--to=lehua.ding@rivai.ai \
--cc=gcc-patches@gcc.gnu.org \
--cc=juzhe.zhong@rivai.ai \
--cc=richard.sandiford@arm.com \
--cc=vmakarov@redhat.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).