re PR tree-optimization/83521 (ICE: verify_gimple failed (error: invalid operand...
authorJakub Jelinek <jakub@redhat.com>
Thu, 21 Dec 2017 19:26:34 +0000 (20:26 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 21 Dec 2017 19:26:34 +0000 (20:26 +0100)
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: r255952

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

index 9bc3ba31d90db050b0cd2b9ad5f0aad9c22cf525..2b1aa73775ac7b22e5f012fbc2b314fcabc02d76 100644 (file)
@@ -1,3 +1,11 @@
+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-21  Andrew Pinski  <apinski@cavium.com>
            Steve Ellcey  <sellcey@cavium.com>
 
index d6928f00fbd203eabb78c25ffbd292b3ad907030..566efde7a336526d8b6087a64e167b38a6774be8 100644 (file)
@@ -1,3 +1,8 @@
+2017-12-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/83521
+       * gcc.dg/pr83521.c: New test.
+
 2017-12-21  Nathan Sidwell  <nathan@acm.org>
 
        PR c++/83406
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 71e7b67bf52e62a0b74fcfe826113d46e4727717..9e6eb9c41dd4ddf67aaed52d186d09b76347c66f 100644 (file)
@@ -548,8 +548,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);