From 351168fe551a792fac3dac3359de72c1bcdc651e Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Thu, 14 Jul 2016 12:15:38 +0000 Subject: re PR tree-optimization/71866 (gcc locks up after fix for PR70159) 2016-07-14 Richard Biener 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 --- gcc/tree-ssa-sccvn.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'gcc/tree-ssa-sccvn.c') 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 -- cgit v1.1