On 11/12/23 07:08, Lehua Ding wrote:
This patch relax the subreg track capability to all subreg registers.
The patch is ok for me when general issues I mentioned in my first email and the issue given below are fixed.
gcc/ChangeLog:

        * ira-build.cc (get_reg_unit_size): New.
        (has_same_nregs): New.
        (ira_set_allocno_class): Adjust.

...
+
+/* 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;
+}
+

It is better to fix the problem source.  But sometimes it is hard to do this for all targets.  RA already has analogous code.  So it is ok for me.  The only thing is that it is too expensive to do this for each allocno.  You should implement some cache (class, mode)->result.


Reply via email to