summaryrefslogtreecommitdiff
path: root/gcc/params.def
diff options
context:
space:
mode:
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2015-10-08 16:49:24 +0000
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2015-10-08 16:49:24 +0000
commitee23033372b5fa1a237d4d536721be287e74bc54 (patch)
tree61678cfe315bf4f20ccae0603f837d13eeab72a5 /gcc/params.def
parent58111f65c1d006a4a124b1145e464661da723725 (diff)
downloadgcc-ee23033372b5fa1a237d4d536721be287e74bc54.tar.gz
Make tree_expr_nonnegative_warnv_p recurse into SSA names
The upcoming patch to move sqrt and cbrt simplifications to match.pd caused a regression because the (abs @0)->@0 simplification didn't trigger for: (abs (convert (abs X))) The simplification is based on tree_expr_nonnegative_p, which at the moment just gives up if it sees an SSA_NAME. This patch makes tree_expr_nonnegative_p recurse into SSA name definitions, but limits the depth of recursion to a small number for the reason mentioned in the comment (adapted from an existing comment in gimple_val_nonnegative_real_p). The patch reuses code in tree-vrp.c, moving it to gimple-fold.c. It also replaces calls to gimple_val_nonnegative_real_p with calls to tree_expr_nonnegative_p. A knock-on effect is that we can now prove _i_589 < 0 is false in sequences like: i_1917 = ASSERT_EXPR <i_1075, i_1075 == 0>; _i_589 = (const int) i_1917; _i_1507 = ASSERT_EXPR <_i_589, _i_589 < 0>; This defeats an assert in tree-vrp.c that ASSERT_EXPR conditions are never known to be false. Previously the assert only ever used local knowledge and so would be limited to cases like x != x for integer x. Now that we use global knowledge it's possible to prove the assertion condition is false in blocks that are in practice unreachable. The patch therefore removes the assert. Bootstrapped & regression-tested on x86_64-linux-gnu. I didn't write a specific test because this is already covered by the testsuite if the follow-on patch is also applied. gcc/ * params.def (PARAM_MAX_SSA_NAME_QUERY_DEPTH): New param. * doc/invoke.texi (--param max-ssa-name-query-depth): Document. * fold-const.h (tree_unary_nonnegative_warnv_p) (tree_single_nonnegative_warnv_p, tree_call_nonnegative_warnv_p) (tree_expr_nonnegative_warnv_p): Add depth parameters. * fold-const.c: Include gimple-fold.h and params.h. (tree_ssa_name_nonnegative_warnv_p): New function. (tree_unary_nonnegative_warnv_p, tree_binary_nonnegative_warnv_p) (tree_single_nonnegative_warnv_p, tree_call_nonnegative_warnv_p) (tree_invalid_nonnegative_warnv_p, tree_expr_nonnegative_warnv_p): Add a depth parameter and increment it for recursive calls to tree_expr_nonnegative_warnv_p. Use tree_ssa_name_nonnegative_warnv_p to handle SSA names. * gimple-fold.h (gimple_val_nonnegative_real_p): Delete. (gimple_stmt_nonnegative_warnv_p): Declare. * tree-vrp.c (remove_range_assertions): Remove assert that condition cannot be proven false. (gimple_assign_nonnegative_warnv_p, gimple_call_nonnegative_warnv_p) (gimple_stmt_nonnegative_warnv_p): Move to... * gimple-fold.c: ...here. Add depth parameters and pass them down to the tree routines. Accept statements that aren't assignments or calls but just return false for them. (gimple_val_nonnegative_real_p): Delete. * tree-ssa-math-opts.c (gimple_expand_builtin_pow): Use tree_expr_nonnegative_p instead of gimple_val_nonnegative_real_p. Check HONOR_NANs first. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228614 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/params.def')
-rw-r--r--gcc/params.def6
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/params.def b/gcc/params.def
index da2c6a3d114..8b8b9fe3ff7 100644
--- a/gcc/params.def
+++ b/gcc/params.def
@@ -1152,6 +1152,12 @@ DEFPARAM (PARAM_PARLOOPS_CHUNK_SIZE,
"parloops-chunk-size",
"Chunk size of omp schedule for loops parallelized by parloops",
0, 0, 0)
+
+DEFPARAM (PARAM_MAX_SSA_NAME_QUERY_DEPTH,
+ "max-ssa-name-query-depth",
+ "Maximum recursion depth allowed when querying a property of an"
+ " SSA name",
+ 2, 1, 0)
/*
Local variables: