From 56bbfaf62ca1d53c8016e0d9e00394a5f23c047a Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Mon, 21 Mar 2016 09:11:37 +0000 Subject: re PR tree-optimization/70288 (ICE with -O1 -fno-tree-dominator-opts) 2016-03-21 Richard Biener PR tree-optimization/70288 * tree-ssa-loop-ivcanon.c (tree_estimate_loop_size): Make sure we do not estimate unsimplified all-constant conditionals or switches as optimized away. * gcc.dg/torture/pr70288-1.c: New testcase. * gcc.dg/torture/pr70288-2.c: Likewise. From-SVN: r234361 --- gcc/tree-ssa-loop-ivcanon.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'gcc/tree-ssa-loop-ivcanon.c') diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c index 1a4d6df..72f91b2 100644 --- a/gcc/tree-ssa-loop-ivcanon.c +++ b/gcc/tree-ssa-loop-ivcanon.c @@ -298,11 +298,17 @@ tree_estimate_loop_size (struct loop *loop, edge exit, edge edge_to_cancel, stru /* Conditionals. */ else if ((gimple_code (stmt) == GIMPLE_COND && constant_after_peeling (gimple_cond_lhs (stmt), stmt, loop) - && constant_after_peeling (gimple_cond_rhs (stmt), stmt, loop)) + && constant_after_peeling (gimple_cond_rhs (stmt), stmt, loop) + /* We don't simplify all constant compares so make sure + they are not both constant already. See PR70288. */ + && (! is_gimple_min_invariant (gimple_cond_lhs (stmt)) + || ! is_gimple_min_invariant (gimple_cond_rhs (stmt)))) || (gimple_code (stmt) == GIMPLE_SWITCH && constant_after_peeling (gimple_switch_index ( as_a (stmt)), - stmt, loop))) + stmt, loop) + && ! is_gimple_min_invariant (gimple_switch_index ( + as_a (stmt))))) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, " Constant conditional.\n"); -- cgit v1.1