From: Oleg Endo Date: Sun, 23 Nov 2014 21:16:26 +0000 (+0000) Subject: re PR target/53976 ([SH] Unnecessary clrt/sett after bt/bf) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8be6500b53610e887bf03876ffd809ecba154066;p=gcc.git re PR target/53976 ([SH] Unnecessary clrt/sett after bt/bf) gcc/ PR target/53976 * config/sh/sh_optimize_sett_clrt.cc (sh_optimize_sett_clrt::find_last_ccreg_values): Return bool instead of void. Abort at complex edges. (sh_optimize_sett_clrt::execute): Do nothing if find_last_ccreg_values returned false. From-SVN: r217987 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 929b2377ca8..7e1f741cc00 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2014-11-23 Oleg Endo + + PR target/53976 + * config/sh/sh_optimize_sett_clrt.cc + (sh_optimize_sett_clrt::find_last_ccreg_values): Return bool instead + of void. Abort at complex edges. + (sh_optimize_sett_clrt::execute): Do nothing if find_last_ccreg_values + returned false. + 2014-11-22 John David Anglin PR other/63694 diff --git a/gcc/config/sh/sh_optimize_sett_clrt.cc b/gcc/config/sh/sh_optimize_sett_clrt.cc index bc1f82fd792..f19c2ebf383 100644 --- a/gcc/config/sh/sh_optimize_sett_clrt.cc +++ b/gcc/config/sh/sh_optimize_sett_clrt.cc @@ -126,7 +126,7 @@ private: // Given a start insn and its basic block, recursively determine all // possible ccreg values in all basic block paths that can lead to the // start insn. - void find_last_ccreg_values (rtx_insn *start_insn, basic_block bb, + bool find_last_ccreg_values (rtx_insn *start_insn, basic_block bb, std::vector& values_out, std::vector& prev_visited_bb) const; @@ -239,8 +239,8 @@ sh_optimize_sett_clrt::execute (function* fun) ccreg_values.clear (); visited_bbs.clear (); - find_last_ccreg_values (PREV_INSN (i), bb, ccreg_values, - visited_bbs); + bool ok = find_last_ccreg_values (PREV_INSN (i), bb, ccreg_values, + visited_bbs); log_msg ("number of ccreg values collected: %u\n", (unsigned int)ccreg_values.size ()); @@ -248,7 +248,7 @@ sh_optimize_sett_clrt::execute (function* fun) // If all the collected values are equal and are equal to the // constant value of the setcc insn, the setcc insn can be // removed. - if (all_ccreg_values_equal (ccreg_values) + if (ok && all_ccreg_values_equal (ccreg_values) && rtx_equal_p (ccreg_values.front ().value, setcc_val)) { log_msg ("all values are "); @@ -322,7 +322,7 @@ sh_optimize_sett_clrt gcc_unreachable (); } -void +bool sh_optimize_sett_clrt ::find_last_ccreg_values (rtx_insn *start_insn, basic_block bb, std::vector& values_out, @@ -361,7 +361,7 @@ sh_optimize_sett_clrt log_msg ("\n"); values_out.push_back (v); - return; + return true; } if (any_condjump_p (i) && onlyjump_p (i) && !prev_visited_bb.empty ()) @@ -385,7 +385,7 @@ sh_optimize_sett_clrt log_msg ("\n"); values_out.push_back (v); - return; + return true; } } @@ -406,10 +406,14 @@ sh_optimize_sett_clrt for (edge_iterator ei = ei_start (bb->preds); !ei_end_p (ei); ei_next (&ei)) { + if (ei_edge (ei)->flags & EDGE_COMPLEX) + log_return (false, "aborting due to complex edge\n"); + basic_block pred_bb = ei_edge (ei)->src; pred_bb_count += 1; - find_last_ccreg_values (BB_END (pred_bb), pred_bb, values_out, - prev_visited_bb); + if (!find_last_ccreg_values (BB_END (pred_bb), pred_bb, values_out, + prev_visited_bb)) + return false; } prev_visited_bb.pop_back (); @@ -432,6 +436,8 @@ sh_optimize_sett_clrt values_out.push_back (v); } + + return true; } bool