+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>
+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
--- /dev/null
+/* 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;
+}
/* 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);