From: Jakub Jelinek Date: Mon, 12 Jun 2017 10:45:52 +0000 (+0200) Subject: re PR tree-optimization/81003 (ICE: tree check: expected ssa_name, have integer_cst... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=aebce39694e2ce735fa12cdcdcd32d9e1984f102;p=gcc.git re PR tree-optimization/81003 (ICE: tree check: expected ssa_name, have integer_cst in optimize_range_tests_to_bit_test, at tree-ssa-reassoc.c:2782) PR tree-optimization/81003 * tree-ssa-reassoc.c (force_into_ssa_name): New function. (update_range_test): Use it instead of force_gimple_operand_gsi. * gcc.c-torture/compile/pr81003.c: New test. From-SVN: r249114 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9a95c6ce5cb..9dbcf02abf0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-06-12 Jakub Jelinek + + PR tree-optimization/81003 + * tree-ssa-reassoc.c (force_into_ssa_name): New function. + (update_range_test): Use it instead of force_gimple_operand_gsi. + 2017-06-12 Richard Biener PR tree-optimization/81053 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 71be107cae2..84670eebf0f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-06-12 Jakub Jelinek + + PR tree-optimization/81003 + * gcc.c-torture/compile/pr81003.c: New test. + 2017-06-12 Richard Biener PR tree-optimization/81053 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr81003.c b/gcc/testsuite/gcc.c-torture/compile/pr81003.c new file mode 100644 index 00000000000..26117b638c4 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr81003.c @@ -0,0 +1,10 @@ +/* PR tree-optimization/81003 */ + +unsigned int a, b; + +void +foo (void) +{ + for (b = 0; b < 13; b += 2) + a &= !!b; +} diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index 6831f447451..35eb72ce310 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -2282,6 +2282,26 @@ range_entry_cmp (const void *a, const void *b) } } +/* Helper function for update_range_test. Force EXPR into an SSA_NAME, + insert needed statements BEFORE or after GSI. */ + +static tree +force_into_ssa_name (gimple_stmt_iterator *gsi, tree expr, bool before) +{ + enum gsi_iterator_update m = before ? GSI_SAME_STMT : GSI_CONTINUE_LINKING; + tree ret = force_gimple_operand_gsi (gsi, expr, true, NULL_TREE, before, m); + if (TREE_CODE (ret) != SSA_NAME) + { + gimple *g = gimple_build_assign (make_ssa_name (TREE_TYPE (ret)), ret); + if (before) + gsi_insert_before (gsi, g, GSI_SAME_STMT); + else + gsi_insert_after (gsi, g, GSI_CONTINUE_LINKING); + ret = gimple_assign_lhs (g); + } + return ret; +} + /* Helper routine of optimize_range_test. [EXP, IN_P, LOW, HIGH, STRICT_OVERFLOW_P] is a merged range for RANGE and OTHERRANGE through OTHERRANGE + COUNT - 1 ranges, @@ -2393,15 +2413,13 @@ update_range_test (struct range_entry *range, struct range_entry *otherrange, else if (op != range->exp) { gsi_insert_seq_before (&gsi, seq, GSI_SAME_STMT); - tem = force_gimple_operand_gsi (&gsi, tem, true, NULL_TREE, true, - GSI_SAME_STMT); + tem = force_into_ssa_name (&gsi, tem, true); gsi_prev (&gsi); } else if (gimple_code (stmt) != GIMPLE_PHI) { gsi_insert_seq_after (&gsi, seq, GSI_CONTINUE_LINKING); - tem = force_gimple_operand_gsi (&gsi, tem, true, NULL_TREE, false, - GSI_CONTINUE_LINKING); + tem = force_into_ssa_name (&gsi, tem, false); } else { @@ -2419,8 +2437,7 @@ update_range_test (struct range_entry *range, struct range_entry *otherrange, } } gsi_insert_seq_before (&gsi, seq, GSI_SAME_STMT); - tem = force_gimple_operand_gsi (&gsi, tem, true, NULL_TREE, true, - GSI_SAME_STMT); + tem = force_into_ssa_name (&gsi, tem, true); if (gsi_end_p (gsi)) gsi = gsi_last_bb (gimple_bb (stmt)); else