GBE: Improve spill policy by considering use count

Graphics / Beignet - Ruiling Song [intel.com] - 24 June 2016 05:27 UTC

In this patch, We use usecount/liverange as the spill cost. And try to minimize the spill cost when do register spilling. For registers inside loop, we will use 10**loop_depth to approximate the use count.

When we spill for a scalar register, that is easy, just find the candidate with least spill cost. But when spilling for a vector of registers, we need to search in physical register space to make enough room for the requested size, and then we will choose the group of registers with least spill cost.

Note I change to always allocate for dst SelectionVector. As dst SelectionVector normally don't introduce too much register pressure. Allocating SelectionVector will greatly reduce MOVs. I think we need to do further optimization for SelectionVector. We need to do dynamic decision based on register pressure. If allowed, we should try to allocate SelectionVector as much as possible, if register pressure not allowed, then we need to try to add extra MOVs or even spilling.

v2: fix assert in getSpillCost() for tmp register.

4048b7b GBE: Improve spill policy by considering use count.
backend/src/backend/context.cpp | 33 +++
backend/src/backend/context.hpp | 1 +
backend/src/backend/gen_reg_allocation.cpp | 331 +++++++++++++++++++---------
backend/src/ir/function.cpp | 34 ++-
backend/src/ir/function.hpp | 15 +-
backend/src/llvm/llvm_gen_backend.cpp | 2 +-
6 files changed, 302 insertions(+), 114 deletions(-)

Upstream: cgit.freedesktop.org


  • Share