From: Jakub Jelinek Date: Sat, 14 Feb 2015 08:23:18 +0000 (+0100) Subject: re PR tree-optimization/62209 (ICE with LTO on valid code on x86_64-linux-gnu) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=952e216e5a092b5072894b3889f18bc5f76dcf72;p=gcc.git re PR tree-optimization/62209 (ICE with LTO on valid code on x86_64-linux-gnu) PR tree-optimization/62209 * tree-ssa-reassoc.c (update_range_test): If stmt is a PHI and op == range->exp, insert seq and gimplified code after labels instead of after the phi. From-SVN: r220706 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ca43bfd0b94..75c18650270 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2015-02-14 Jakub Jelinek + + PR tree-optimization/62209 + * tree-ssa-reassoc.c (update_range_test): If stmt is a PHI and + op == range->exp, insert seq and gimplified code after labels + instead of after the phi. + 2015-02-13 Jeff Law PR bootstrap/65060 diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index 9952222f715..ce37053bdb3 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -2177,10 +2177,18 @@ update_range_test (struct range_entry *range, struct range_entry *otherrange, tem = fold_convert_loc (loc, optype, tem); gsi = gsi_for_stmt (stmt); + unsigned int uid = gimple_uid (stmt); /* In rare cases range->exp can be equal to lhs of stmt. In that case we have to insert after the stmt rather then before - it. */ - if (op == range->exp) + it. If stmt is a PHI, insert it at the start of the basic block. */ + 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); + 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, @@ -2188,16 +2196,32 @@ update_range_test (struct range_entry *range, struct range_entry *otherrange, } else { + gsi = gsi_after_labels (gimple_bb (stmt)); + if (!gsi_end_p (gsi)) + uid = gimple_uid (gsi_stmt (gsi)); + else + { + gsi = gsi_start_bb (gimple_bb (stmt)); + uid = 1; + while (!gsi_end_p (gsi)) + { + uid = gimple_uid (gsi_stmt (gsi)); + gsi_next (&gsi); + } + } gsi_insert_seq_before (&gsi, seq, GSI_SAME_STMT); tem = force_gimple_operand_gsi (&gsi, tem, true, NULL_TREE, true, GSI_SAME_STMT); - gsi_prev (&gsi); + if (gsi_end_p (gsi)) + gsi = gsi_last_bb (gimple_bb (stmt)); + else + gsi_prev (&gsi); } for (; !gsi_end_p (gsi); gsi_prev (&gsi)) if (gimple_uid (gsi_stmt (gsi))) break; else - gimple_set_uid (gsi_stmt (gsi), gimple_uid (stmt)); + gimple_set_uid (gsi_stmt (gsi), uid); oe->op = tem; range->exp = exp;