re PR middle-end/81207 (tree check fail in simplify_builtin_call)
authorJakub Jelinek <jakub@redhat.com>
Tue, 27 Jun 2017 07:22:14 +0000 (09:22 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 27 Jun 2017 07:22:14 +0000 (09:22 +0200)
PR middle-end/81207
* gimple-fold.c (replace_call_with_call_and_fold): Handle
gimple_vuse copying separately from gimple_vdef copying.

* gcc.c-torture/compile/pr81207.c: New test.

From-SVN: r249677

gcc/ChangeLog
gcc/gimple-fold.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr81207.c [new file with mode: 0644]

index d2c4260faf2108ba052256f10ab8d56aa5cfa55f..e9dc0d6f2bac71fd21d95d2803de9acd3ec4b41f 100644 (file)
@@ -1,10 +1,14 @@
+2017-06-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/81207
+       * gimple-fold.c (replace_call_with_call_and_fold): Handle
+       gimple_vuse copying separately from gimple_vdef copying.
+
 2017-06-27  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>
 
        * value-prof.c (free_hist): Remove call to memset and the enclosing if
        condition.
 
-gcc/ChangeLog:
-
 2017-06-26  Jerome Lambourg  <lambourg@adacore.com>
             Olivier Hainque  <hainque@adacore.com>
 
index a00c2c88713bb39c2040928ce8b03a059279b3c2..8e315fe2e2ed7a7a3290356df76b55297141f119 100644 (file)
@@ -607,9 +607,10 @@ replace_call_with_call_and_fold (gimple_stmt_iterator *gsi, gimple *repl)
       && TREE_CODE (gimple_vdef (stmt)) == SSA_NAME)
     {
       gimple_set_vdef (repl, gimple_vdef (stmt));
-      gimple_set_vuse (repl, gimple_vuse (stmt));
       SSA_NAME_DEF_STMT (gimple_vdef (repl)) = repl;
     }
+  if (gimple_vuse (stmt))
+    gimple_set_vuse (repl, gimple_vuse (stmt));
   gsi_replace (gsi, repl, false);
   fold_stmt (gsi);
 }
index 38e5c7a94348c0c695f2c17770dee0874cbbbbf8..0217b7f0beef7c6c2dc185c1291e99d4f729a24a 100644 (file)
@@ -1,3 +1,8 @@
+2017-06-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/81207
+       * gcc.c-torture/compile/pr81207.c: New test.
+
 2017-06-27  Marek Polacek  <polacek@redhat.com>
 
        PR bootstrap/81216
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr81207.c b/gcc/testsuite/gcc.c-torture/compile/pr81207.c
new file mode 100644 (file)
index 0000000..f0faa8c
--- /dev/null
@@ -0,0 +1,13 @@
+/* PR middle-end/81207 */
+
+static const char *b[2] = { "'", "" };
+
+int
+foo (const char *d)
+{
+  int e;
+  for (e = 0; b[e]; e++)
+    if (__builtin_strstr (d, b[e]))
+      return 1;
+  return 0;
+}