On Fri, Sep 6, 2013 at 8:41 AM, Richard Biener wrote:
>> I'd recommend re-implementing the control dependence code, then. The
>> current implementation is basically taken from old RTL-SSA dce.c and
>> uses a now old-fashioned view of the CFG, e.g. using edge lists.
>> You're probably better off starting from the dominance frontiers code
>> (control dependence is the same as dominance frontiers on the reverse
>> CFG).
...
> Well, I'm not in a position to do the re-implementation at the moment.

You don't have to. You just copy the dominance frontier code and make
it work on the reverse CFG. That shouldn't take more than half an hour
or so, and the result is much easier to interpret/validate than the
edge list stuff so you'll probably get that half our back easily when
working on control dependence consumers.

In fact, I already made those changes some time ago, see the cfganal.c
parts of http://gcc.gnu.org/ml/gcc-patches/2013-01/txt00046.txt


> Would a re-implementation give me control-dependence in a more useful
> way for PHI nodes?  That is, what block is an incoming edge (to compute
> the PHI arg) control dependent on?

I suppose so, yes. The inverse dominance-frontiers output is a
relation between basic blocks, i.e. not edge based. So you'd get
B=e->src and take the control dependencies of B.


> The current DCE query looks for
> control dependece of the incoming edges predecessor, but for
>
>    if
>     |\
>     | <empty>
>     |  /
>    PHI <1, 2>
>
> this gets us the right answer for the edge from the <empty> block
> but a wrong one for the one that uses the if block (as DCE has to
> consider all incoming edges that probably doesn't matter as it
> just gets one step ahead here instead of waiting for the control
> dependence of the if block being marked).

I'm not sure I'm following what you're trying to say here, but if I
understand correctly, then there should be a check in DCE that the PHI
block does not post-dominate its predecessor.

In any case, I recommend you don't start from the DCE control
dependence code. It is relatively slow (Harvey's algorithm is optimal,
Morgan's is quadratic in the number of edges), and it doesn't compute
control dependence for abnormal edges (I hacked that out, it made
control dependence calculation too slow). You'll want "proper",
correct control dependence, and the code in tree-ssa-dce.c is tweaked
for the purpose of DCE.

Ciao!
Steven

Reply via email to