[PATCH] D156491: [RA] Split a virtual register in cold blocks if it is not assigned preferred physical register

Guozhi Wei via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 4 10:10:46 PDT 2023


Carrot added a comment.

In D156491#4652888 <https://reviews.llvm.org/D156491#4652888>, @hans wrote:

> In D156491#4652685 <https://reviews.llvm.org/D156491#4652685>, @Carrot wrote:
>
>> In D156491#4652598 <https://reviews.llvm.org/D156491#4652598>, @hans wrote:
>>
>>> We're seeing binary size increases in Chromium, in particular for Android and Fuchsia where size is critical: https://crbug.com/1488374
>>> Is that an inherent property of this change, and could it be scaled back for optsize functions for example?
>>
>> This change is driven by the cost of using a single physical register and split a register. As most cost computations in RA, these are based on the weighted number of instructions (dynamic number of instructions or performance), static number of instructions is not considered. So its impact to code size is random. You can use -split-threshold-for-reg-with-hint=0 to disable this optimization.
>
> It does consistently increase binary size (where we measured, which is Android and Fuchsia), so I wouldn't call it random. We are using `-split-threshold-for-reg-with-hint=0` to disable this for now, but we really don't want to use internal compiler flags, and I don't think we can expect users to do so in general.
>
> Did you look at binary size in your benchmarking? If we can't make it size neutral, I think we should consider turning it off in `optsize` functions.

I thought about it more. There are two typical cases that can change size.

1. One COPY instruction between virtual register and physical register in hot block, it constructs a hint for the virtual register, they interfere in two or more cold blocks, we can split the virtual register in cold blocks, it increases code size.
2. Two or more COPY instructions between same virtual register and physical register in hot blocks, they construct a hint for the virtual register, they interfere in one cold block, we can split the virtual register in the cold block, it decreases code size.

The case 1 is more common than case 2. So the it has more possibility to increase size. So it's reasonable to disable it for  `optsize` functions. I will send a patch for it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156491/new/

https://reviews.llvm.org/D156491



More information about the llvm-commits mailing list