Commit 4f450a2b by Richard Biener Committed by Richard Biener

gimple-match-head.c (do_valueize): Return OP if valueize returns NULL_TREE.

2017-07-26  Richard Biener  <rguenther@suse.de>

	* gimple-match-head.c (do_valueize): Return OP if valueize
	returns NULL_TREE.
	(get_def): New helper to get at the def stmt of a SSA name
	if valueize allows.
	* genmatch.c (dt_node::gen_kids_1): Use get_def instead of
	do_valueize to get at the def stmt.
	(dt_operand::gen_gimple_expr): Simplify do_valueize calls.

	* gcc/testsuite/gcc.dg/pr70920-2.c: Adjust for transform already
	happening in ccp1.
	* gcc/testsuite/gcc.dg/pr70920-4.c: Likewise.

From-SVN: r250565
parent e1711448
2017-07-26 Richard Biener <rguenther@suse.de>
* gimple-match-head.c (do_valueize): Return OP if valueize
returns NULL_TREE.
(get_def): New helper to get at the def stmt of a SSA name
if valueize allows.
* genmatch.c (dt_node::gen_kids_1): Use get_def instead of
do_valueize to get at the def stmt.
(dt_operand::gen_gimple_expr): Simplify do_valueize calls.
2017-07-26 Wilco Dijkstra <wdijkstr@arm.com> 2017-07-26 Wilco Dijkstra <wdijkstr@arm.com>
PR middle-end/46932 PR middle-end/46932
......
...@@ -2646,6 +2646,7 @@ dt_operand::gen_gimple_expr (FILE *f, int indent) ...@@ -2646,6 +2646,7 @@ dt_operand::gen_gimple_expr (FILE *f, int indent)
expr *e = static_cast<expr *> (op); expr *e = static_cast<expr *> (op);
id_base *id = e->operation; id_base *id = e->operation;
unsigned n_ops = e->ops.length (); unsigned n_ops = e->ops.length ();
unsigned n_braces = 0;
for (unsigned i = 0; i < n_ops; ++i) for (unsigned i = 0; i < n_ops; ++i)
{ {
...@@ -2678,14 +2679,15 @@ dt_operand::gen_gimple_expr (FILE *f, int indent) ...@@ -2678,14 +2679,15 @@ dt_operand::gen_gimple_expr (FILE *f, int indent)
"if ((TREE_CODE (%s) == SSA_NAME\n", "if ((TREE_CODE (%s) == SSA_NAME\n",
child_opname); child_opname);
fprintf_indent (f, indent, fprintf_indent (f, indent,
" || is_gimple_min_invariant (%s))\n", " || is_gimple_min_invariant (%s)))\n",
child_opname); child_opname);
fprintf_indent (f, indent, fprintf_indent (f, indent,
" && (%s = do_valueize (valueize, %s)))\n",
child_opname, child_opname);
fprintf_indent (f, indent,
" {\n"); " {\n");
indent += 4; indent += 4;
n_braces++;
fprintf_indent (f, indent,
"%s = do_valueize (valueize, %s);\n",
child_opname, child_opname);
continue; continue;
} }
else else
...@@ -2698,10 +2700,8 @@ dt_operand::gen_gimple_expr (FILE *f, int indent) ...@@ -2698,10 +2700,8 @@ dt_operand::gen_gimple_expr (FILE *f, int indent)
"tree %s = gimple_call_arg (def, %u);\n", "tree %s = gimple_call_arg (def, %u);\n",
child_opname, i); child_opname, i);
fprintf_indent (f, indent, fprintf_indent (f, indent,
"if ((%s = do_valueize (valueize, %s)))\n", "%s = do_valueize (valueize, %s);\n",
child_opname, child_opname); child_opname, child_opname);
fprintf_indent (f, indent, " {\n");
indent += 4;
} }
/* While the toplevel operands are canonicalized by the caller /* While the toplevel operands are canonicalized by the caller
after valueizing operands of sub-expressions we have to after valueizing operands of sub-expressions we have to
...@@ -2726,7 +2726,7 @@ dt_operand::gen_gimple_expr (FILE *f, int indent) ...@@ -2726,7 +2726,7 @@ dt_operand::gen_gimple_expr (FILE *f, int indent)
} }
} }
return n_ops; return n_braces;
} }
/* Generate GENERIC matching code for the decision tree operand. */ /* Generate GENERIC matching code for the decision tree operand. */
...@@ -2867,14 +2867,10 @@ dt_node::gen_kids_1 (FILE *f, int indent, bool gimple, ...@@ -2867,14 +2867,10 @@ dt_node::gen_kids_1 (FILE *f, int indent, bool gimple,
fprintf_indent (f, indent, fprintf_indent (f, indent,
"case SSA_NAME:\n"); "case SSA_NAME:\n");
fprintf_indent (f, indent, fprintf_indent (f, indent,
" if (do_valueize (valueize, %s) != NULL_TREE)\n", " if (gimple *def_stmt = get_def (valueize, %s))\n",
kid_opname); kid_opname);
fprintf_indent (f, indent, fprintf_indent (f, indent,
" {\n"); " {\n");
fprintf_indent (f, indent,
" gimple *def_stmt = SSA_NAME_DEF_STMT (%s);\n",
kid_opname);
indent += 6; indent += 6;
if (exprs_len) if (exprs_len)
{ {
......
...@@ -779,10 +779,25 @@ inline tree ...@@ -779,10 +779,25 @@ inline tree
do_valueize (tree (*valueize)(tree), tree op) do_valueize (tree (*valueize)(tree), tree op)
{ {
if (valueize && TREE_CODE (op) == SSA_NAME) if (valueize && TREE_CODE (op) == SSA_NAME)
return valueize (op); {
tree tem = valueize (op);
if (tem)
return tem;
}
return op; return op;
} }
/* Helper for the autogenerated code, get at the definition of NAME when
VALUEIZE allows that. */
inline gimple *
get_def (tree (*valueize)(tree), tree name)
{
if (valueize && ! valueize (name))
return NULL;
return SSA_NAME_DEF_STMT (name);
}
/* Routine to determine if the types T1 and T2 are effectively /* Routine to determine if the types T1 and T2 are effectively
the same for GIMPLE. If T1 or T2 is not a type, the test the same for GIMPLE. If T1 or T2 is not a type, the test
applies to their TREE_TYPE. */ applies to their TREE_TYPE. */
......
2017-07-26 Richard Biener <rguenther@suse.de>
* gcc/testsuite/gcc.dg/pr70920-2.c: Adjust for transform already
happening in ccp1.
* gcc/testsuite/gcc.dg/pr70920-4.c: Likewise.
2017-07-26 Wilco Dijkstra <wdijkstr@arm.com> 2017-07-26 Wilco Dijkstra <wdijkstr@arm.com>
PR middle-end/46932 PR middle-end/46932
......
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-forwprop-details" } */ /* { dg-options "-O2 -fdump-tree-ccp1-details" } */
#include <stdint.h> #include <stdint.h>
...@@ -18,4 +18,4 @@ foo (int *a) ...@@ -18,4 +18,4 @@ foo (int *a)
} }
} }
/* { dg-final { scan-tree-dump "gimple_simplified to if \\(a_\[0-9\]*\\(D\\) == 0B\\)" "forwprop1" } } */ /* { dg-final { scan-tree-dump "gimple_simplified to if \\(a_\[0-9\]*\\(D\\) == 0B\\)" "ccp1" } } */
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-require-effective-target lp64 } */ /* { dg-require-effective-target lp64 } */
/* { dg-options "-O2 -fdump-tree-forwprop-details -Wno-int-to-pointer-cast" } */ /* { dg-options "-O2 -fdump-tree-ccp1 -Wno-int-to-pointer-cast" } */
#include <stdint.h> #include <stdint.h>
...@@ -19,4 +19,4 @@ foo (int a) ...@@ -19,4 +19,4 @@ foo (int a)
} }
} }
/* { dg-final { scan-tree-dump "if \\(_\[0-9\]* == 0\\)" "forwprop1" } } */ /* { dg-final { scan-tree-dump "if \\(a_\[0-9\]*\\(D\\) == 0\\)" "ccp1" } } */
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