* [IRA] Skip empty register classes in setup_reg_class_relations
@ 2023-07-12 11:05 SenthilKumar.Selvaraj
2023-07-13 12:45 ` Vladimir Makarov
0 siblings, 1 reply; 2+ messages in thread
From: SenthilKumar.Selvaraj @ 2023-07-12 11:05 UTC (permalink / raw)
To: gcc-patches; +Cc: vmakarov
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [IRA] Skip empty register classes in setup_reg_class_relations
2023-07-12 11:05 [IRA] Skip empty register classes in setup_reg_class_relations SenthilKumar.Selvaraj
@ 2023-07-13 12:45 ` Vladimir Makarov
0 siblings, 0 replies; 2+ messages in thread
From: Vladimir Makarov @ 2023-07-13 12:45 UTC (permalink / raw)
To: SenthilKumar.Selvaraj, gcc-patches
On 7/12/23 07:05, SenthilKumar.Selvaraj@microchip.com wrote:
> Hi,
>
> I've been spending some (spare) time trying to get LRA working
> for the avr target.
Thank you for addressing this problem.
The code you changing is very sensitive and was a source of multiple PRs
in the past. But I found the change your propose logical and I think it
will not create problems. Still please be alert and revert the patch if
people reports the problem with this change.
> 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.
OK.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-07-13 12:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-12 11:05 [IRA] Skip empty register classes in setup_reg_class_relations SenthilKumar.Selvaraj
2023-07-13 12:45 ` Vladimir Makarov
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).