Re: [PATCH] Fix cond-expr handling in genmatch

2016-10-18 Thread Richard Biener
On Mon, 17 Oct 2016, Richard Biener wrote:

> 
> This fixes matching of toplevel (cond (lt @1 @2) ...) as reported by
> Bin to me privately.
> 
> Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

This is what I applied.

Richard.

2016-10-18  Richard Biener  

* genmatch.c (dt_operand::gen_gimple_expr): Use get_name to
get at the operand to look at with TREE_OPERAND for generic
sub-nodes.

Index: gcc/genmatch.c
===
--- gcc/genmatch.c  (revision 241228)
+++ gcc/genmatch.c  (working copy)
@@ -2644,9 +2644,19 @@ dt_operand::gen_gimple_expr (FILE *f, in
  /* ???  If this is a memory operation we can't (and should not)
 match this.  The only sensible operand types are
 SSA names and invariants.  */
- fprintf_indent (f, indent,
- "tree %s = TREE_OPERAND (gimple_assign_rhs1 
(def), %i);\n",
- child_opname, i);
+ if (e->is_generic)
+   {
+ char opname[20];
+ get_name (opname);
+ fprintf_indent (f, indent,
+ "tree %s = TREE_OPERAND (%s, %i);\n",
+ child_opname, opname, i);
+   }
+ else
+   fprintf_indent (f, indent,
+   "tree %s = TREE_OPERAND "
+   "(gimple_assign_rhs1 (def), %i);\n",
+   child_opname, i);
  fprintf_indent (f, indent,
  "if ((TREE_CODE (%s) == SSA_NAME\n",
  child_opname);


[PATCH] Fix cond-expr handling in genmatch

2016-10-17 Thread Richard Biener

This fixes matching of toplevel (cond (lt @1 @2) ...) as reported by
Bin to me privately.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2016-10-17  Richard Biener  

* genmatch.c (dt_operand::gen_gimple_expr): Use get_name to
get at the operand to look at with TREE_OPERAND for generic
sub-nodes.

Index: gcc/genmatch.c
===
--- gcc/genmatch.c  (revision 241228)
+++ gcc/genmatch.c  (working copy)
@@ -2644,9 +2652,11 @@ dt_operand::gen_gimple_expr (FILE *f, in
  /* ???  If this is a memory operation we can't (and should not)
 match this.  The only sensible operand types are
 SSA names and invariants.  */
+ char opname[20];
+ get_name (opname);
  fprintf_indent (f, indent,
- "tree %s = TREE_OPERAND (gimple_assign_rhs1 
(def), %i);\n",
- child_opname, i);
+ "tree %s = TREE_OPERAND (%s, %i);\n",
+ child_opname, opname, i);
  fprintf_indent (f, indent,
  "if ((TREE_CODE (%s) == SSA_NAME\n",
  child_opname);