GBE: Implement an extra liveness analysis for the Gen backend.
authorZhigang Gong <zhigang.gong@intel.com>
Thu, 23 Jan 2014 06:15:05 +0000 (14:15 +0800)
committerZhigang Gong <zhigang.gong@intel.com>
Sun, 26 Jan 2014 08:46:48 +0000 (16:46 +0800)
commit1a8afc3ccc79b9204a24aa077fb33b2e047887b5
treea77162bdf0a8f3046ec9b4161044571326423f20
parent3262ebecac132b0adf168e8f5efc2f6993a1fe92
GBE: Implement an extra liveness analysis for the Gen backend.

  Consider the following scenario, %100's normal liveness will start from Ln-1's
  position. In normal analysis, the Ln-1 is not Ln's predecessor, thus the liveness
  of %100 will be passed to Ln and then will not be passed to L0.

  But considering we are running on a multilane with predication's vector machine.
  The unconditional BR in Ln-1 may be removed and it will enter Ln with a subset of
  the revert set of Ln-1's predication. For example when running Ln-1, the active lane
  is 0-7, then at Ln the active lane is 8-15. Then at the end of Ln, a subset of 8-15
  will jump to L0. If a register %10 is allocated the same GRF as %100, given the fact
  that their normal liveness doesn't overlapped, the a subset of 8-15 lanes will be
  modified. If the %10 and %100 are the same vector data type, then we are fine. But if
  %100 is a float vector, and the %10 is a bool or short vector, then we hit a bug here.

L0:
  ...
  %10 = 5
  ...
Ln-1:
  %100 = 2
  BR Ln+1

Ln:
  ...
  BR(%xxx) L0

Ln+1:
  %101 = %100 + 2;
  ...

  The solution to fix this issue is to build an extra liveness analysis. We will start with
  those BBs with backward jump. Then pass all the liveOut register as extra liveIn
  of current BB and then forward this extra liveIn to all the blocks. This is very similar
  to the normal liveness analysis just with reverse direction.

  Thanks yang rong who found this bug.

v2:
  Don't remove livein when initialize the extra livein.

Signed-off-by: Zhigang Gong <zhigang.gong@intel.com>
Reviewed-by: Yang Rong <rong.r.yang@intel.com>
backend/src/backend/gen_context.hpp
backend/src/backend/gen_reg_allocation.cpp
backend/src/ir/liveness.cpp
backend/src/ir/liveness.hpp