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> 2015-10-01 Segher Boessenkool <segher@kernel.crashing.org>
* doc/invoke.texi (Optimization Options): Add * doc/invoke.texi (Optimization Options): Add
...@@ -4877,22 +4877,28 @@ gimple_fold_stmt_to_constant_1 (gimple *stmt, tree (*valueize) (tree), ...@@ -4877,22 +4877,28 @@ gimple_fold_stmt_to_constant_1 (gimple *stmt, tree (*valueize) (tree),
edges if there are intermediate VARYING defs. For this reason edges if there are intermediate VARYING defs. For this reason
do not follow SSA edges here even though SCCVN can technically do not follow SSA edges here even though SCCVN can technically
just deal fine with that. */ just deal fine with that. */
if (gimple_simplify (stmt, &rcode, ops, NULL, gvalueize, valueize) if (gimple_simplify (stmt, &rcode, ops, NULL, gvalueize, valueize))
&& rcode.is_tree_code () {
&& (TREE_CODE_LENGTH ((tree_code) rcode) == 0 tree res = NULL_TREE;
|| ((tree_code) rcode) == ADDR_EXPR) if (rcode.is_tree_code ()
&& is_gimple_val (ops[0])) && (TREE_CODE_LENGTH ((tree_code) rcode) == 0
{ || ((tree_code) rcode) == ADDR_EXPR)
tree res = ops[0]; && is_gimple_val (ops[0]))
if (dump_file && dump_flags & TDF_DETAILS) res = ops[0];
else if (mprts_hook)
res = mprts_hook (rcode, gimple_expr_type (stmt), ops);
if (res)
{ {
fprintf (dump_file, "Match-and-simplified "); if (dump_file && dump_flags & TDF_DETAILS)
print_gimple_expr (dump_file, stmt, 0, TDF_SLIM); {
fprintf (dump_file, " to "); fprintf (dump_file, "Match-and-simplified ");
print_generic_expr (dump_file, res, 0); print_gimple_expr (dump_file, stmt, 0, TDF_SLIM);
fprintf (dump_file, "\n"); fprintf (dump_file, " to ");
print_generic_expr (dump_file, res, 0);
fprintf (dump_file, "\n");
}
return res;
} }
return res;
} }
location_t loc = gimple_location (stmt); location_t loc = gimple_location (stmt);
......
...@@ -293,6 +293,8 @@ maybe_build_generic_op (enum tree_code code, tree type, ...@@ -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 /* Push the exploded expression described by RCODE, TYPE and OPS
as a statement to SEQ if necessary and return a gimple value as a statement to SEQ if necessary and return a gimple value
denoting the value of the expression. If RES is not NULL 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, ...@@ -310,6 +312,12 @@ maybe_push_res_to_seq (code_helper rcode, tree type, tree *ops,
|| ((tree_code) rcode) == ADDR_EXPR) || ((tree_code) rcode) == ADDR_EXPR)
&& is_gimple_val (ops[0])) && is_gimple_val (ops[0]))
return ops[0]; return ops[0];
if (mprts_hook)
{
tree tem = mprts_hook (rcode, type, ops);
if (tem)
return tem;
}
if (!seq) if (!seq)
return NULL_TREE; return NULL_TREE;
/* Play safe and do not allow abnormals to be mentioned in /* Play safe and do not allow abnormals to be mentioned in
......
...@@ -40,6 +40,8 @@ private: ...@@ -40,6 +40,8 @@ private:
int rep; int rep;
}; };
extern tree (*mprts_hook) (code_helper, tree, tree *);
bool gimple_simplify (gimple *, code_helper *, tree *, gimple_seq *, bool gimple_simplify (gimple *, code_helper *, tree *, gimple_seq *,
tree (*)(tree), tree (*)(tree)); tree (*)(tree), tree (*)(tree));
tree maybe_push_res_to_seq (code_helper, 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> 2015-09-30 Jeff Law <law@redhat.com>
* gcc.dg/tree-ssa/ssa-dom-branch-1.c: New test. * gcc.dg/tree-ssa/ssa-dom-branch-1.c: New test.
......
...@@ -29,8 +29,8 @@ intflt foo(intflt j) ...@@ -29,8 +29,8 @@ intflt foo(intflt j)
return a.u.k; return a.u.k;
} }
/* { dg-final { scan-tree-dump-times "Inserted pretmp" 1 "fre1" } } */ /* { dg-final { scan-tree-dump-times "Inserted" 1 "fre1" } } */
/* { dg-final { scan-tree-dump-times "Replaced a.u.f with pretmp" 3 "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-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 "= VIEW_CONVERT_EXPR<float>\\\(j_" "fre1" } } */
/* { dg-final { scan-tree-dump "return j" "optimized" } } */ /* { dg-final { scan-tree-dump "return j" "optimized" } } */
...@@ -28,5 +28,5 @@ intflt foo(int i, int b) ...@@ -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 "Replaced u.f with" 2 "fre1" } } */
/* { dg-final { scan-tree-dump-times "Inserted pretmp" 2 "fre1" } } */ /* { dg-final { scan-tree-dump-times "Inserted" 2 "fre1" } } */
...@@ -3945,21 +3945,23 @@ eliminate_push_avail (tree op) ...@@ -3945,21 +3945,23 @@ eliminate_push_avail (tree op)
static tree static tree
eliminate_insert (gimple_stmt_iterator *gsi, tree val) eliminate_insert (gimple_stmt_iterator *gsi, tree val)
{ {
tree expr = vn_get_expr_for (val); gimple *stmt = gimple_seq_first_stmt (VN_INFO (val)->expr);
if (!CONVERT_EXPR_P (expr) if (!is_gimple_assign (stmt)
&& TREE_CODE (expr) != VIEW_CONVERT_EXPR) || (!CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (stmt))
&& gimple_assign_rhs_code (stmt) != VIEW_CONVERT_EXPR))
return NULL_TREE; 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; tree leader = TREE_CODE (op) == SSA_NAME ? eliminate_avail (op) : op;
if (!leader) if (!leader)
return NULL_TREE; return NULL_TREE;
tree res = make_temp_ssa_name (TREE_TYPE (val), NULL, "pretmp"); gimple_seq stmts = NULL;
gassign *tem = gimple_build_assign (res, tree res = gimple_build (&stmts, gimple_assign_rhs_code (stmt),
fold_build1 (TREE_CODE (expr), TREE_TYPE (val), leader);
TREE_TYPE (expr), leader)); gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
gsi_insert_before (gsi, tem, GSI_SAME_STMT);
VN_INFO_GET (res)->valnum = val; VN_INFO_GET (res)->valnum = val;
if (TREE_CODE (leader) == SSA_NAME) if (TREE_CODE (leader) == SSA_NAME)
...@@ -3969,7 +3971,7 @@ eliminate_insert (gimple_stmt_iterator *gsi, tree val) ...@@ -3969,7 +3971,7 @@ eliminate_insert (gimple_stmt_iterator *gsi, tree val)
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
{ {
fprintf (dump_file, "Inserted "); 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; return res;
...@@ -4093,7 +4095,7 @@ eliminate_dom_walker::before_dom_children (basic_block b) ...@@ -4093,7 +4095,7 @@ eliminate_dom_walker::before_dom_children (basic_block b)
if (val != VN_TOP if (val != VN_TOP
&& TREE_CODE (val) == SSA_NAME && TREE_CODE (val) == SSA_NAME
&& VN_INFO (val)->needs_insertion && VN_INFO (val)->needs_insertion
&& VN_INFO (val)->expr != NULL_TREE && VN_INFO (val)->expr != NULL
&& (sprime = eliminate_insert (&gsi, val)) != NULL_TREE) && (sprime = eliminate_insert (&gsi, val)) != NULL_TREE)
eliminate_push_avail (sprime); eliminate_push_avail (sprime);
} }
......
...@@ -165,8 +165,8 @@ typedef struct vn_ssa_aux ...@@ -165,8 +165,8 @@ typedef struct vn_ssa_aux
{ {
/* Value number. This may be an SSA name or a constant. */ /* Value number. This may be an SSA name or a constant. */
tree valnum; tree valnum;
/* Representative expression, if not a direct constant. */ /* Statements to insert if needs_insertion is true. */
tree expr; gimple_seq expr;
/* Unique identifier that all expressions with the same value have. */ /* Unique identifier that all expressions with the same value have. */
unsigned int value_id; unsigned int value_id;
...@@ -177,8 +177,6 @@ typedef struct vn_ssa_aux ...@@ -177,8 +177,6 @@ typedef struct vn_ssa_aux
unsigned visited : 1; unsigned visited : 1;
unsigned on_sccstack : 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 /* Whether the SSA_NAME has been value numbered already. This is
only saying whether visit_use has been called on it at least only saying whether visit_use has been called on it at least
once. It cannot be used to avoid visitation for SSA_NAME's 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