Commit 3a15c2cf by Steven Bosscher

re PR middle-end/54385 (ICE in pre_and_rev_post_order_compute, at cfganal.c:873)

	PR middle-end/54385
	* postreload.c (reload_cse_simplify): Return a bool indicating
	whether the CFG was changed.
	(reload_cse_regs_1): Traverse the CFG instead of the insns chain.
	Cleanup the CFG if edges may have been removed.
	(reload_cse_regs): Update.

From-SVN: r193359
parent 50919d13
2012-11-09 Steven Bosscher <steven@gcc.gnu.org>
PR middle-end/54385
* postreload.c (reload_cse_simplify): Return a bool indicating
whether the CFG was changed.
(reload_cse_regs_1): Traverse the CFG instead of the insns chain.
Cleanup the CFG if edges may have been removed.
(reload_cse_regs): Update.
2012-11-09 Andrey Belevantsev <abel@ispras.ru> 2012-11-09 Andrey Belevantsev <abel@ispras.ru>
PR rtl-optimization/54472 PR rtl-optimization/54472
* sel-sched-ir.c (has_dependence_note_reg_set): Handle implicit sets. * sel-sched-ir.c (has_dependence_note_reg_set): Handle implicit sets.
(has_dependence_note_reg_clobber, (has_dependence_note_reg_clobber,
has_dependence_note_reg_use): Likewise. has_dependence_note_reg_use): Likewise.
...@@ -48,8 +48,8 @@ along with GCC; see the file COPYING3. If not see ...@@ -48,8 +48,8 @@ along with GCC; see the file COPYING3. If not see
#include "dbgcnt.h" #include "dbgcnt.h"
static int reload_cse_noop_set_p (rtx); static int reload_cse_noop_set_p (rtx);
static void reload_cse_simplify (rtx, rtx); static bool reload_cse_simplify (rtx, rtx);
static void reload_cse_regs_1 (rtx); static void reload_cse_regs_1 (void);
static int reload_cse_simplify_set (rtx, rtx); static int reload_cse_simplify_set (rtx, rtx);
static int reload_cse_simplify_operands (rtx, rtx); static int reload_cse_simplify_operands (rtx, rtx);
...@@ -67,14 +67,14 @@ static void ...@@ -67,14 +67,14 @@ static void
reload_cse_regs (rtx first ATTRIBUTE_UNUSED) reload_cse_regs (rtx first ATTRIBUTE_UNUSED)
{ {
bool moves_converted; bool moves_converted;
reload_cse_regs_1 (first); reload_cse_regs_1 ();
reload_combine (); reload_combine ();
moves_converted = reload_cse_move2add (first); moves_converted = reload_cse_move2add (first);
if (flag_expensive_optimizations) if (flag_expensive_optimizations)
{ {
if (moves_converted) if (moves_converted)
reload_combine (); reload_combine ();
reload_cse_regs_1 (first); reload_cse_regs_1 ();
} }
} }
...@@ -88,11 +88,13 @@ reload_cse_noop_set_p (rtx set) ...@@ -88,11 +88,13 @@ reload_cse_noop_set_p (rtx set)
return rtx_equal_for_cselib_p (SET_DEST (set), SET_SRC (set)); return rtx_equal_for_cselib_p (SET_DEST (set), SET_SRC (set));
} }
/* Try to simplify INSN. */ /* Try to simplify INSN. Return true if the CFG may have changed. */
static void static bool
reload_cse_simplify (rtx insn, rtx testreg) reload_cse_simplify (rtx insn, rtx testreg)
{ {
rtx body = PATTERN (insn); rtx body = PATTERN (insn);
basic_block insn_bb = BLOCK_FOR_INSN (insn);
unsigned insn_bb_succs = EDGE_COUNT (insn_bb->succs);
if (GET_CODE (body) == SET) if (GET_CODE (body) == SET)
{ {
...@@ -113,7 +115,8 @@ reload_cse_simplify (rtx insn, rtx testreg) ...@@ -113,7 +115,8 @@ reload_cse_simplify (rtx insn, rtx testreg)
value = 0; value = 0;
if (check_for_inc_dec (insn)) if (check_for_inc_dec (insn))
delete_insn_and_edges (insn); delete_insn_and_edges (insn);
return; /* We're done with this insn. */
goto done;
} }
if (count > 0) if (count > 0)
...@@ -166,7 +169,7 @@ reload_cse_simplify (rtx insn, rtx testreg) ...@@ -166,7 +169,7 @@ reload_cse_simplify (rtx insn, rtx testreg)
if (check_for_inc_dec (insn)) if (check_for_inc_dec (insn))
delete_insn_and_edges (insn); delete_insn_and_edges (insn);
/* We're done with this insn. */ /* We're done with this insn. */
return; goto done;
} }
/* It's not a no-op, but we can try to simplify it. */ /* It's not a no-op, but we can try to simplify it. */
...@@ -179,6 +182,9 @@ reload_cse_simplify (rtx insn, rtx testreg) ...@@ -179,6 +182,9 @@ reload_cse_simplify (rtx insn, rtx testreg)
else else
reload_cse_simplify_operands (insn, testreg); reload_cse_simplify_operands (insn, testreg);
} }
done:
return (EDGE_COUNT (insn_bb->succs) != insn_bb_succs);
} }
/* Do a very simple CSE pass over the hard registers. /* Do a very simple CSE pass over the hard registers.
...@@ -199,25 +205,30 @@ reload_cse_simplify (rtx insn, rtx testreg) ...@@ -199,25 +205,30 @@ reload_cse_simplify (rtx insn, rtx testreg)
if possible, much like an optional reload would. */ if possible, much like an optional reload would. */
static void static void
reload_cse_regs_1 (rtx first) reload_cse_regs_1 (void)
{ {
bool cfg_changed = false;
basic_block bb;
rtx insn; rtx insn;
rtx testreg = gen_rtx_REG (VOIDmode, -1); rtx testreg = gen_rtx_REG (VOIDmode, -1);
cselib_init (CSELIB_RECORD_MEMORY); cselib_init (CSELIB_RECORD_MEMORY);
init_alias_analysis (); init_alias_analysis ();
for (insn = first; insn; insn = NEXT_INSN (insn)) FOR_EACH_BB (bb)
{ FOR_BB_INSNS (bb, insn)
if (INSN_P (insn)) {
reload_cse_simplify (insn, testreg); if (INSN_P (insn))
cfg_changed |= reload_cse_simplify (insn, testreg);
cselib_process_insn (insn); cselib_process_insn (insn);
} }
/* Clean up. */ /* Clean up. */
end_alias_analysis (); end_alias_analysis ();
cselib_finish (); cselib_finish ();
if (cfg_changed)
cleanup_cfg (0);
} }
/* Try to simplify a single SET instruction. SET is the set pattern. /* Try to simplify a single SET instruction. SET is the set pattern.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment