Richard Sandiford <[email protected]> writes:
> Denis Chertykov <[email protected]> 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.
Ok.
Committed as obvious ef7ed227fc9
Denis.
gcc/
* lra-spills.cc (assign_stack_slot_num_and_sort_pseudos): Use known_ge
to compare sizes.
diff --git a/gcc/lra-spills.cc b/gcc/lra-spills.cc
index 93a0c92db9f..fc912c43ce6 100644
--- a/gcc/lra-spills.cc
+++ b/gcc/lra-spills.cc
@@ -394,8 +394,7 @@ assign_stack_slot_num_and_sort_pseudos (int *pseudo_regnos,
int n)
/* 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)
+ && known_ge (slots[j].size, GET_MODE_SIZE (mode)))
break;
}
}