From: Jakub Jelinek Date: Thu, 21 Dec 2017 19:26:34 +0000 (+0100) Subject: re PR tree-optimization/83521 (ICE: verify_gimple failed (error: invalid operand... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a4710e09ed089313e3d4189d00fcfc487262e05a;p=gcc.git re PR tree-optimization/83521 (ICE: verify_gimple failed (error: invalid operand in unary operation)) 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9bc3ba31d90..2b1aa73775a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2017-12-21 Jakub Jelinek + + 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 Steve Ellcey diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d6928f00fbd..566efde7a33 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-12-21 Jakub Jelinek + + PR tree-optimization/83521 + * gcc.dg/pr83521.c: New test. + 2017-12-21 Nathan Sidwell PR c++/83406 diff --git a/gcc/testsuite/gcc.dg/pr83521.c b/gcc/testsuite/gcc.dg/pr83521.c new file mode 100644 index 00000000000..fc7ca04d1b4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr83521.c @@ -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; +} diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c index 71e7b67bf52..9e6eb9c41dd 100644 --- a/gcc/tree-ssa-phiopt.c +++ b/gcc/tree-ssa-phiopt.c @@ -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);