fix: try_to_simplify_bb eargerness
commit852801f8b966407544326cd1c485f9bc7681a2e6
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>
Fri, 16 Jun 2017 06:31:50 +0000 (16 08:31 +0200)
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>
Wed, 21 Jun 2017 09:28:40 +0000 (21 11:28 +0200)
tree2371a2168b9c6c7a343860d2e27331753d3a4514
parentd79853389f55e3645e4a094f091915ea63546d09
fix: try_to_simplify_bb eargerness

The simplification done by try_to_simplify_bb() (essentially
trying to bypass a basic block containing a conditional branch
if the branch is controlled by an OP_PHI when the corresponding
OP_PHISRC is a constant) can only be done if some conditions
are met:
1) The basic block doesn't have some side effects (in which case
   it must not be bypassed). Checked by bb_has_side_effects().
2) There may be some pseudos defined in the basic block but no
   basic blocks may depend on them. Checked by bb_depends_on().

The second condition is efficiently checked using liveness
information. However, there is no liveness information done
for OP_PHI/OP_PHISRC. So if the basic block contains some
other OP_PHI than the controlling one, there will surely be
some other BB depending on it but this will not be reflected
in the liveness info and bb_depends_on() can then wrongly
report that no dependencies exist.

Fix this by adding an extra check, verifiying that no other
OP_PHI are defined in the BB and avoiding the simplification
otherwise.

Reported-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
flow.c
validation/crazy03.c [new file with mode: 0644]