Open Quuxplusone opened 9 years ago
Attached test.ll
(6299 bytes, application/octet-stream): Testcase
Hi James,
I am not sure what you are suggesting here.
When we take the decision of evicting something for vreg45, we have to assume
the worst case scenario, i.e., the evicted register will be spilled around all
uses. In that respect, both vreg23 and verg1 are more expensive I guess (I
haven’t actually checked). The fact that evicting one of those is cheaper may
come from the fact that unlike vreg7, we will be able to split them and have a
cheaper live-range to spill as a result.
Anyhow, we do not know that when taking the decision to evict and I do not see
how we can determine that at that time.
The bottom line is I do not see how the loop hierarchy would help here.
Thanks.
Hi Quentin,
Indeed, the live range of vreg23/vreg1 should be split, I think. How do you think we should approach this? the spill in the inner loop is avoidable (with perfect allocation) and is obviously bad, so is there anything we can do about it?
I'm not massively well versed in the myriad tradeoffs in register allocation/range-splitting/spill-placement/coalescing.
James
I have to double check but my hopes are low that we can do something
reasonable. Basically we are hitting a fundamental limitation of the algorithm.
It looks at the current state for deciding and cannot think future (which is
pretty hard).
I believe we could tweak the eviction policy to “fake” the splitting mechanism
and check how expensive that would be to spill the resulting live-range (which
should be shorter, thus likely less expensive).
However, assuming this is doable (faking the splitting may be fun), like all
heuristics, if we get it wrong, e.g., because the split live-ranges would have
different priority and we completely missed what the future will in fact look
like, we can have some dramatic regressions.
test.ll
(6299 bytes, application/octet-stream)