diff options
author | Richard Biener <rguenther@suse.de> | 2016-07-14 12:15:38 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2016-07-14 12:15:38 +0000 |
commit | 351168fe551a792fac3dac3359de72c1bcdc651e (patch) | |
tree | e63596b59c87415b491b0e9c85ffdeff0cdb6f3d /gcc/tree-ssa-sccvn.c | |
parent | 8234d02aa47d9cba294b4263e47a336e9c67f5b1 (diff) | |
download | gcc-351168fe551a792fac3dac3359de72c1bcdc651e.zip gcc-351168fe551a792fac3dac3359de72c1bcdc651e.tar.gz gcc-351168fe551a792fac3dac3359de72c1bcdc651e.tar.bz2 |
re PR tree-optimization/71866 (gcc locks up after fix for PR70159)
2016-07-14 Richard Biener <rguenther@suse.de>
PR tree-optimization/71866
* tree-ssa-pre.c (get_constant_for_value_id): Remove.
(do_hoist_insertion): Avoid endless recursion when we
didn't insert anything because we managed to simplify
things down to a constant or SSA name.
(fully_constant_expression): Re-write in terms of ...
* tree-ssa-sccvn.h (vn_nary_simplify): ... this. Declare.
* tree-ssa-sccvn.c (vn_nary_simplify): New wrapper around
vn_nary_build_or_lookup_1.
(vn_nary_build_or_lookup_1): Added flag and renamed from ...
(vn_nary_build_or_lookup): ... this which now wraps it.
* gcc.dg/torture/pr71866.c: New testcase.
From-SVN: r238334
Diffstat (limited to 'gcc/tree-ssa-sccvn.c')
-rw-r--r-- | gcc/tree-ssa-sccvn.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 9427bfc..bd752a5 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -1625,10 +1625,12 @@ vn_lookup_simplify_result (code_helper rcode, tree type, tree *ops) } /* Return a value-number for RCODE OPS... either by looking up an existing - value-number for the simplified result or by inserting the operation. */ + value-number for the simplified result or by inserting the operation if + INSERT is true. */ static tree -vn_nary_build_or_lookup (code_helper rcode, tree type, tree *ops) +vn_nary_build_or_lookup_1 (code_helper rcode, tree type, tree *ops, + bool insert) { tree result = NULL_TREE; /* We will be creating a value number for @@ -1658,7 +1660,7 @@ vn_nary_build_or_lookup (code_helper rcode, tree type, tree *ops) else { tree val = vn_lookup_simplify_result (rcode, type, ops); - if (!val) + if (!val && insert) { gimple_seq stmts = NULL; result = maybe_push_res_to_seq (rcode, type, ops, &stmts); @@ -1719,6 +1721,29 @@ vn_nary_build_or_lookup (code_helper rcode, tree type, tree *ops) return result; } +/* Return a value-number for RCODE OPS... either by looking up an existing + value-number for the simplified result or by inserting the operation. */ + +static tree +vn_nary_build_or_lookup (code_helper rcode, tree type, tree *ops) +{ + return vn_nary_build_or_lookup_1 (rcode, type, ops, true); +} + +/* Try to simplify the expression RCODE OPS... of type TYPE and return + its value if present. */ + +tree +vn_nary_simplify (vn_nary_op_t nary) +{ + if (nary->length > 3) + return NULL_TREE; + tree ops[3]; + memcpy (ops, nary->op, sizeof (tree) * nary->length); + return vn_nary_build_or_lookup_1 (nary->opcode, nary->type, ops, false); +} + + /* Callback for walk_non_aliased_vuses. Tries to perform a lookup from the statement defining VUSE and if not successful tries to translate *REFP and VR_ through an aggregate copy at the definition |