public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: <SenthilKumar.Selvaraj@microchip.com>
To: <gcc-patches@gcc.gnu.org>
Cc: <vmakarov@redhat.com>
Subject: [IRA] Skip empty register classes in setup_reg_class_relations
Date: Wed, 12 Jul 2023 11:05:10 +0000	[thread overview]
Message-ID: <4c71614eec51bbefe18602f3fb6301efcf33f477.camel@microchip.com> (raw)

Hi,

  I've been spending some (spare) time trying to get LRA working
  for the avr target. After making a couple of changes to get
  libgcc going, I'm now hitting an assert at
  lra-constraints.cc:4423 for a subarch (avrtiny) that has a
  couple of regclasses with no available registers.

  The assert fires because in_class_p (correctly) returns
  false for get_reg_class (regno) = ALL_REGS, and new_class =
  NO_LD_REGS. For avrtiny, NO_LD_REGS is an empty regset, and
  therefore hard_reg_set_subset_p (NO_LD_REGS, lra_no_alloc_regs)
  is always true, making in_class_p return false.

  in_class_p picks NO_LD_REGS as new_class because common_class =
  ira_reg_class_subset[ALL_REGS][NO_REGS] evaluates as
  NO_LD_REGS. This appears wrong to me - it should be NO_REGS
  instead (lra-constraints.cc:4421 checks for NO_REGS).

  ira.cc:setup_reg_class_relations sets up
  ira_reg_class_subset (among other things), and the problem
  appears to be a missing continue statement if
  reg_class_contents[cl3] (in the innermost loop) is empty.

  In this case, for cl1 = ALL_REGS and cl2 = NO_REGS, cl3 =
  NO_LD_REGS, temp_hard_regset and temp_set2 are both empty, and
  hard_reg_subset_p (<emptyset>, <anyval>) is always true, so
  ira_reg_class_subset[ALL_REGS][NO_REGS] ends up being set to
  cl3 = NO_LD_REGS. Adding a continue if hard_reg_set_empty_p (temp_hard_regset)
  fixes the problem for me.

  Does the below patch look ok? Bootstrapping and regression
  testing passed on x86_64.

Regards
Senthil

gcc/ChangeLog:

	* ira.cc (setup_reg_class_relations): Skip if
	cl3 is an empty register class.

	
--- gcc/ira.cc
+++ gcc/ira.cc
@@ -1259,6 +1259,9 @@ setup_reg_class_relations (void)
          for (cl3 = 0; cl3 < N_REG_CLASSES; cl3++)
            {
              temp_hard_regset = reg_class_contents[cl3] & ~no_unit_alloc_regs;
+             if (hard_reg_set_empty_p (temp_hard_regset))
+               continue;
+
              if (hard_reg_set_subset_p (temp_hard_regset, intersection_set))
                {
                  /* CL3 allocatable hard register set is inside of

             reply	other threads:[~2023-07-12 11:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-12 11:05 SenthilKumar.Selvaraj [this message]
2023-07-13 12:45 ` 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=4c71614eec51bbefe18602f3fb6301efcf33f477.camel@microchip.com \
    --to=senthilkumar.selvaraj@microchip.com \
    --cc=gcc-patches@gcc.gnu.org \
    --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).