Denis Chertykov <cherty...@gmail.com> writes: > PR rtl-optimization/117868 > gcc/ > * lra-spills.cc (assign_stack_slot_num_and_sort_pseudos): Reuse slots > only without allocated memory or only with equal or smaller registers > with equal or smaller alignment. > (lra_spill): Print slot size as width. > > > diff --git a/gcc/lra-spills.cc b/gcc/lra-spills.cc > index db78dcd28a3..93a0c92db9f 100644 > --- a/gcc/lra-spills.cc > +++ b/gcc/lra-spills.cc > @@ -386,7 +386,18 @@ assign_stack_slot_num_and_sort_pseudos (int > *pseudo_regnos, int n) > && ! (lra_intersected_live_ranges_p > (slots[j].live_ranges, > lra_reg_info[regno].live_ranges))) > - break; > + { > + /* A slot without allocated memory can be shared. */ > + if (slots[j].mem == NULL_RTX) > + break; > + > + /* A slot with allocated memory can be shared only with equal > + or smaller register with equal or smaller alignment. */ > + if (slots[j].align >= spill_slot_alignment (mode) > + && compare_sizes_for_sort (slots[j].size, > + GET_MODE_SIZE (mode)) != -1)
Sorry for piping up late, but I think this should be: known_ge (GET_MODE_SIZE (mode), slots[j].size) >From the comment above compare_sizes_for_sort: /* Compare A and B for sorting purposes, returning -1 if A should come before B, 0 if A and B are identical, and 1 if A should come after B. This is a lexicographical compare of the coefficients in reverse order. A consequence of this is that all constant sizes come before all non-constant ones, regardless of magnitude (since a size is never negative). This is what most callers want. For example, when laying data out on the stack, it's better to keep all the constant-sized data together so that it can be accessed as a constant offset from a single base. */ For example, compare_sizes_for_sort would return 1 for a slot size of 2+2X and a mode size of 16, but the slot would be too small for X < 7. Thanks, Richard > + break; > + } > } > if (j >= slots_num) > { > @@ -656,8 +667,7 @@ lra_spill (void) > for (i = 0; i < slots_num; i++) > { > fprintf (lra_dump_file, " Slot %d regnos (width = ", i); > - print_dec (GET_MODE_SIZE (GET_MODE (slots[i].mem)), > - lra_dump_file, SIGNED); > + print_dec (slots[i].size, lra_dump_file, SIGNED); > fprintf (lra_dump_file, "):"); > for (curr_regno = slots[i].regno;; > curr_regno = pseudo_slots[curr_regno].next - pseudo_slots)