On Thu, Dec 29, 2016 at 10:18:34PM +0100, Jakub Jelinek wrote: > On Tue, Dec 20, 2016 at 09:45:03PM +0100, Jakub Jelinek wrote: > > That is what I tried first, but there is some bug in genmatch.c that > > prevents it. The: > > (for vec (VECTOR_CST CONSTRUCTOR) > > (simplify > > (shiftrotate @0 vec@1) > > results in case SSA_NAME: being added to a switch: > > case SSA_NAME: > > if (do_valueize (valueize, op1) != NULL_TREE) > > { > > gimple *def_stmt = SSA_NAME_DEF_STMT (op1); > > if (gassign *def = dyn_cast <gassign *> (def_stmt)) > > switch (gimple_assign_rhs_code (def)) > > { > > case CONSTRUCTOR: > > and the SSA_NAME@1 in another simplification resulted in another > > case SSA_NAME: > > into the same switch (rather than appending to the case SSA_NAME). > > This patch attempts to deal with that. The change for the new version of > the patch with SSA_NAME@1 I'll post right away is (twice). Two case SSA_NAME: > in a single switch of course don't work well.
Oops, forgot to add the actual patch, here it is: 2017-01-02 Jakub Jelinek <ja...@redhat.com> * genmatch.c (dt_node::gen_kids_1): If generic_exprs include SSA_NAME and exprs_len || fns_len, emit the code for SSA_NAME next to the exprs and fns handling, rather than in a separate case SSA_NAME. --- gcc/genmatch.c.jj 2016-11-09 16:34:58.000000000 +0100 +++ gcc/genmatch.c 2016-12-29 22:11:25.088950033 +0100 @@ -2913,6 +2913,20 @@ dt_node::gen_kids_1 (FILE *f, int indent indent -= 6; fprintf_indent (f, indent, " }\n"); + /* See if there is SSA_NAME among generic_exprs and if yes, emit it + here rather than in the next loop. */ + for (unsigned i = 0; i < generic_exprs.length (); ++i) + { + expr *e = as_a <expr *>(generic_exprs[i]->op); + id_base *op = e->operation; + if (*op == SSA_NAME && (exprs_len || fns_len)) + { + fprintf_indent (f, indent + 4, "{\n"); + generic_exprs[i]->gen (f, indent + 6, gimple); + fprintf_indent (f, indent + 4, "}\n"); + } + } + fprintf_indent (f, indent, " break;\n"); } @@ -2922,6 +2936,9 @@ dt_node::gen_kids_1 (FILE *f, int indent id_base *op = e->operation; if (*op == CONVERT_EXPR || *op == NOP_EXPR) fprintf_indent (f, indent, "CASE_CONVERT:\n"); + else if (*op == SSA_NAME && (exprs_len || fns_len)) + /* Already handled above. */ + continue; else fprintf_indent (f, indent, "case %s:\n", op->id); fprintf_indent (f, indent, " {\n"); Jakub