summaryrefslogtreecommitdiff
path: root/gcc/reload1.c
diff options
context:
space:
mode:
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>2011-06-23 21:30:20 +0000
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>2011-06-23 21:30:20 +0000
commit731fe0f739ed41635fb7ddd02c2416ec38c4845b (patch)
treeec001f94b4dc1405030f08d6e85ac05f217a3e9a /gcc/reload1.c
parent3de5b8d75db75b29294c6a4d3dd5995bd8d2164a (diff)
downloadgcc-731fe0f739ed41635fb7ddd02c2416ec38c4845b.tar.gz
PR middle-end/48770
* reload.h (reload): Change to return a bool. * ira.c (ira): If requested by reload, run a fast DCE pass after reload has completed. Fix comment typo. * reload1.c (need_dce): New file scoped static. (reload): Set reload_completed here. Return whether or not a DCE pass after reload is needed. (delete_dead_insn): Set need_dce as needed. PR middle-end/48770 * gcc.dg/pr48770.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@175353 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/reload1.c')
-rw-r--r--gcc/reload1.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/gcc/reload1.c b/gcc/reload1.c
index a87e6ad08d6..a9aa01723ee 100644
--- a/gcc/reload1.c
+++ b/gcc/reload1.c
@@ -250,6 +250,10 @@ static char *reload_insn_firstobj;
examine. */
struct insn_chain *reload_insn_chain;
+/* TRUE if we potentially left dead insns in the insn stream and want to
+ run DCE immediately after reload, FALSE otherwise. */
+static bool need_dce;
+
/* List of all insns needing reloads. */
static struct insn_chain *insns_need_reload;
@@ -695,10 +699,11 @@ static int *temp_pseudo_reg_arr;
If GLOBAL is zero, we do not have enough information to do that,
so any pseudo reg that is spilled must go to the stack.
- Return value is nonzero if reload failed
- and we must not do any more for this function. */
+ Return value is TRUE if reload likely left dead insns in the
+ stream and a DCE pass should be run to elimiante them. Else the
+ return value is FALSE. */
-int
+bool
reload (rtx first, int global)
{
int i, n;
@@ -1329,7 +1334,9 @@ reload (rtx first, int global)
gcc_assert (bitmap_empty_p (&spilled_pseudos));
- return failure;
+ reload_completed = !failure;
+
+ return need_dce;
}
/* Yet another special case. Unfortunately, reg-stack forces people to
@@ -2123,14 +2130,19 @@ delete_dead_insn (rtx insn)
rtx prev = prev_active_insn (insn);
rtx prev_dest;
- /* If the previous insn sets a register that dies in our insn, delete it
- too. */
+ /* If the previous insn sets a register that dies in our insn make
+ a note that we want to run DCE immediately after reload.
+
+ We used to delete the previous insn & recurse, but that's wrong for
+ block local equivalences. Instead of trying to figure out the exact
+ circumstances where we can delete the potentially dead insns, just
+ let DCE do the job. */
if (prev && GET_CODE (PATTERN (prev)) == SET
&& (prev_dest = SET_DEST (PATTERN (prev)), REG_P (prev_dest))
&& reg_mentioned_p (prev_dest, PATTERN (insn))
&& find_regno_note (insn, REG_DEAD, REGNO (prev_dest))
&& ! side_effects_p (SET_SRC (PATTERN (prev))))
- delete_dead_insn (prev);
+ need_dce = 1;
SET_INSN_DELETED (insn);
}