From d8202b848c1d8b270fb9f82c8e91b507ec266cdb Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 31 Oct 2013 14:51:38 +0100 Subject: tree-cfg.c (assert_unreachable_fallthru_edge_p): New function. * tree-cfg.c (assert_unreachable_fallthru_edge_p): New function. * tree-cfg.h (assert_unreachable_fallthru_edge_p): New prototype. * tree-vrp.c (all_imm_uses_in_stmt_or_feed_cond): New function. (remove_range_assertions): If ASSERT_EXPR_VAR has no other immediate uses but in the condition and ASSERT_EXPR and the other successor of the predecessor bb is __builtin_unreachable (), set_range_info of the ASSERT_EXPR_VAR to the range info of the ASSERT_EXPR's lhs. From-SVN: r204255 --- gcc/tree-cfg.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'gcc/tree-cfg.c') diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index d705657..d646693 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -381,6 +381,50 @@ computed_goto_p (gimple t) && TREE_CODE (gimple_goto_dest (t)) != LABEL_DECL); } +/* Returns true for edge E where e->src ends with a GIMPLE_COND and + the other edge points to a bb with just __builtin_unreachable (). + I.e. return true for C->M edge in: + : + ... + if (something) + goto ; + else + goto ; + : + __builtin_unreachable (); + : */ + +bool +assert_unreachable_fallthru_edge_p (edge e) +{ + basic_block pred_bb = e->src; + gimple last = last_stmt (pred_bb); + if (last && gimple_code (last) == GIMPLE_COND) + { + basic_block other_bb = EDGE_SUCC (pred_bb, 0)->dest; + if (other_bb == e->dest) + other_bb = EDGE_SUCC (pred_bb, 1)->dest; + if (EDGE_COUNT (other_bb->succs) == 0) + { + gimple_stmt_iterator gsi = gsi_after_labels (other_bb); + gimple stmt; + + if (gsi_end_p (gsi)) + return false; + stmt = gsi_stmt (gsi); + if (is_gimple_debug (stmt)) + { + gsi_next_nondebug (&gsi); + if (gsi_end_p (gsi)) + return false; + stmt = gsi_stmt (gsi); + } + return gimple_call_builtin_p (stmt, BUILT_IN_UNREACHABLE); + } + } + return false; +} + /* Search the CFG for any computed gotos. If found, factor them to a common computed goto site. Also record the location of that site so -- cgit v1.1