[PATCH] D106408: Allow rematerialization of virtual reg uses

Stanislav Mekhanoshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 22 11:06:59 PDT 2021


rampitec added a comment.

In D106408#3014403 <https://reviews.llvm.org/D106408#3014403>, @wxiao3 wrote:

> hi,
>
> There is some internal benchmark performance regression after the patch landed.
> The story is as follows:
> There is a virtual register: %5 which lives across many basic blocks (some are inside loops).
> Before this patch is landed, its weight is: 2.299834e-03 as below:
>
>   %5 [592r,3248B:0)[3312B,3392B:0)[3456B,3616B:0)[3712B,4368B:0)[4464B,5008B:0)[5072B,5328B:0)[6208B,6480B:0)[6560B,6640B:0)[6720B,6976B:0)[7104B,8224B:0)[8336B,9104B:0)[9184B,9488B:0)[10512B,13904B:0)[14480B,16320B:0)  0 at 592r weight:2.299834e-03
>
> Its definition is as below:
>
>   592B      %5:gr64 = LEA64r %523:gr64, 1, %0:gr64_nosp, 0, $noreg
>
> After this patch is landed, its weight is reduced by half to: 1.149917e-03 as below:
>
>   %5 [592r,3248B:0)[3312B,3392B:0)[3456B,3616B:0)[3712B,4368B:0)[4464B,5008B:0)[5072B,5328B:0)[6208B,6480B:0)[6560B,6640B:0)[6720B,6976B:0)[7104B,8224B:0)[8336B,9104B:0)[9184B,9488B:0)[10512B,13904B:0)[14480B,16320B:0)  0 at 592r weight:1.149917e-03
>
> Finally, %5 is evicted by other VR, which doesn't happen before this patch land.
>
> For this case, treating %5 as ReMaterializable and reducing its weight is very bad.
>
> Any idea to fix the performance regression?
>
> Wei

It is now considered rematerializable which has halven the spill weight because it could be rematerialized instead. I guess at the end it was not rematerialized. I'd start with checking what has prevented it, but likely that is because %523 or %0 are not available at the point of rematerialization.

I was experimenting with avoiding the division by 2 at the end of the `VirtRegAuxInfo::weightCalcHelper` if there are vreg uses, but actually got worse results. Since this is a heuristic calculating weights it might make sense to give it some little extra weight for every vreg use I guess.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106408



More information about the llvm-commits mailing list