Commit 34050b6b by Richard Biener Committed by Richard Biener

gimple-match.h (mprts_hook): Declare.

2015-10-01  Richard Biener  <rguenther@suse.de>

	* gimple-match.h (mprts_hook): Declare.
	* gimple-match.head.c (mprts_hook): Define.
	(maybe_push_res_to_seq): Use new hook.
	* gimple-fold.c (gimple_fold_stmt_to_constant_1): Likewise.
	* tree-ssa-sccvn.h (vn_ssa_aux::expr): Change to a gimple_seq.
	(vn_ssa_aux::has_constants): Remove.
	* tree-ssa-sccvn.c: Include gimple-match.h.
	(VN_INFO_GET): Assert we don't re-use SSA names.
	(vn_get_expr_for): Remove.
	(expr_has_constants): Likewise.
	(stmt_has_constants): Likewise.
	(simplify_binary_expression): Likewise.
	(simplify_unary_expression): Likewise.
	(vn_lookup_simplify_result): New hook.
	(visit_copy): Adjust.
	(visit_reference_op_call): Likewise.
	(visit_phi): Likewise.
	(visit_use): Likewise.
	(process_scc): Likewise.
	(init_scc_vn): Likewise.
	(visit_reference_op_load): Likewise.  Use match-and-simplify and
	a gimple seq for inserted expressions.
	(try_to_simplify): Remove GENERIC stmt combining code.
	(sccvn_dom_walker::before_dom_children): Use match-and-simplify.
	* tree-ssa-pre.c (eliminate_insert): Adjust.
	(eliminate_dom_walker::before_dom_children): Likewise.

	* gcc.dg/tree-ssa/ssa-fre-7.c: Adjust.
	* gcc.dg/tree-ssa/ssa-fre-8.c: Likewise.

From-SVN: r228320
parent e01c66ca
2015-10-01 Richard Biener <rguenther@suse.de>
* gimple-match.h (mprts_hook): Declare.
* gimple-match.head.c (mprts_hook): Define.
(maybe_push_res_to_seq): Use new hook.
* gimple-fold.c (gimple_fold_stmt_to_constant_1): Likewise.
* tree-ssa-sccvn.h (vn_ssa_aux::expr): Change to a gimple_seq.
(vn_ssa_aux::has_constants): Remove.
* tree-ssa-sccvn.c: Include gimple-match.h.
(VN_INFO_GET): Assert we don't re-use SSA names.
(vn_get_expr_for): Remove.
(expr_has_constants): Likewise.
(stmt_has_constants): Likewise.
(simplify_binary_expression): Likewise.
(simplify_unary_expression): Likewise.
(vn_lookup_simplify_result): New hook.
(visit_copy): Adjust.
(visit_reference_op_call): Likewise.
(visit_phi): Likewise.
(visit_use): Likewise.
(process_scc): Likewise.
(init_scc_vn): Likewise.
(visit_reference_op_load): Likewise. Use match-and-simplify and
a gimple seq for inserted expressions.
(try_to_simplify): Remove GENERIC stmt combining code.
(sccvn_dom_walker::before_dom_children): Use match-and-simplify.
* tree-ssa-pre.c (eliminate_insert): Adjust.
(eliminate_dom_walker::before_dom_children): Likewise.
2015-10-01 Segher Boessenkool <segher@kernel.crashing.org>
* doc/invoke.texi (Optimization Options): Add
......@@ -4877,13 +4877,18 @@ gimple_fold_stmt_to_constant_1 (gimple *stmt, tree (*valueize) (tree),
edges if there are intermediate VARYING defs. For this reason
do not follow SSA edges here even though SCCVN can technically
just deal fine with that. */
if (gimple_simplify (stmt, &rcode, ops, NULL, gvalueize, valueize)
&& rcode.is_tree_code ()
if (gimple_simplify (stmt, &rcode, ops, NULL, gvalueize, valueize))
{
tree res = NULL_TREE;
if (rcode.is_tree_code ()
&& (TREE_CODE_LENGTH ((tree_code) rcode) == 0
|| ((tree_code) rcode) == ADDR_EXPR)
&& is_gimple_val (ops[0]))
res = ops[0];
else if (mprts_hook)
res = mprts_hook (rcode, gimple_expr_type (stmt), ops);
if (res)
{
tree res = ops[0];
if (dump_file && dump_flags & TDF_DETAILS)
{
fprintf (dump_file, "Match-and-simplified ");
......@@ -4894,6 +4899,7 @@ gimple_fold_stmt_to_constant_1 (gimple *stmt, tree (*valueize) (tree),
}
return res;
}
}
location_t loc = gimple_location (stmt);
switch (gimple_code (stmt))
......
......@@ -293,6 +293,8 @@ maybe_build_generic_op (enum tree_code code, tree type,
}
}
tree (*mprts_hook) (code_helper, tree, tree *);
/* Push the exploded expression described by RCODE, TYPE and OPS
as a statement to SEQ if necessary and return a gimple value
denoting the value of the expression. If RES is not NULL
......@@ -310,6 +312,12 @@ maybe_push_res_to_seq (code_helper rcode, tree type, tree *ops,
|| ((tree_code) rcode) == ADDR_EXPR)
&& is_gimple_val (ops[0]))
return ops[0];
if (mprts_hook)
{
tree tem = mprts_hook (rcode, type, ops);
if (tem)
return tem;
}
if (!seq)
return NULL_TREE;
/* Play safe and do not allow abnormals to be mentioned in
......
......@@ -40,6 +40,8 @@ private:
int rep;
};
extern tree (*mprts_hook) (code_helper, tree, tree *);
bool gimple_simplify (gimple *, code_helper *, tree *, gimple_seq *,
tree (*)(tree), tree (*)(tree));
tree maybe_push_res_to_seq (code_helper, tree, tree *,
......
2015-10-01 Richard Biener <rguenther@suse.de>
* gcc.dg/tree-ssa/ssa-fre-7.c: Adjust.
* gcc.dg/tree-ssa/ssa-fre-8.c: Likewise.
2015-09-30 Jeff Law <law@redhat.com>
* gcc.dg/tree-ssa/ssa-dom-branch-1.c: New test.
......
......@@ -29,8 +29,8 @@ intflt foo(intflt j)
return a.u.k;
}
/* { dg-final { scan-tree-dump-times "Inserted pretmp" 1 "fre1" } } */
/* { dg-final { scan-tree-dump-times "Replaced a.u.f with pretmp" 3 "fre1" } } */
/* { dg-final { scan-tree-dump-times "Inserted" 1 "fre1" } } */
/* { dg-final { scan-tree-dump-times "Replaced a.u.f with" 3 "fre1" } } */
/* { dg-final { scan-tree-dump-times "Replaced a.u.k with j" 1 "fre1" } } */
/* { dg-final { scan-tree-dump "= VIEW_CONVERT_EXPR<float>\\\(j_" "fre1" } } */
/* { dg-final { scan-tree-dump "return j" "optimized" } } */
......@@ -28,5 +28,5 @@ intflt foo(int i, int b)
}
}
/* { dg-final { scan-tree-dump-times "Replaced u.f with pretmp" 2 "fre1" } } */
/* { dg-final { scan-tree-dump-times "Inserted pretmp" 2 "fre1" } } */
/* { dg-final { scan-tree-dump-times "Replaced u.f with" 2 "fre1" } } */
/* { dg-final { scan-tree-dump-times "Inserted" 2 "fre1" } } */
......@@ -3945,21 +3945,23 @@ eliminate_push_avail (tree op)
static tree
eliminate_insert (gimple_stmt_iterator *gsi, tree val)
{
tree expr = vn_get_expr_for (val);
if (!CONVERT_EXPR_P (expr)
&& TREE_CODE (expr) != VIEW_CONVERT_EXPR)
gimple *stmt = gimple_seq_first_stmt (VN_INFO (val)->expr);
if (!is_gimple_assign (stmt)
|| (!CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (stmt))
&& gimple_assign_rhs_code (stmt) != VIEW_CONVERT_EXPR))
return NULL_TREE;
tree op = TREE_OPERAND (expr, 0);
tree op = gimple_assign_rhs1 (stmt);
if (gimple_assign_rhs_code (stmt) == VIEW_CONVERT_EXPR)
op = TREE_OPERAND (op, 0);
tree leader = TREE_CODE (op) == SSA_NAME ? eliminate_avail (op) : op;
if (!leader)
return NULL_TREE;
tree res = make_temp_ssa_name (TREE_TYPE (val), NULL, "pretmp");
gassign *tem = gimple_build_assign (res,
fold_build1 (TREE_CODE (expr),
TREE_TYPE (expr), leader));
gsi_insert_before (gsi, tem, GSI_SAME_STMT);
gimple_seq stmts = NULL;
tree res = gimple_build (&stmts, gimple_assign_rhs_code (stmt),
TREE_TYPE (val), leader);
gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
VN_INFO_GET (res)->valnum = val;
if (TREE_CODE (leader) == SSA_NAME)
......@@ -3969,7 +3971,7 @@ eliminate_insert (gimple_stmt_iterator *gsi, tree val)
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "Inserted ");
print_gimple_stmt (dump_file, tem, 0, 0);
print_gimple_stmt (dump_file, SSA_NAME_DEF_STMT (res), 0, 0);
}
return res;
......@@ -4093,7 +4095,7 @@ eliminate_dom_walker::before_dom_children (basic_block b)
if (val != VN_TOP
&& TREE_CODE (val) == SSA_NAME
&& VN_INFO (val)->needs_insertion
&& VN_INFO (val)->expr != NULL_TREE
&& VN_INFO (val)->expr != NULL
&& (sprime = eliminate_insert (&gsi, val)) != NULL_TREE)
eliminate_push_avail (sprime);
}
......
......@@ -165,8 +165,8 @@ typedef struct vn_ssa_aux
{
/* Value number. This may be an SSA name or a constant. */
tree valnum;
/* Representative expression, if not a direct constant. */
tree expr;
/* Statements to insert if needs_insertion is true. */
gimple_seq expr;
/* Unique identifier that all expressions with the same value have. */
unsigned int value_id;
......@@ -177,8 +177,6 @@ typedef struct vn_ssa_aux
unsigned visited : 1;
unsigned on_sccstack : 1;
/* Whether the representative expression contains constants. */
unsigned has_constants : 1;
/* Whether the SSA_NAME has been value numbered already. This is
only saying whether visit_use has been called on it at least
once. It cannot be used to avoid visitation for SSA_NAME's
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment