[patch tree-optimization]: Add cleanup code for possible unused statements in binary optimization

Richard Guenther richard.guenther@gmail.com
Tue Aug 2 11:11:00 GMT 2011


On Tue, Aug 2, 2011 at 12:39 PM, Kai Tietz <ktietz70@googlemail.com> wrote:
> Hello,
>
> this patch adds some statement-cleanup to forward-propagation.
>
> ChangeLog
>
> 2011-08-02  Kai Tietz  <ktietz@redhat.com>
>
>        * tree-ssa-forwprop.c (simplify_bitwise_binary):
>        Remove possible unused statement after optimization.
>
> 2011-08-02  Kai Tietz  <ktietz@redhat.com>
>
>        * gcc.dg/tree-ssa/forwprop-9.c: Add test for no int casts.
>
> Bootstrapped and regression-tested for all languages (including Ada
> and Obj-C++) on host x86_64-pc-linux-gnu.
> Ok for apply?

You have to handle the stmts return value - if it removes a possibly
trapping instruction we have to run cfgcleanup.

I also think these are excessive - we want to apply the
transformations for single-use chains only (we are inserting new
stmts after all), in which case we can remove the old defs uncontitionally.

Richard.

> Regards,
> Kai
>
> Index: gcc/gcc/tree-ssa-forwprop.c
> ===================================================================
> --- gcc.orig/gcc/tree-ssa-forwprop.c
> +++ gcc/gcc/tree-ssa-forwprop.c
> @@ -1810,6 +1810,8 @@ simplify_bitwise_binary (gimple_stmt_ite
>       gimple_assign_set_rhs_with_ops_1 (gsi, NOP_EXPR,
>                                        tem, NULL_TREE, NULL_TREE);
>       update_stmt (gsi_stmt (*gsi));
> +      if (TREE_CODE (arg1) == SSA_NAME)
> +       remove_prop_source_from_use (arg1);
>       return true;
>     }
>
> @@ -1840,6 +1842,10 @@ simplify_bitwise_binary (gimple_stmt_ite
>       gimple_assign_set_rhs_with_ops_1 (gsi, NOP_EXPR,
>                                        tem, NULL_TREE, NULL_TREE);
>       update_stmt (gsi_stmt (*gsi));
> +      if (TREE_CODE (arg1) == SSA_NAME)
> +       remove_prop_source_from_use (arg1);
> +      if (TREE_CODE (arg2) == SSA_NAME)
> +       remove_prop_source_from_use (arg2);
>       return true;
>     }
>
> @@ -1887,6 +1893,8 @@ simplify_bitwise_binary (gimple_stmt_ite
>       gimple_assign_set_rhs1 (stmt, def1_arg1);
>       gimple_assign_set_rhs2 (stmt, cst);
>       update_stmt (stmt);
> +      if (TREE_CODE (arg1) == SSA_NAME)
> +       remove_prop_source_from_use (arg1);
>       return true;
>     }
>
> @@ -1907,6 +1915,10 @@ simplify_bitwise_binary (gimple_stmt_ite
>     {
>       gimple_assign_set_rhs_from_tree (gsi, res);
>       update_stmt (gsi_stmt (*gsi));
> +      if (TREE_CODE (arg1) == SSA_NAME)
> +       remove_prop_source_from_use (arg1);
> +      if (TREE_CODE (arg2) == SSA_NAME)
> +       remove_prop_source_from_use (arg2);
>       return true;
>     }
>
> Index: gcc/gcc/testsuite/gcc.dg/tree-ssa/forwprop-9.c
> ===================================================================
> --- gcc.orig/gcc/testsuite/gcc.dg/tree-ssa/forwprop-9.c
> +++ gcc/gcc/testsuite/gcc.dg/tree-ssa/forwprop-9.c
> @@ -11,4 +11,5 @@ foo (_Bool a, _Bool b, _Bool c
>
>  /* { dg-final { scan-tree-dump-times " == " 0 "forwprop1" } } */
>  /* { dg-final { scan-tree-dump-times " != " 0 "forwprop1" } } */
> +/* { dg-final { scan-tree-dump-times "\\\(int\\\)" 0 "forwprop1" } } */
>  /* { dg-final { cleanup-tree-dump "forwprop1" } } */
>



More information about the Gcc-patches mailing list