aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Oldham <oldham@codesourcery.com>2001-02-21 16:11:59 +0000
committerJeffrey D. Oldham <oldham@gcc.gnu.org>2001-02-21 16:11:59 +0000
commit0443f602bc9f5711c31e45a995ceaf6828d08283 (patch)
tree4a642b8fbfaab6d7d53f3f8917b92e5cbc52db22
parent7e6d8ba1842561ee144669cc97fad0fcbda65ae6 (diff)
downloadgcc-0443f602bc9f5711c31e45a995ceaf6828d08283.zip
gcc-0443f602bc9f5711c31e45a995ceaf6828d08283.tar.gz
gcc-0443f602bc9f5711c31e45a995ceaf6828d08283.tar.bz2
Makefile.in (reorg.o): Add params.h dependence.
2001-02-21 Jeffrey Oldham <oldham@codesourcery.com> * Makefile.in (reorg.o): Add params.h dependence. * params.def: Fix typographical error in comment. (MAX_DELAY_SLOT_INSN_SEARCH): New parameter. * params.h: Modify introductory comment. (MAX_DELAY_SLOT_INSN_SEARCH): New parameter. * reorg.c: Add dependence on params.h. (redundant_insn): Add parameterized throttle for search. (fill_simple_delay_slots): Add a comment explaining a variable. Move conditional out of loop, simplifying code. (fill_eager_delay_slots): Fix typographical error in comment. From-SVN: r39948
-rw-r--r--gcc/ChangeLog13
-rw-r--r--gcc/Makefile.in2
-rw-r--r--gcc/params.def13
-rw-r--r--gcc/params.h7
-rw-r--r--gcc/reorg.c147
5 files changed, 100 insertions, 82 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b4bd206..9461dca 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,16 @@
+2001-02-21 Jeffrey Oldham <oldham@codesourcery.com>
+
+ * Makefile.in (reorg.o): Add params.h dependence.
+ * params.def: Fix typographical error in comment.
+ (MAX_DELAY_SLOT_INSN_SEARCH): New parameter.
+ * params.h: Modify introductory comment.
+ (MAX_DELAY_SLOT_INSN_SEARCH): New parameter.
+ * reorg.c: Add dependence on params.h.
+ (redundant_insn): Add parameterized throttle for search.
+ (fill_simple_delay_slots): Add a comment explaining a variable.
+ Move conditional out of loop, simplifying code.
+ (fill_eager_delay_slots): Fix typographical error in comment.
+
2001-02-20 Aldy Hernandez <aldyh@redhat.com>
* tm.texi (REVERSE_CONDEXEC_PREDICATES_P): New macro documentation.
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index b71ca64..ba41875 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1481,7 +1481,7 @@ caller-save.o : caller-save.c $(CONFIG_H) system.h $(RTL_H) flags.h \
$(RECOG_H) reload.h $(EXPR_H) toplev.h
reorg.o : reorg.c $(CONFIG_H) system.h $(RTL_H) conditions.h hard-reg-set.h \
$(BASIC_BLOCK_H) $(REGS_H) insn-config.h $(INSN_ATTR_H) insn-flags.h \
- $(RECOG_H) function.h flags.h output.h $(EXPR_H) toplev.h
+ $(RECOG_H) function.h flags.h output.h $(EXPR_H) toplev.h params.h
alias.o : alias.c $(CONFIG_H) system.h $(RTL_H) flags.h hard-reg-set.h \
$(BASIC_BLOCK_H) $(REGS_H) toplev.h output.h $(EXPR_H) insn-flags.h \
$(GGC_H) function.h cselib.h $(TREE_H)
diff --git a/gcc/params.def b/gcc/params.def
index f96a89f..61c3600 100644
--- a/gcc/params.def
+++ b/gcc/params.def
@@ -24,7 +24,7 @@ Boston, MA 02111-1307, USA.
/* This file contains definitions for language-independent
parameters. The DEFPARAM macro takes 4 arguments:
- - The enumeral corresonding to this parameter.
+ - The enumeral corresponding to this parameter.
- The name that can be used to set this parameter using the
command-line option `--param <name>=<value>'.
@@ -44,6 +44,17 @@ DEFPARAM (PARAM_MAX_INLINE_INSNS,
"The maximum number of instructions in a function that is eligible for inlining",
10000)
+/* The maximum number of instructions to consider when looking for an
+ instruction to fill a delay slot. If more than this arbitrary
+ number of instructions is searched, the time savings from filling
+ the delay slot will be minimal so stop searching. Increasing
+ values mean more aggressive optimization, making the compile time
+ increase with probably small improvement in executable run time. */
+DEFPARAM (PARAM_MAX_DELAY_SLOT_INSN_SEARCH,
+ "max-delay-slot-insn-search",
+ "The maximum number of instructions to consider to fill a delay slot",
+ 100)
+
/*
Local variables:
mode:c
diff --git a/gcc/params.h b/gcc/params.h
index c097ad1..b60d29d 100644
--- a/gcc/params.h
+++ b/gcc/params.h
@@ -27,7 +27,10 @@ Boston, MA 02111-1307, USA.
place. The values of the parameters can be set on the
command-line, thereby providing a way to control the amount of
effort spent on particular optimization passes, or otherwise tune
- the behavior of the compiler. */
+ the behavior of the compiler.
+
+ Since their values can be set on the command-line, these parameters
+ should not be used for non-dynamic memory allocation. */
#ifndef PARAMS_H
#define PARAMS_H
@@ -81,5 +84,7 @@ typedef enum compiler_param
/* Macros for the various parameters. */
#define MAX_INLINE_INSNS \
PARAM_VALUE (PARAM_MAX_INLINE_INSNS)
+#define MAX_DELAY_SLOT_INSN_SEARCH \
+ PARAM_VALUE (PARAM_MAX_DELAY_SLOT_INSN_SEARCH)
#endif /* PARAMS_H */
diff --git a/gcc/reorg.c b/gcc/reorg.c
index 6d3b26a..142ecdf 100644
--- a/gcc/reorg.c
+++ b/gcc/reorg.c
@@ -139,6 +139,7 @@ Boston, MA 02111-1307, USA. */
#include "obstack.h"
#include "insn-attr.h"
#include "resource.h"
+#include "params.h"
#ifdef DELAY_SLOTS
@@ -1635,6 +1636,7 @@ redundant_insn (insn, target, delay_list)
rtx trial, pat;
struct resources needed, set;
int i;
+ unsigned insns_to_search;
/* If INSN has any REG_UNUSED notes, it can't match anything since we
are allowed to not actually assign to such a register. */
@@ -1642,7 +1644,10 @@ redundant_insn (insn, target, delay_list)
return 0;
/* Scan backwards looking for a match. */
- for (trial = PREV_INSN (target); trial; trial = PREV_INSN (trial))
+ for (trial = PREV_INSN (target),
+ insns_to_search = MAX_DELAY_SLOT_INSN_SEARCH;
+ trial && insns_to_search > 0;
+ trial = PREV_INSN (trial), --insns_to_search)
{
if (GET_CODE (trial) == CODE_LABEL)
return 0;
@@ -1743,9 +1748,10 @@ redundant_insn (insn, target, delay_list)
/* Scan backwards until we reach a label or an insn that uses something
INSN sets or sets something insn uses or sets. */
- for (trial = PREV_INSN (target);
- trial && GET_CODE (trial) != CODE_LABEL;
- trial = PREV_INSN (trial))
+ for (trial = PREV_INSN (target),
+ insns_to_search = MAX_DELAY_SLOT_INSN_SEARCH;
+ trial && GET_CODE (trial) != CODE_LABEL && insns_to_search > 0;
+ trial = PREV_INSN (trial), --insns_to_search)
{
if (GET_CODE (trial) != INSN && GET_CODE (trial) != CALL_INSN
&& GET_CODE (trial) != JUMP_INSN)
@@ -2223,9 +2229,11 @@ fill_simple_delay_slots (non_jumps_p)
&& ! simplejump_p (insn)
&& JUMP_LABEL (insn) != 0)))
{
+ /* Invariant: If insn is a JUMP_INSN, the insn's jump
+ label. Otherwise, zero. */
rtx target = 0;
int maybe_never = 0;
- struct resources needed_at_jump;
+ rtx pat, trial_delay;
CLEAR_RESOURCE (&needed);
CLEAR_RESOURCE (&set);
@@ -2244,92 +2252,73 @@ fill_simple_delay_slots (non_jumps_p)
target = JUMP_LABEL (insn);
}
- for (trial = next_nonnote_insn (insn); trial; trial = next_trial)
- {
- rtx pat, trial_delay;
-
- next_trial = next_nonnote_insn (trial);
-
- if (GET_CODE (trial) == CODE_LABEL
- || GET_CODE (trial) == BARRIER)
- break;
+ if (target == 0)
+ for (trial = next_nonnote_insn (insn); trial; trial = next_trial)
+ {
+ next_trial = next_nonnote_insn (trial);
- /* We must have an INSN, JUMP_INSN, or CALL_INSN. */
- pat = PATTERN (trial);
+ if (GET_CODE (trial) == CODE_LABEL
+ || GET_CODE (trial) == BARRIER)
+ break;
- /* Stand-alone USE and CLOBBER are just for flow. */
- if (GET_CODE (pat) == USE || GET_CODE (pat) == CLOBBER)
- continue;
+ /* We must have an INSN, JUMP_INSN, or CALL_INSN. */
+ pat = PATTERN (trial);
- /* If this already has filled delay slots, get the insn needing
- the delay slots. */
- if (GET_CODE (pat) == SEQUENCE)
- trial_delay = XVECEXP (pat, 0, 0);
- else
- trial_delay = trial;
-
- /* If this is a jump insn to our target, indicate that we have
- seen another jump to it. If we aren't handling a conditional
- jump, stop our search. Otherwise, compute the needs at its
- target and add them to NEEDED. */
- if (GET_CODE (trial_delay) == JUMP_INSN)
- {
- if (target == 0)
- break;
- else if (JUMP_LABEL (trial_delay) != target)
- {
- rtx ninsn =
- next_active_insn (JUMP_LABEL (trial_delay));
-
- mark_target_live_regs (get_insns (), ninsn,
- &needed_at_jump);
- needed.memory |= needed_at_jump.memory;
- needed.unch_memory |= needed_at_jump.unch_memory;
- IOR_HARD_REG_SET (needed.regs, needed_at_jump.regs);
- }
- }
+ /* Stand-alone USE and CLOBBER are just for flow. */
+ if (GET_CODE (pat) == USE || GET_CODE (pat) == CLOBBER)
+ continue;
- /* See if we have a resource problem before we try to
- split. */
- if (target == 0
- && GET_CODE (pat) != SEQUENCE
- && ! insn_references_resource_p (trial, &set, 1)
- && ! insn_sets_resource_p (trial, &set, 1)
- && ! insn_sets_resource_p (trial, &needed, 1)
+ /* If this already has filled delay slots, get the insn needing
+ the delay slots. */
+ if (GET_CODE (pat) == SEQUENCE)
+ trial_delay = XVECEXP (pat, 0, 0);
+ else
+ trial_delay = trial;
+
+ /* Stop our search when seeing an unconditional jump. */
+ if (GET_CODE (trial_delay) == JUMP_INSN)
+ break;
+
+ /* See if we have a resource problem before we try to
+ split. */
+ if (GET_CODE (pat) != SEQUENCE
+ && ! insn_references_resource_p (trial, &set, 1)
+ && ! insn_sets_resource_p (trial, &set, 1)
+ && ! insn_sets_resource_p (trial, &needed, 1)
#ifdef HAVE_cc0
- && ! (reg_mentioned_p (cc0_rtx, pat) && ! sets_cc0_p (pat))
+ && ! (reg_mentioned_p (cc0_rtx, pat) && ! sets_cc0_p (pat))
#endif
- && ! (maybe_never && may_trap_p (pat))
- && (trial = try_split (pat, trial, 0))
- && eligible_for_delay (insn, slots_filled, trial, flags))
- {
- next_trial = next_nonnote_insn (trial);
- delay_list = add_to_delay_list (trial, delay_list);
+ && ! (maybe_never && may_trap_p (pat))
+ && (trial = try_split (pat, trial, 0))
+ && eligible_for_delay (insn, slots_filled, trial, flags))
+ {
+ next_trial = next_nonnote_insn (trial);
+ delay_list = add_to_delay_list (trial, delay_list);
#ifdef HAVE_cc0
- if (reg_mentioned_p (cc0_rtx, pat))
- link_cc0_insns (trial);
+ if (reg_mentioned_p (cc0_rtx, pat))
+ link_cc0_insns (trial);
#endif
- delete_insn (trial);
- if (slots_to_fill == ++slots_filled)
- break;
- continue;
- }
+ delete_insn (trial);
+ if (slots_to_fill == ++slots_filled)
+ break;
+ continue;
+ }
- mark_set_resources (trial, &set, 0, MARK_SRC_DEST_CALL);
- mark_referenced_resources (trial, &needed, 1);
+ mark_set_resources (trial, &set, 0, MARK_SRC_DEST_CALL);
+ mark_referenced_resources (trial, &needed, 1);
- /* Ensure we don't put insns between the setting of cc and the
- comparison by moving a setting of cc into an earlier delay
- slot since these insns could clobber the condition code. */
- set.cc = 1;
+ /* Ensure we don't put insns between the setting of cc and the
+ comparison by moving a setting of cc into an earlier delay
+ slot since these insns could clobber the condition code. */
+ set.cc = 1;
- /* If this is a call or jump, we might not get here. */
- if (GET_CODE (trial_delay) == CALL_INSN
- || GET_CODE (trial_delay) == JUMP_INSN)
- maybe_never = 1;
- }
+ /* If this is a call or jump, we might not get here. */
+ if (GET_CODE (trial_delay) == CALL_INSN
+ || GET_CODE (trial_delay) == JUMP_INSN)
+ maybe_never = 1;
+ }
/* If there are slots left to fill and our search was stopped by an
unconditional branch, try the insn at the branch target. We can
@@ -2982,7 +2971,7 @@ fill_eager_delay_slots ()
}
/* If this insn is expected to branch, first try to get insns from our
- target, then our fallthrough insns. If it is not, expected to branch,
+ target, then our fallthrough insns. If it is not expected to branch,
try the other order. */
if (prediction > 0)