[PATCH 1/7] ira: Refactor the handling of register conflicts to make it more general

Lehua Ding lehua.ding@rivai.ai
Wed Nov 8 08:34:10 GMT 2023


Hi Richard,

Thanks for taking the time to review the code.

On 2023/11/8 15:57, Richard Biener wrote:
> On Wed, Nov 8, 2023 at 4:48 AM Lehua Ding <lehua.ding@rivai.ai> wrote:
>>
>> This patch does not make any functional changes. It mainly refactor two parts:
>>
>> 1. The ira_allocno's objects field is expanded to an scalable array, and multi-word
>>     pseduo registers are split and tracked only when necessary.
>> 2. Since the objects array has been expanded, there will be more subreg objects
>>     that pass through later, rather than the previous fixed two. Therefore, it
>>     is necessary to modify the detection of whether two objects conflict, and
>>     the check method is to pull back the registers occupied by the object to
>>     the first register of the allocno for judgment.
> 
> Did you profile this before/after?  RA performance is critical ...

Based on the data I ran earlier, the performance changes on spec2017 
were very slight. I'll run again and give you the data.Based on my 
expectations, the impact on existing performance should all be minimal. 
Except for examples like the ones I put up.

>> diff --git a/gcc/hard-reg-set.h b/gcc/hard-reg-set.h
>> index b0bb9bce074..760eadba186 100644
>> --- a/gcc/hard-reg-set.h
>> +++ b/gcc/hard-reg-set.h
>> @@ -113,6 +113,39 @@ struct HARD_REG_SET
>>       return !operator== (other);
>>     }
>>
>> +  HARD_REG_SET
>> +  operator>> (unsigned int shift_amount) const
> 
> This is a quite costly operation, why do we need it instead
> of keeping an "offset" for set queries?

Because there are logic operations after the shift. For a mutil hardreg 
pseudo register, it will record the physical registers of each part of 
the conflict, and different parts of the offset are different, and we 
need to unify these differences to the conflict against the first single 
reg of the pseduo register. That is to say, first we need to convert it 
to a conflict against the first_single_reg, and then we need to collect 
all the conflicting registers (by OR operation). like this:

*start_conflict_regs |= OBJECT_TOTAL_CONFLICT_HARD_REGS (obj) >> 
(OBJECT_START (obj) + j)

>> +/* Return the object in allocno A which match START & NREGS.  */
>> +ira_object_t
>> +find_object (ira_allocno_t a, int start, int nregs)
>> +{
>> +  for (ira_object_t obj : a->objects)
> 
> linear search?  really?

I was thinking about the fact that most allocno's have only one objects, 
and most of the others don't have more than 10, so I chose this easiest 
way to find them. Thanks for the heads up, it's really not very good 
here, I'll see if there's a faster way.

-- 
Best,
Lehua (RiVAI)
lehua.ding@rivai.ai



More information about the Gcc-patches mailing list