new copy elimination pass
commitb2ea8c11b61014cb90e2a025d605ac77a1c7d6bc
authorQuentin Carbonneaux <quentin@c9x.me>
Thu, 21 Feb 2019 21:35:12 +0000 (21 22:35 +0100)
committerQuentin Carbonneaux <quentin@c9x.me>
Tue, 26 Feb 2019 07:51:59 +0000 (26 08:51 +0100)
treec3d3c5c7372ea7c2a29bec69110e8e70246258a9
parentdadf6d69d8ef24ada3461ddc81cf56418cfdc91e
new copy elimination pass

The sparse data-flow analysis used for
copy elimination before this patch
could sometimes diverge.  The core
reason for this behavior is that the
visitphi() function was not monotonic
in the following copy-of lattice:

     top   (represented as the temp
    / | \   itself)
   x  y  z ...
    \ | /
     bot   (represented as R)

This monotonicity defect could be
fixed by reverting 2f41ff03, but
then the pass would end up missing
some redundant phis.

This patch re-implements the pass
from scratch using a different
approach.  The new algorithm should
get rid of all redundant copies.  On
the other hand, it can run slower
than the monotonic sparse data-flow
analysis because, in the worst case,
an instruction in a phi cluster can
be visited as many times as there
are phis in the input program.

Thanks to Michael Forney for reviewing
and testing the new pass.
copy.c