On Thu, Jul 21, 2011 at 10:40 AM, Kai Tietz <[email protected]> wrote:
> Hello,
>
> this patch binds scanning direction for statements within BB in function
> substitute_and_fold with the do_dce flag. For DCE it is profitable to
> walk statements
> from last to first element, but in non-DCE passes - like VRP - it is
> more profitable
> to walk opposite direction.
>
> ChangeLog gcc
>
> 2011-07-21 Kai Tietz <[email protected]>
>
> * tree-ssa-propagate.c (substitute_and_fold): Use
> do_dce flag to deside, if BB's statements are scanned
> in last to first, or first to last order.
>
> Bootstrapped and regression tested for all standard languages
> (including Ada and Obj-C++) on
host x86_64-pc-linux-gnu. Ok for apply?
Ok.
Thanks,
Richard.
>
> Regards,
> Kai
>
> Index: gcc-head/gcc/tree-ssa-propagate.c
> ===================================================================
> --- gcc-head.orig/gcc/tree-ssa-propagate.c
> +++ gcc-head/gcc/tree-ssa-propagate.c
> @@ -966,6 +966,9 @@ replace_phi_args_in (gimple phi, ssa_pro
>
> DO_DCE is true if trivially dead stmts can be removed.
>
> + If DO_DCE is true, the statements within a BB are walked from
> + last to first element. Otherwise we scan from first to last element.
> +
> Return TRUE when something changed. */
>
> bool
> @@ -1046,9 +1049,10 @@ substitute_and_fold (ssa_prop_get_value_
> for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
> replace_phi_args_in (gsi_stmt (i), get_value_fn);
>
> - /* Propagate known values into stmts. Do a backward walk to expose
> - more trivially deletable stmts. */
> - for (i = gsi_last_bb (bb); !gsi_end_p (i);)
> + /* Propagate known values into stmts. Do a backward walk if
> + do_dce is true. In some case it exposes
> + more trivially deletable stmts to walk backward. */
> + for (i = (do_dce ? gsi_last_bb (bb) : gsi_start_bb (bb));
> !gsi_end_p (i);)
> {
> bool did_replace;
> gimple stmt = gsi_stmt (i);
> @@ -1057,7 +1061,10 @@ substitute_and_fold (ssa_prop_get_value_
> gimple_stmt_iterator oldi;
>
> oldi = i;
> - gsi_prev (&i);
> + if (do_dce)
> + gsi_prev (&i);
> + else
> + gsi_next (&i);
>
> /* Ignore ASSERT_EXPRs. They are used by VRP to generate
> range information for names and they are discarded
>