MachineSink: Fix and tweak critical-edge breaking heuristic.
authorWill Dietz <wdietz2@illinois.edu>
Mon, 14 Oct 2013 16:57:17 +0000 (16:57 +0000)
committerWill Dietz <wdietz2@illinois.edu>
Mon, 14 Oct 2013 16:57:17 +0000 (16:57 +0000)
commite4b44c1617b82ba4bb5451df83cfc214b1e5d5f5
treec7c48e1a87e71215618ba79bb5336929278ffc6d
parent1e422bf49dfde2070b2c0c402d3df2666550551d
MachineSink: Fix and tweak critical-edge breaking heuristic.

Per original comment, the intention of this loop
is to go ahead and break the critical edge
(in order to sink this instruction) if there's
reason to believe doing so might "unblock" the
sinking of additional instructions that define
registers used by this one.  The idea is that if
we have a few instructions to sink "together"
breaking the edge might be worthwhile.

This commit makes a few small changes
to help better realize this goal:

First, modify the loop to ignore registers
defined by this instruction.  We don't
sink definitions of physical registers,
and sinking an SSA definition isn't
going to unblock an upstream instruction.

Second, ignore uses of physical registers.
Instructions that define physical registers are
rejected for sinking, and so moving this one
won't enable moving any defining instructions.
As an added bonus, while virtual register
use-def chains are generally small due
to SSA goodness, iteration over the uses
and definitions (used by hasOneNonDBGUse)
for physical registers like EFLAGS
can be rather expensive in practice.
(This is the original reason for looking at this)

Finally, to keep things simple continue
to only consider this trick for registers that
have a single use (via hasOneNonDBGUse),
but to avoid spuriously breaking critical edges
only do so if the definition resides
in the same MBB and therefore this one directly
blocks it from being sunk as well.
If sinking them together is meant to be,
let the iterative nature of this pass
sink the definition into this block first.

Update tests to accomodate this change,
add new testcase where sinking avoids pipeline stalls.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192608 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/MachineSink.cpp
test/CodeGen/ARM/2011-04-11-MachineLICMBug.ll
test/CodeGen/ARM/2011-08-25-ldmia_ret.ll
test/CodeGen/ARM/2012-08-30-select.ll
test/CodeGen/ARM/2013-10-11-select-stalls.ll [new file with mode: 0644]
test/CodeGen/Thumb2/v8_IT_1.ll
test/CodeGen/X86/2012-11-30-handlemove-dbg.ll
test/CodeGen/X86/fold-load.ll
test/CodeGen/X86/hoist-common.ll
test/CodeGen/X86/misched-balance.ll