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 via email to