]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR tree-optimization/83521 (ICE: verify_gimple failed (error: invalid...
authorJakub Jelinek <jakub@redhat.com>
Mon, 25 Jun 2018 17:03:26 +0000 (19:03 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 25 Jun 2018 17:03:26 +0000 (19:03 +0200)
Backported from mainline
2017-12-21  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/83521
* tree-ssa-phiopt.c (factor_out_conditional_conversion): Use
gimple_build_assign without code on result of
fold_build1 (VIEW_CONVERT_EXPR, ...), as it might not create
a VIEW_CONVERT_EXPR.

* gcc.dg/pr83521.c: New test.

From-SVN: r262047

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr83521.c [new file with mode: 0644]
gcc/tree-ssa-phiopt.c

index 78463eccedcf595b68cde4b7c13bdf94ecc7dad0..d67b8dbebdcc4c618f0fb9d6c04230844246a7d2 100644 (file)
@@ -1,6 +1,14 @@
 2018-06-25  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2017-12-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/83521
+       * tree-ssa-phiopt.c (factor_out_conditional_conversion): Use
+       gimple_build_assign without code on result of
+       fold_build1 (VIEW_CONVERT_EXPR, ...), as it might not create
+       a VIEW_CONVERT_EXPR.
+
        2017-12-19  Jakub Jelinek  <jakub@redhat.com>
 
        PR ipa/82801
index 069c4e2103365fe56b6147703bfad563e11d48f6..dd21e51e93c90da19d514c09a5ac5ef28daec2ee 100644 (file)
@@ -1,6 +1,11 @@
 2018-06-25  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2017-12-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/83521
+       * gcc.dg/pr83521.c: New test.
+
        2017-12-19  Jakub Jelinek  <jakub@redhat.com>
 
        PR ipa/82801
diff --git a/gcc/testsuite/gcc.dg/pr83521.c b/gcc/testsuite/gcc.dg/pr83521.c
new file mode 100644 (file)
index 0000000..fc7ca04
--- /dev/null
@@ -0,0 +1,10 @@
+/* PR tree-optimization/83521 */
+/* { dg-do compile } */
+/* { dg-options "-O1 -fno-tree-forwprop" } */
+
+int
+foo (unsigned int x, int y)
+{
+  int *z = (int *)&x;
+  return (y == 0) ? y : *z;
+}
index fb6e8be434346bc0fb8e290d47ee3e506d5b2f6c..5f92ce5d25ad7721b5a437658b4cbd680977cc84 100644 (file)
@@ -523,8 +523,12 @@ factor_out_conditional_conversion (edge e0, edge e1, gphi *phi,
 
   /* Create the conversion stmt and insert it.  */
   if (convert_code == VIEW_CONVERT_EXPR)
-    temp = fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (result), temp);
-  new_stmt = gimple_build_assign (result,  convert_code, temp);
+    {
+      temp = fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (result), temp);
+      new_stmt = gimple_build_assign (result, temp);
+    }
+  else
+    new_stmt = gimple_build_assign (result, convert_code, temp);
   gsi = gsi_after_labels (gimple_bb (phi));
   gsi_insert_before (&gsi, new_stmt, GSI_SAME_STMT);