On Tue, Oct 18, 2016 at 02:34:58PM +0200, Richard Biener wrote:
> 
> The following patch makes EVRP remove stmts that will become dead
> after propagation.  For this to work we have to propagate into PHIs
> (sth we missed as well).
> 
> Bootstrap and regtest running on x86_64-unknown-linux-gnu.
> 
> Richard.
> 
> 2016-10-18  Richard Biener  <rguent...@suse.de>
> 
>       * tree-vrp.c (evrp_dom_walker::evrp_dom_walker): Initialize
>       stmts_to_remove.
>       (evrp_dom_walker::~evrp_dom_walker): Free it.
>       (evrp_dom_walker::stmts_to_remove): Add.
>       (evrp_dom_walker::before_dom_children): Mark PHIs and stmts
>       whose output we fully propagate for removal.  Propagate
>       into BB destination PHI arguments.
>       (execute_early_vrp): Remove queued stmts.  Dump value ranges
>       before stmt removal.
> 
> Index: gcc/tree-vrp.c
> ===================================================================
> --- gcc/tree-vrp.c    (revision 241302)
> +++ gcc/tree-vrp.c    (working copy)
> @@ -10643,11 +10643,13 @@ public:
>      : dom_walker (CDI_DOMINATORS), stack (10)
>      {
>        stmts_to_fixup.create (0);
> +      stmts_to_remove.create (0);
>        need_eh_cleanup = BITMAP_ALLOC (NULL);
>      }
>    ~evrp_dom_walker ()
>      {
>        stmts_to_fixup.release ();
> +      stmts_to_remove.release ();
>        BITMAP_FREE (need_eh_cleanup);
>      }
>    virtual edge before_dom_children (basic_block);
> @@ -10660,6 +10662,7 @@ public:
>    auto_vec<std::pair <const_tree, value_range*> > stack;
>    bitmap need_eh_cleanup;
>    vec<gimple *> stmts_to_fixup;
> +  vec<gimple *> stmts_to_remove;

That might as well be an auto_vec right?

>  };
>  
>  
> @@ -10769,6 +10772,15 @@ evrp_dom_walker::before_dom_children (ba
>        else
>       set_value_range_to_varying (&vr_result);
>        update_value_range (lhs, &vr_result);
> +
> +      /* Mark PHIs whose lhs we fully propagate for removal.  */
> +      tree val;
> +      if ((val = op_with_constant_singleton_value_range (lhs))
> +       && may_propagate_copy (lhs, val))

wouldn't it be clearer to write that as

tree val = op_with_constant_singleton_value_range (lhs);
if (val && may_propagate_copy (lhs, val))

> +     {
> +       stmts_to_remove.safe_push (phi);
> +       continue;
> +     }
>      }
>  
>    edge taken_edge = NULL;
> @@ -10806,7 +10818,6 @@ evrp_dom_walker::before_dom_children (ba
>             update_value_range (output, &vr);
>             vr = *get_value_range (output);
>  
> -
>             /* Set the SSA with the value range.  */
>             if (INTEGRAL_TYPE_P (TREE_TYPE (output)))
>               {
> @@ -10824,6 +10835,17 @@ evrp_dom_walker::before_dom_children (ba
>                              && range_includes_zero_p (vr.min,
>                                                        vr.max) == 1)))
>               set_ptr_nonnull (output);
> +
> +           /* Mark stmts whose output we fully propagate for removal.  */
> +           tree val;
> +           if ((val = op_with_constant_singleton_value_range (output))
> +               && may_propagate_copy (output, val)
> +               && !stmt_could_throw_p (stmt)
> +               && !gimple_has_side_effects (stmt))

similar.

Thanks!

Trev

Reply via email to