* [PATCH] Fix PR65519
@ 2015-03-24 14:11 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2015-03-24 14:11 UTC (permalink / raw)
To: gcc-patches
The following fixes PR65519 - we were using gimple_build from
gimple_simplify which isn't a good idea as that doesn't properly
fail when materializing stmts with operands we don't want
(SSA_NAME_OCCURS_IN_ABNORMAL_PHI).
Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
Richard.
2015-03-24 Richard Biener <rguenther@suse.de>
PR middle-end/65519
* genmatch.c (expr::gen_transform): Re-write to avoid
using gimple_build.
* gnat.dg/specs/opt2.ads: New testcase.
Index: gcc/genmatch.c
===================================================================
--- gcc/genmatch.c (revision 221624)
+++ gcc/genmatch.c (working copy)
@@ -1742,22 +1742,18 @@ expr::gen_transform (FILE *f, const char
if (gimple)
{
- /* ??? Have another helper that is like gimple_build but may
- fail if seq == NULL. */
- fprintf (f, " if (!seq)\n"
- " {\n"
- " res = gimple_simplify (%s, %s", opr, type);
+ /* ??? 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. */
+ fprintf (f, " code_helper tem_code = %s;\n"
+ " tree tem_ops[3] = { ", opr);
for (unsigned i = 0; i < ops.length (); ++i)
- fprintf (f, ", ops%d[%u]", depth, i);
- fprintf (f, ", seq, valueize);\n");
- fprintf (f, " if (!res) return false;\n");
- fprintf (f, " }\n");
- fprintf (f, " else\n");
- fprintf (f, " res = gimple_build (seq, UNKNOWN_LOCATION, %s, %s",
- opr, type);
- for (unsigned i = 0; i < ops.length (); ++i)
- fprintf (f, ", ops%d[%u]", depth, i);
- fprintf (f, ", valueize);\n");
+ fprintf (f, "ops%d[%u]%s", depth, i,
+ i == ops.length () - 1 ? " };\n" : ", ");
+ fprintf (f, " gimple_resimplify%d (seq, &tem_code, %s, tem_ops, valueize);\n",
+ ops.length (), type);
+ fprintf (f, " res = maybe_push_res_to_seq (tem_code, %s, tem_ops, seq);\n"
+ " if (!res) return false;\n", type);
}
else
{
@@ -1771,7 +1767,7 @@ expr::gen_transform (FILE *f, const char
fprintf (f, ", ops%d[%u]", depth, i);
fprintf (f, ");\n");
}
- fprintf (f, " %s = res;\n", dest);
+ fprintf (f, "%s = res;\n", dest);
fprintf (f, "}\n");
}
Index: gcc/testsuite/gnat.dg/specs/opt2.ads
===================================================================
*** gcc/testsuite/gnat.dg/specs/opt2.ads (revision 0)
--- gcc/testsuite/gnat.dg/specs/opt2.ads (revision 0)
***************
*** 0 ****
--- 1,11 ----
+ -- { dg-do compile }
+ -- { dg-options "-O2" }
+
+ with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
+ with Interfaces; use Interfaces;
+
+ package Opt2 is
+
+ type Arr is array (Unsigned_32 range <>) of Unbounded_String;
+
+ end P;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-03-24 14:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-24 14:11 [PATCH] Fix PR65519 Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).