Commit b7fe158a by Richard Biener Committed by Richard Biener

gimple-match.h (gimple_match_op::resimplify): New.

2019-07-09  Richard Biener  <rguenther@suse.de>

	* gimple-match.h (gimple_match_op::resimplify): New.
	(gimple_resimplify1, gimple_resimplify2, gimple_resimplify3,
	gimple_resimplify4, gimple_resimplify5): Remove.
	* gimple-match-head.c (gimple_resimplify1, gimple_resimplify2,
	gimple_resimplify3, gimple_resimplify4, gimple_resimplify5):
	Make static.
	(gimple_match_op::resimplify): New.
	* tree-ssa-sccvn.c (vn_nary_build_or_lookup_1): Valueize
	according to availability.  Use gimple_match_op::resimplify.

From-SVN: r273302
parent 49507955
2019-07-09 Richard Biener <rguenther@suse.de>
* gimple-match.h (gimple_match_op::resimplify): New.
(gimple_resimplify1, gimple_resimplify2, gimple_resimplify3,
gimple_resimplify4, gimple_resimplify5): Remove.
* gimple-match-head.c (gimple_resimplify1, gimple_resimplify2,
gimple_resimplify3, gimple_resimplify4, gimple_resimplify5):
Make static.
(gimple_match_op::resimplify): New.
* tree-ssa-sccvn.c (vn_nary_build_or_lookup_1): Valueize
according to availability. Use gimple_match_op::resimplify.
2019-07-09 Eric Botcazou <ebotcazou@adacore.com> 2019-07-09 Eric Botcazou <ebotcazou@adacore.com>
* ira-emit.c (emit_moves): Skip DEBUG_INSNs when setting the location. * ira-emit.c (emit_moves): Skip DEBUG_INSNs when setting the location.
......
...@@ -57,6 +57,16 @@ static bool gimple_simplify (gimple_match_op *, gimple_seq *, tree (*)(tree), ...@@ -57,6 +57,16 @@ static bool gimple_simplify (gimple_match_op *, gimple_seq *, tree (*)(tree),
code_helper, tree, tree, tree, tree, tree); code_helper, tree, tree, tree, tree, tree);
static bool gimple_simplify (gimple_match_op *, gimple_seq *, tree (*)(tree), static bool gimple_simplify (gimple_match_op *, gimple_seq *, tree (*)(tree),
code_helper, tree, tree, tree, tree, tree, tree); code_helper, tree, tree, tree, tree, tree, tree);
static bool gimple_resimplify1 (gimple_seq *, gimple_match_op *,
tree (*)(tree));
static bool gimple_resimplify2 (gimple_seq *, gimple_match_op *,
tree (*)(tree));
static bool gimple_resimplify3 (gimple_seq *, gimple_match_op *,
tree (*)(tree));
static bool gimple_resimplify4 (gimple_seq *, gimple_match_op *,
tree (*)(tree));
static bool gimple_resimplify5 (gimple_seq *, gimple_match_op *,
tree (*)(tree));
const unsigned int gimple_match_op::MAX_NUM_OPS; const unsigned int gimple_match_op::MAX_NUM_OPS;
...@@ -173,7 +183,7 @@ maybe_resimplify_conditional_op (gimple_seq *seq, gimple_match_op *res_op, ...@@ -173,7 +183,7 @@ maybe_resimplify_conditional_op (gimple_seq *seq, gimple_match_op *res_op,
RES_OP with a simplified and/or canonicalized result and RES_OP with a simplified and/or canonicalized result and
returns whether any change was made. */ returns whether any change was made. */
bool static bool
gimple_resimplify1 (gimple_seq *seq, gimple_match_op *res_op, gimple_resimplify1 (gimple_seq *seq, gimple_match_op *res_op,
tree (*valueize)(tree)) tree (*valueize)(tree))
{ {
...@@ -233,7 +243,7 @@ gimple_resimplify1 (gimple_seq *seq, gimple_match_op *res_op, ...@@ -233,7 +243,7 @@ gimple_resimplify1 (gimple_seq *seq, gimple_match_op *res_op,
RES_OP with a simplified and/or canonicalized result and RES_OP with a simplified and/or canonicalized result and
returns whether any change was made. */ returns whether any change was made. */
bool static bool
gimple_resimplify2 (gimple_seq *seq, gimple_match_op *res_op, gimple_resimplify2 (gimple_seq *seq, gimple_match_op *res_op,
tree (*valueize)(tree)) tree (*valueize)(tree))
{ {
...@@ -305,7 +315,7 @@ gimple_resimplify2 (gimple_seq *seq, gimple_match_op *res_op, ...@@ -305,7 +315,7 @@ gimple_resimplify2 (gimple_seq *seq, gimple_match_op *res_op,
RES_OP with a simplified and/or canonicalized result and RES_OP with a simplified and/or canonicalized result and
returns whether any change was made. */ returns whether any change was made. */
bool static bool
gimple_resimplify3 (gimple_seq *seq, gimple_match_op *res_op, gimple_resimplify3 (gimple_seq *seq, gimple_match_op *res_op,
tree (*valueize)(tree)) tree (*valueize)(tree))
{ {
...@@ -376,7 +386,7 @@ gimple_resimplify3 (gimple_seq *seq, gimple_match_op *res_op, ...@@ -376,7 +386,7 @@ gimple_resimplify3 (gimple_seq *seq, gimple_match_op *res_op,
RES_OP with a simplified and/or canonicalized result and RES_OP with a simplified and/or canonicalized result and
returns whether any change was made. */ returns whether any change was made. */
bool static bool
gimple_resimplify4 (gimple_seq *seq, gimple_match_op *res_op, gimple_resimplify4 (gimple_seq *seq, gimple_match_op *res_op,
tree (*valueize)(tree)) tree (*valueize)(tree))
{ {
...@@ -417,7 +427,7 @@ gimple_resimplify4 (gimple_seq *seq, gimple_match_op *res_op, ...@@ -417,7 +427,7 @@ gimple_resimplify4 (gimple_seq *seq, gimple_match_op *res_op,
RES_OP with a simplified and/or canonicalized result and RES_OP with a simplified and/or canonicalized result and
returns whether any change was made. */ returns whether any change was made. */
bool static bool
gimple_resimplify5 (gimple_seq *seq, gimple_match_op *res_op, gimple_resimplify5 (gimple_seq *seq, gimple_match_op *res_op,
tree (*valueize)(tree)) tree (*valueize)(tree))
{ {
...@@ -439,6 +449,30 @@ gimple_resimplify5 (gimple_seq *seq, gimple_match_op *res_op, ...@@ -439,6 +449,30 @@ gimple_resimplify5 (gimple_seq *seq, gimple_match_op *res_op,
return false; return false;
} }
/* Match and simplify the toplevel valueized operation THIS.
Replaces THIS with a simplified and/or canonicalized result and
returns whether any change was made. */
bool
gimple_match_op::resimplify (gimple_seq *seq, tree (*valueize)(tree))
{
switch (num_ops)
{
case 1:
return gimple_resimplify1 (seq, this, valueize);
case 2:
return gimple_resimplify2 (seq, this, valueize);
case 3:
return gimple_resimplify3 (seq, this, valueize);
case 4:
return gimple_resimplify4 (seq, this, valueize);
case 5:
return gimple_resimplify5 (seq, this, valueize);
default:
gcc_unreachable ();
}
}
/* If in GIMPLE the operation described by RES_OP should be single-rhs, /* If in GIMPLE the operation described by RES_OP should be single-rhs,
build a GENERIC tree for that expression and update RES_OP accordingly. */ build a GENERIC tree for that expression and update RES_OP accordingly. */
......
...@@ -105,6 +105,8 @@ struct gimple_match_op ...@@ -105,6 +105,8 @@ struct gimple_match_op
tree op_or_null (unsigned int) const; tree op_or_null (unsigned int) const;
bool resimplify (gimple_seq *, tree (*)(tree));
/* The maximum value of NUM_OPS. */ /* The maximum value of NUM_OPS. */
static const unsigned int MAX_NUM_OPS = 5; static const unsigned int MAX_NUM_OPS = 5;
...@@ -331,11 +333,6 @@ extern tree (*mprts_hook) (gimple_match_op *); ...@@ -331,11 +333,6 @@ extern tree (*mprts_hook) (gimple_match_op *);
bool gimple_simplify (gimple *, gimple_match_op *, gimple_seq *, bool gimple_simplify (gimple *, gimple_match_op *, gimple_seq *,
tree (*)(tree), tree (*)(tree)); tree (*)(tree), tree (*)(tree));
bool gimple_resimplify1 (gimple_seq *, gimple_match_op *, tree (*)(tree));
bool gimple_resimplify2 (gimple_seq *, gimple_match_op *, tree (*)(tree));
bool gimple_resimplify3 (gimple_seq *, gimple_match_op *, tree (*)(tree));
bool gimple_resimplify4 (gimple_seq *, gimple_match_op *, tree (*)(tree));
bool gimple_resimplify5 (gimple_seq *, gimple_match_op *, tree (*)(tree));
tree maybe_push_res_to_seq (gimple_match_op *, gimple_seq *, tree maybe_push_res_to_seq (gimple_match_op *, gimple_seq *,
tree res = NULL_TREE); tree res = NULL_TREE);
void maybe_build_generic_op (gimple_match_op *); void maybe_build_generic_op (gimple_match_op *);
......
...@@ -1968,21 +1968,25 @@ vn_nary_build_or_lookup_1 (gimple_match_op *res_op, bool insert) ...@@ -1968,21 +1968,25 @@ vn_nary_build_or_lookup_1 (gimple_match_op *res_op, bool insert)
RCODE (OPS...). RCODE (OPS...).
So first simplify and lookup this expression to see if it So first simplify and lookup this expression to see if it
is already available. */ is already available. */
mprts_hook = vn_lookup_simplify_result; /* For simplification valueize. */
bool res = false; unsigned i;
switch (TREE_CODE_LENGTH ((tree_code) res_op->code)) for (i = 0; i < res_op->num_ops; ++i)
if (TREE_CODE (res_op->ops[i]) == SSA_NAME)
{ {
case 1: tree tem = vn_valueize (res_op->ops[i]);
res = gimple_resimplify1 (NULL, res_op, vn_valueize); if (!tem)
break;
case 2:
res = gimple_resimplify2 (NULL, res_op, vn_valueize);
break;
case 3:
res = gimple_resimplify3 (NULL, res_op, vn_valueize);
break; break;
res_op->ops[i] = tem;
} }
/* If valueization of an operand fails (it is not available), skip
simplification. */
bool res = false;
if (i == res_op->num_ops)
{
mprts_hook = vn_lookup_simplify_result;
res = res_op->resimplify (NULL, vn_valueize);
mprts_hook = NULL; mprts_hook = NULL;
}
gimple *new_stmt = NULL; gimple *new_stmt = NULL;
if (res if (res
&& gimple_simplified_result_is_gimple_val (res_op)) && gimple_simplified_result_is_gimple_val (res_op))
......
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