tree-scalar-evolution.c: New file.

* tree-scalar-evolution.c: New file.
	* tree-scalar-evolution.h: New file.
	* tree-ssa-loop-niter.c: New file.
	* Makefile.in (SCEV_H): New.
	(tree-scalar-evolution.o, tree-ssa-loop-niter.o): Add new files.
	* cfgloop.h (struct loop): Add bounds field.
	* tree-flow.h (struct tree_niter_desc): New type.
	(number_of_iterations_cond, number_of_iterations_exit,
	loop_niter_by_eval, find_loop_niter_by_eval,
	estimate_numbers_of_iterations, can_count_iv_in_wider_type,
	free_numbers_of_iterations_estimates): Declare.
	* tree.h (lower_bound_in_type, upper_bound_in_type): Declare.
	* params.def (PARAM_MAX_ITERATIONS_TO_TRACK): New parameter.
	* doc/invoke.texi (max-iterations-to-track): Document.

From-SVN: r84340
This commit is contained in:
Zdenek Dvorak 2004-07-09 05:19:14 +02:00 committed by Zdenek Dvorak
parent dd29d26b24
commit e9eb809dec
10 changed files with 1487 additions and 1 deletions

View File

@ -1,3 +1,20 @@
2004-07-08 Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>
* tree-scalar-evolution.c: New file.
* tree-scalar-evolution.h: New file.
* tree-ssa-loop-niter.c: New file.
* Makefile.in (SCEV_H): New.
(tree-scalar-evolution.o, tree-ssa-loop-niter.o): Add new files.
* cfgloop.h (struct loop): Add bounds field.
* tree-flow.h (struct tree_niter_desc): New type.
(number_of_iterations_cond, number_of_iterations_exit,
loop_niter_by_eval, find_loop_niter_by_eval,
estimate_numbers_of_iterations, can_count_iv_in_wider_type,
free_numbers_of_iterations_estimates): Declare.
* tree.h (lower_bound_in_type, upper_bound_in_type): Declare.
* params.def (PARAM_MAX_ITERATIONS_TO_TRACK): New parameter.
* doc/invoke.texi (max-iterations-to-track): Document.
2004-07-08 Kaz Kojima <kkojima@gcc.gnu.org>
* config/sh/sh.c (sh_va_arg): Initinalize lab_over.

View File

@ -728,6 +728,7 @@ TREE_SSA_LIVE_H = tree-ssa-live.h $(PARTITION_H)
PRETTY_PRINT_H = pretty-print.h input.h $(OBSTACK_H)
DIAGNOSTIC_H = diagnostic.h diagnostic.def $(PRETTY_PRINT_H)
C_PRETTY_PRINT_H = $(PRETTY_PRINT_H) $(C_COMMON_H) $(TREE_H)
SCEV_H = tree-scalar-evolution.h $(GGC_H) tree-chrec.h
#
# Now figure out from those variables how to compile and link.
@ -886,7 +887,7 @@ C_OBJS = c-parse.o c-lang.o stub-objc.o $(C_AND_OBJC_OBJS)
# Language-independent object files.
OBJS-common = \
tree-chrec.o \
tree-chrec.o tree-scalar-evolution.o \
tree-cfg.o tree-dfa.o tree-eh.o tree-ssa.o tree-optimize.o tree-gimple.o \
tree-alias-type.o gimplify.o tree-pretty-print.o tree-into-ssa.o \
tree-outof-ssa.o tree-alias-common.o tree-ssa-ccp.o tree-vn.o \
@ -895,6 +896,7 @@ OBJS-common = \
tree-ssa-phiopt.o tree-ssa-forwprop.o tree-nested.o tree-ssa-dse.o \
tree-ssa-dom.o domwalk.o tree-tailcall.o gimple-low.o tree-iterator.o \
tree-phinodes.o tree-ssanames.o tree-sra.o tree-complex.o tree-ssa-loop.o \
tree-ssa-loop-niter.o \
alias.o bb-reorder.o bitmap.o builtins.o caller-save.o calls.o \
cfg.o cfganal.o cfgbuild.o cfgcleanup.o cfglayout.o cfgloop.o \
cfgloopanal.o cfgloopmanip.o loop-init.o loop-unswitch.o loop-unroll.o \
@ -1676,6 +1678,10 @@ tree-ssa-loop.o : tree-ssa-loop.c $(TREE_FLOW_H) $(CONFIG_H) \
$(SYSTEM_H) $(RTL_H) $(TREE_H) $(TM_P_H) $(CFGLOOP_H) \
output.h diagnostic.h $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) \
tree-pass.h $(FLAGS_H) tree-inline.h
tree-ssa-loop-niter.o : tree-ssa-loop-niter.c $(TREE_FLOW_H) $(CONFIG_H) \
$(SYSTEM_H) $(RTL_H) $(TREE_H) $(TM_P_H) cfgloop.h $(PARAMS_H) tree-inline.h \
output.h diagnostic.h $(TM_H) coretypes.h $(TREE_DUMP_H) flags.h \
tree-pass.h $(SCEV_H)
tree-ssa-loop-ch.o : tree-ssa-loop-ch.c $(TREE_FLOW_H) $(CONFIG_H) \
$(SYSTEM_H) $(RTL_H) $(TREE_H) $(TM_P_H) $(CFGLOOP_H) tree-inline.h \
output.h diagnostic.h $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) \
@ -1708,6 +1714,10 @@ tree-browser.o : tree-browser.c tree-browser.def $(CONFIG_H) $(SYSTEM_H) \
$(TM_H) coretypes.h
tree-chrec.o: tree-chrec.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
errors.h $(GGC_H) $(TREE_H) tree-chrec.h tree-pass.h
tree-scalar-evolution.o: tree-scalar-evolution.c $(CONFIG_H) $(SYSTEM_H) \
coretypes.h $(TM_H) errors.h $(GGC_H) $(TREE_H) $(RTL_H) \
$(BASIC_BLOCK_H) diagnostic.h $(TREE_FLOW_H) $(TREE_DUMP_H) \
$(TIMEVAR_H) cfgloop.h $(SCEV_H)
tree-gimple.o : tree-gimple.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(EXPR_H) \
$(RTL_H) $(TREE_GIMPLE_H) $(TM_H) coretypes.h bitmap.h $(GGC_H)
tree-mudflap.o : $(CONFIG_H) errors.h $(SYSTEM_H) $(TREE_H) tree-inline.h \

View File

@ -175,6 +175,9 @@ struct loop
/* The number of LABEL_REFs on exit_labels for this loop and all
loops nested inside it. */
int exit_count;
/* Upper bound on number of iterations of a loop. */
struct nb_iter_bound *bounds;
};
/* Flags for state of loop structure. */

View File

@ -5174,6 +5174,11 @@ The maximum number of insns of an unswitched loop.
@item max-unswitch-level
The maximum number of branches unswitched in a single loop.
@item max-iterations-to-track
The maximum number of iterations of a loop the brute force algorithm
for analysis of # of iterations of the loop tries to evaluate.
@item hot-bb-count-fraction
Select fraction of the maximal count of repetitions of basic block in program
given basic block needs to have to be considered hot.

View File

@ -229,6 +229,14 @@ DEFPARAM(PARAM_MAX_UNSWITCH_LEVEL,
"The maximum number of unswitchings in a single loop",
3)
/* The maximum number of iterations of a loop the brute force algorithm
for analysis of # of iterations of the loop tries to evaluate. */
DEFPARAM(PARAM_MAX_ITERATIONS_TO_TRACK,
"max-iterations-to-track",
"Bound on the number of iterations the brute force # of iterations \
analysis algorithm evaluates",
1000)
DEFPARAM(PARAM_MAX_SMS_LOOP_NUMBER,
"max-sms-loop-number",
"Maximum number of loops to perform swing modulo scheduling on \

View File

@ -597,6 +597,50 @@ extern void propagate_tree_value (tree *, tree);
extern void replace_exp (use_operand_p, tree);
extern bool may_propagate_copy (tree, tree);
/* Description of number of iterations of a loop. All the expressions inside
the structure can be evaluated at the end of the loop's preheader
(and due to ssa form, also anywhere inside the body of the loop). */
struct tree_niter_desc
{
tree assumptions; /* The boolean expression. If this expression evalutes
to false, then the other fields in this structure
should not be used; there is no guarantee that they
will be correct. */
tree may_be_zero; /* The booleand expression. If it evaluates to true,
the loop will exit in the first iteration (i.e.
its latch will not be executed), even if the niter
field says otherwise. */
tree niter; /* The expression giving the number of iterations of
a loop (provided that assumptions == true and
may_be_zero == false), more precisely the number
of executions of the latch of the loop. */
tree additional_info; /* The boolean expression. Sometimes we use additional
knowledge to simplify the other expressions
contained in this structure (for example the
knowledge about value ranges of operands on entry to
the loop). If this is a case, conjunction of such
condition is stored in this field, so that we do not
lose the information: for example if may_be_zero
is (n <= 0) and niter is (unsigned) n, we know
that the number of iterations is at most
MAX_SIGNED_INT. However if the (n <= 0) assumption
is eliminated (by looking at the guard on entry of
the loop), then the information would be lost. */
};
/* In tree-ssa-loop*.c */
void number_of_iterations_cond (tree, tree, tree, enum tree_code, tree, tree,
struct tree_niter_desc *);
bool number_of_iterations_exit (struct loop *, edge,
struct tree_niter_desc *niter);
tree loop_niter_by_eval (struct loop *, edge);
tree find_loop_niter_by_eval (struct loop *, edge *);
void estimate_numbers_of_iterations (struct loops *);
tree can_count_iv_in_wider_type (struct loop *, tree, tree, tree, tree);
void free_numbers_of_iterations_estimates (struct loops *);
/* In tree-flow-inline.h */
static inline int phi_arg_from_edge (tree, edge);
static inline bool is_call_clobbered (tree);

View File

@ -0,0 +1,61 @@
/* Scalar evolution detector.
Copyright (C) 2003, 2004 Free Software Foundation, Inc.
Contributed by Sebastian Pop <s.pop@laposte.net>
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to the Free
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "errors.h"
#include "ggc.h"
#include "tree.h"
#include "rtl.h"
#include "basic-block.h"
#include "diagnostic.h"
#include "tree-flow.h"
#include "tree-dump.h"
#include "timevar.h"
#include "cfgloop.h"
#include "tree-chrec.h"
#include "tree-scalar-evolution.h"
/* Analyze all the parameters of the chrec that were left under a
symbolic form. LOOP is the loop in which symbolic names have to
be analyzed and instantiated. */
tree
instantiate_parameters (struct loop *loop ATTRIBUTE_UNUSED,
tree chrec)
{
/* Just a dummy definition for now. */
return chrec;
}
/* Checks whether OP behaves as a simple affine iv of LOOP in STMT and returns
its BASE and STEP if possible. */
bool
simple_iv (struct loop *loop ATTRIBUTE_UNUSED, tree stmt ATTRIBUTE_UNUSED,
tree op ATTRIBUTE_UNUSED, tree *base ATTRIBUTE_UNUSED,
tree *step ATTRIBUTE_UNUSED)
{
/* Just a dummy definition for now. */
return false;
}

View File

@ -0,0 +1,28 @@
/* Scalar evolution detector.
Copyright (C) 2003, 2004 Free Software Foundation, Inc.
Contributed by Sebastian Pop <s.pop@laposte.net>
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to the Free
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
#ifndef GCC_TREE_SCALAR_EVOLUTION_H
#define GCC_TREE_SCALAR_EVOLUTION_H
extern tree instantiate_parameters (struct loop *, tree);
extern bool simple_iv (struct loop *, tree, tree, tree *, tree *);
#endif /* GCC_TREE_SCALAR_EVOLUTION_H */

1305
gcc/tree-ssa-loop-niter.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -3754,4 +3754,9 @@ extern int tree_node_sizes[];
restricted to creating gimple expressions. */
extern bool in_gimple_form;
/* In tree-ssa-loop-niter.c. */
tree lower_bound_in_type (tree, tree);
tree upper_bound_in_type (tree, tree);
#endif /* GCC_TREE_H */