This short-cuts re-simplifying (convert ...)s which often are no-ops
because a conditional convert didn't match. So instead of throwing
the whole match-and-simplify machinery on such converts and yell
out that match.pd:961 triggered (that really happens often...) the
following simply does nothing for matching types.
Code-generation changes like
--- gimple-match.c.orig 2015-06-30 13:32:17.218895640 +0200
+++ gimple-match.c 2015-06-30 13:36:23.681291002 +0200
@@ -2771,21 +2771,33 @@
{
tree ops2[1], res;
ops2[0] = captures[2];
+ if (utype != TREE_TYPE (ops2[0])
+ && !useless_type_conversion_p (utype, TREE_TYPE (ops2[0])))
+ {
code_helper tem_code = NOP_EXPR;
tree tem_ops[3] = { ops2[0] };
gimple_resimplify1 (seq, &tem_code, utype, tem_ops, valueize);
res = maybe_push_res_to_seq (tem_code, utype, tem_ops, seq);
if (!res) return false;
+ }
+ else
+ res = ops2[0];
ops1[0] = res;
}
for GIMPLE and the following for GENERIC
--- generic-match.c.orig 2015-06-30 13:36:20.158257155 +0200
+++ generic-match.c 2015-06-30 13:36:23.707291254 +0200
@@ -2348,13 +2348,19 @@
{
tree ops2[1], res;
ops2[0] = captures[2];
+ if (TREE_TYPE (ops2[0]) != utype)
res = fold_build1_loc (loc, NOP_EXPR, utype, ops2[0]);
+ else
+ res = ops2[0];
ops1[0] = res;
}
Bootstrap and regtest running on x86_64-unknown-linux-gnu.
Richard.
2015-06-30 Richard Biener <[email protected]>
* genmatch.c (expr::gen_transform): Shortcut re-simplifying
of converts to avoid uninteresting noise from the conversion
simplifying patterns.
Index: gcc/genmatch.c
===================================================================
--- gcc/genmatch.c (revision 225163)
+++ gcc/genmatch.c (working copy)
@@ -1740,6 +1740,10 @@ expr::gen_transform (FILE *f, const char
if (gimple)
{
+ if (*operation == CONVERT_EXPR)
+ fprintf (f, " if (%s != TREE_TYPE (ops%d[0])\n"
+ " && !useless_type_conversion_p (%s, TREE_TYPE (ops%d[0])))\n"
+ " {\n", type, depth, type, depth);
/* ??? Building a stmt can fail for various reasons here, seq being
NULL or the stmt referencing SSA names occuring in abnormal PHIs.
So if we fail here we should continue matching other patterns. */
@@ -1752,9 +1756,15 @@ expr::gen_transform (FILE *f, const char
ops.length (), type);
fprintf (f, " res = maybe_push_res_to_seq (tem_code, %s, tem_ops,
seq);\n"
" if (!res) return false;\n", type);
+ if (*operation == CONVERT_EXPR)
+ fprintf (f, " }\n"
+ " else\n"
+ " res = ops%d[0];\n", depth);
}
else
{
+ if (*operation == CONVERT_EXPR)
+ fprintf (f, " if (TREE_TYPE (ops%d[0]) != %s)\n", depth, type);
if (operation->kind == id_base::CODE)
fprintf (f, " res = fold_build%d_loc (loc, %s, %s",
ops.length(), opr, type);
@@ -1764,6 +1774,9 @@ expr::gen_transform (FILE *f, const char
for (unsigned i = 0; i < ops.length (); ++i)
fprintf (f, ", ops%d[%u]", depth, i);
fprintf (f, ");\n");
+ if (*operation == CONVERT_EXPR)
+ fprintf (f, " else\n"
+ " res = ops%d[0];\n", depth);
}
fprintf (f, "%s = res;\n", dest);
fprintf (f, "}\n");