2004-07-09 05:19:14 +02:00
|
|
|
|
/* Scalar evolution detector.
|
basic-block.h, [...]: Update copyright.
* basic-block.h, c-common.c, c-cppbuiltin.c, c-lang.c,
c-tree.h, cfgbuild.c, cgraph.c, cgraph.h, collect2.c,
combine.c, config.gcc, coverage.h, cse.c, cselib.c,
defaults.h, df.c, dwarf2asm.c, dwarf2out.c, explow.c, expr.c,
flow.c, fold-const.c, gcse.c, ggc-page.c, gimple-low.c,
gimplify.c, ifcvt.c, langhooks-def.h, lcm.c, optabs.h,
output.h, postreload-gcse.c, postreload.c, recog.c,
resource.c, rtl.def, rtlanal.c, sched-deps.c, sched-rgn.c,
targhooks.h, toplev.c, tree-data-ref.c, tree-eh.c,
tree-flow.h, tree-loop-linear.c, tree-mudflap.h, tree-nrv.c,
tree-optimize.c, tree-outof-ssa.c, tree-pass.h,
tree-scalar-evolution.c, tree-ssa-copy.c, tree-ssa-dce.c,
tree-ssa-dse.c, tree-ssa-loop-ivopts.c, tree-ssa-operands.c,
tree-ssa-pre.c, tree-ssa.c, tree-vectorizer.c, tree.def,
unwind-dw2-fde-darwin.c, var-tracking.c: Update copyright.
From-SVN: r93827
2005-01-18 12:36:31 +01:00
|
|
|
|
Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
|
2004-07-09 05:19:14 +02:00
|
|
|
|
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
|
2005-06-25 04:02:01 +02:00
|
|
|
|
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
|
02110-1301, USA. */
|
2004-07-09 05:19:14 +02:00
|
|
|
|
|
2004-07-12 21:31:16 +02:00
|
|
|
|
/*
|
|
|
|
|
Description:
|
|
|
|
|
|
|
|
|
|
This pass analyzes the evolution of scalar variables in loop
|
|
|
|
|
structures. The algorithm is based on the SSA representation,
|
|
|
|
|
and on the loop hierarchy tree. This algorithm is not based on
|
|
|
|
|
the notion of versions of a variable, as it was the case for the
|
|
|
|
|
previous implementations of the scalar evolution algorithm, but
|
|
|
|
|
it assumes that each defined name is unique.
|
|
|
|
|
|
|
|
|
|
The notation used in this file is called "chains of recurrences",
|
|
|
|
|
and has been proposed by Eugene Zima, Robert Van Engelen, and
|
|
|
|
|
others for describing induction variables in programs. For example
|
|
|
|
|
"b -> {0, +, 2}_1" means that the scalar variable "b" is equal to 0
|
|
|
|
|
when entering in the loop_1 and has a step 2 in this loop, in other
|
|
|
|
|
words "for (b = 0; b < N; b+=2);". Note that the coefficients of
|
|
|
|
|
this chain of recurrence (or chrec [shrek]) can contain the name of
|
|
|
|
|
other variables, in which case they are called parametric chrecs.
|
|
|
|
|
For example, "b -> {a, +, 2}_1" means that the initial value of "b"
|
|
|
|
|
is the value of "a". In most of the cases these parametric chrecs
|
|
|
|
|
are fully instantiated before their use because symbolic names can
|
|
|
|
|
hide some difficult cases such as self-references described later
|
|
|
|
|
(see the Fibonacci example).
|
|
|
|
|
|
|
|
|
|
A short sketch of the algorithm is:
|
|
|
|
|
|
|
|
|
|
Given a scalar variable to be analyzed, follow the SSA edge to
|
|
|
|
|
its definition:
|
|
|
|
|
|
|
|
|
|
- When the definition is a MODIFY_EXPR: if the right hand side
|
|
|
|
|
(RHS) of the definition cannot be statically analyzed, the answer
|
|
|
|
|
of the analyzer is: "don't know".
|
|
|
|
|
Otherwise, for all the variables that are not yet analyzed in the
|
|
|
|
|
RHS, try to determine their evolution, and finally try to
|
|
|
|
|
evaluate the operation of the RHS that gives the evolution
|
|
|
|
|
function of the analyzed variable.
|
|
|
|
|
|
|
|
|
|
- When the definition is a condition-phi-node: determine the
|
|
|
|
|
evolution function for all the branches of the phi node, and
|
|
|
|
|
finally merge these evolutions (see chrec_merge).
|
|
|
|
|
|
|
|
|
|
- When the definition is a loop-phi-node: determine its initial
|
|
|
|
|
condition, that is the SSA edge defined in an outer loop, and
|
|
|
|
|
keep it symbolic. Then determine the SSA edges that are defined
|
|
|
|
|
in the body of the loop. Follow the inner edges until ending on
|
|
|
|
|
another loop-phi-node of the same analyzed loop. If the reached
|
|
|
|
|
loop-phi-node is not the starting loop-phi-node, then we keep
|
|
|
|
|
this definition under a symbolic form. If the reached
|
|
|
|
|
loop-phi-node is the same as the starting one, then we compute a
|
|
|
|
|
symbolic stride on the return path. The result is then the
|
|
|
|
|
symbolic chrec {initial_condition, +, symbolic_stride}_loop.
|
|
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
|
|
|
|
|
Example 1: Illustration of the basic algorithm.
|
|
|
|
|
|
|
|
|
|
| a = 3
|
|
|
|
|
| loop_1
|
|
|
|
|
| b = phi (a, c)
|
|
|
|
|
| c = b + 1
|
|
|
|
|
| if (c > 10) exit_loop
|
|
|
|
|
| endloop
|
|
|
|
|
|
|
|
|
|
Suppose that we want to know the number of iterations of the
|
|
|
|
|
loop_1. The exit_loop is controlled by a COND_EXPR (c > 10). We
|
|
|
|
|
ask the scalar evolution analyzer two questions: what's the
|
|
|
|
|
scalar evolution (scev) of "c", and what's the scev of "10". For
|
|
|
|
|
"10" the answer is "10" since it is a scalar constant. For the
|
|
|
|
|
scalar variable "c", it follows the SSA edge to its definition,
|
|
|
|
|
"c = b + 1", and then asks again what's the scev of "b".
|
|
|
|
|
Following the SSA edge, we end on a loop-phi-node "b = phi (a,
|
|
|
|
|
c)", where the initial condition is "a", and the inner loop edge
|
|
|
|
|
is "c". The initial condition is kept under a symbolic form (it
|
|
|
|
|
may be the case that the copy constant propagation has done its
|
|
|
|
|
work and we end with the constant "3" as one of the edges of the
|
|
|
|
|
loop-phi-node). The update edge is followed to the end of the
|
|
|
|
|
loop, and until reaching again the starting loop-phi-node: b -> c
|
|
|
|
|
-> b. At this point we have drawn a path from "b" to "b" from
|
|
|
|
|
which we compute the stride in the loop: in this example it is
|
|
|
|
|
"+1". The resulting scev for "b" is "b -> {a, +, 1}_1". Now
|
|
|
|
|
that the scev for "b" is known, it is possible to compute the
|
|
|
|
|
scev for "c", that is "c -> {a + 1, +, 1}_1". In order to
|
|
|
|
|
determine the number of iterations in the loop_1, we have to
|
|
|
|
|
instantiate_parameters ({a + 1, +, 1}_1), that gives after some
|
|
|
|
|
more analysis the scev {4, +, 1}_1, or in other words, this is
|
|
|
|
|
the function "f (x) = x + 4", where x is the iteration count of
|
|
|
|
|
the loop_1. Now we have to solve the inequality "x + 4 > 10",
|
|
|
|
|
and take the smallest iteration number for which the loop is
|
|
|
|
|
exited: x = 7. This loop runs from x = 0 to x = 7, and in total
|
|
|
|
|
there are 8 iterations. In terms of loop normalization, we have
|
|
|
|
|
created a variable that is implicitly defined, "x" or just "_1",
|
|
|
|
|
and all the other analyzed scalars of the loop are defined in
|
|
|
|
|
function of this variable:
|
|
|
|
|
|
|
|
|
|
a -> 3
|
|
|
|
|
b -> {3, +, 1}_1
|
|
|
|
|
c -> {4, +, 1}_1
|
|
|
|
|
|
|
|
|
|
or in terms of a C program:
|
|
|
|
|
|
|
|
|
|
| a = 3
|
|
|
|
|
| for (x = 0; x <= 7; x++)
|
|
|
|
|
| {
|
|
|
|
|
| b = x + 3
|
|
|
|
|
| c = x + 4
|
|
|
|
|
| }
|
|
|
|
|
|
|
|
|
|
Example 2: Illustration of the algorithm on nested loops.
|
|
|
|
|
|
|
|
|
|
| loop_1
|
|
|
|
|
| a = phi (1, b)
|
|
|
|
|
| c = a + 2
|
|
|
|
|
| loop_2 10 times
|
|
|
|
|
| b = phi (c, d)
|
|
|
|
|
| d = b + 3
|
|
|
|
|
| endloop
|
|
|
|
|
| endloop
|
|
|
|
|
|
|
|
|
|
For analyzing the scalar evolution of "a", the algorithm follows
|
|
|
|
|
the SSA edge into the loop's body: "a -> b". "b" is an inner
|
|
|
|
|
loop-phi-node, and its analysis as in Example 1, gives:
|
|
|
|
|
|
|
|
|
|
b -> {c, +, 3}_2
|
|
|
|
|
d -> {c + 3, +, 3}_2
|
|
|
|
|
|
|
|
|
|
Following the SSA edge for the initial condition, we end on "c = a
|
|
|
|
|
+ 2", and then on the starting loop-phi-node "a". From this point,
|
|
|
|
|
the loop stride is computed: back on "c = a + 2" we get a "+2" in
|
|
|
|
|
the loop_1, then on the loop-phi-node "b" we compute the overall
|
|
|
|
|
effect of the inner loop that is "b = c + 30", and we get a "+30"
|
|
|
|
|
in the loop_1. That means that the overall stride in loop_1 is
|
|
|
|
|
equal to "+32", and the result is:
|
|
|
|
|
|
|
|
|
|
a -> {1, +, 32}_1
|
|
|
|
|
c -> {3, +, 32}_1
|
|
|
|
|
|
|
|
|
|
Example 3: Higher degree polynomials.
|
|
|
|
|
|
|
|
|
|
| loop_1
|
|
|
|
|
| a = phi (2, b)
|
|
|
|
|
| c = phi (5, d)
|
|
|
|
|
| b = a + 1
|
|
|
|
|
| d = c + a
|
|
|
|
|
| endloop
|
|
|
|
|
|
|
|
|
|
a -> {2, +, 1}_1
|
|
|
|
|
b -> {3, +, 1}_1
|
|
|
|
|
c -> {5, +, a}_1
|
|
|
|
|
d -> {5 + a, +, a}_1
|
|
|
|
|
|
|
|
|
|
instantiate_parameters ({5, +, a}_1) -> {5, +, 2, +, 1}_1
|
|
|
|
|
instantiate_parameters ({5 + a, +, a}_1) -> {7, +, 3, +, 1}_1
|
|
|
|
|
|
|
|
|
|
Example 4: Lucas, Fibonacci, or mixers in general.
|
|
|
|
|
|
|
|
|
|
| loop_1
|
|
|
|
|
| a = phi (1, b)
|
|
|
|
|
| c = phi (3, d)
|
|
|
|
|
| b = c
|
|
|
|
|
| d = c + a
|
|
|
|
|
| endloop
|
|
|
|
|
|
|
|
|
|
a -> (1, c)_1
|
|
|
|
|
c -> {3, +, a}_1
|
|
|
|
|
|
|
|
|
|
The syntax "(1, c)_1" stands for a PEELED_CHREC that has the
|
|
|
|
|
following semantics: during the first iteration of the loop_1, the
|
|
|
|
|
variable contains the value 1, and then it contains the value "c".
|
|
|
|
|
Note that this syntax is close to the syntax of the loop-phi-node:
|
|
|
|
|
"a -> (1, c)_1" vs. "a = phi (1, c)".
|
|
|
|
|
|
|
|
|
|
The symbolic chrec representation contains all the semantics of the
|
|
|
|
|
original code. What is more difficult is to use this information.
|
|
|
|
|
|
|
|
|
|
Example 5: Flip-flops, or exchangers.
|
|
|
|
|
|
|
|
|
|
| loop_1
|
|
|
|
|
| a = phi (1, b)
|
|
|
|
|
| c = phi (3, d)
|
|
|
|
|
| b = c
|
|
|
|
|
| d = a
|
|
|
|
|
| endloop
|
|
|
|
|
|
|
|
|
|
a -> (1, c)_1
|
|
|
|
|
c -> (3, a)_1
|
|
|
|
|
|
|
|
|
|
Based on these symbolic chrecs, it is possible to refine this
|
|
|
|
|
information into the more precise PERIODIC_CHRECs:
|
|
|
|
|
|
|
|
|
|
a -> |1, 3|_1
|
|
|
|
|
c -> |3, 1|_1
|
|
|
|
|
|
|
|
|
|
This transformation is not yet implemented.
|
|
|
|
|
|
|
|
|
|
Further readings:
|
|
|
|
|
|
|
|
|
|
You can find a more detailed description of the algorithm in:
|
|
|
|
|
http://icps.u-strasbg.fr/~pop/DEA_03_Pop.pdf
|
|
|
|
|
http://icps.u-strasbg.fr/~pop/DEA_03_Pop.ps.gz. But note that
|
|
|
|
|
this is a preliminary report and some of the details of the
|
|
|
|
|
algorithm have changed. I'm working on a research report that
|
|
|
|
|
updates the description of the algorithms to reflect the design
|
|
|
|
|
choices used in this implementation.
|
|
|
|
|
|
|
|
|
|
A set of slides show a high level overview of the algorithm and run
|
|
|
|
|
an example through the scalar evolution analyzer:
|
|
|
|
|
http://cri.ensmp.fr/~pop/gcc/mar04/slides.pdf
|
|
|
|
|
|
|
|
|
|
The slides that I have presented at the GCC Summit'04 are available
|
|
|
|
|
at: http://cri.ensmp.fr/~pop/gcc/20040604/gccsummit-lno-spop.pdf
|
|
|
|
|
*/
|
|
|
|
|
|
2004-07-09 05:19:14 +02:00
|
|
|
|
#include "config.h"
|
|
|
|
|
#include "system.h"
|
|
|
|
|
#include "coretypes.h"
|
|
|
|
|
#include "tm.h"
|
|
|
|
|
#include "ggc.h"
|
|
|
|
|
#include "tree.h"
|
2005-08-03 16:18:56 +02:00
|
|
|
|
#include "real.h"
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
/* These RTL headers are needed for basic-block.h. */
|
2004-07-09 05:19:14 +02:00
|
|
|
|
#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"
|
2004-07-12 21:31:16 +02:00
|
|
|
|
#include "tree-pass.h"
|
|
|
|
|
#include "flags.h"
|
2005-09-26 20:44:16 +02:00
|
|
|
|
#include "params.h"
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
static tree analyze_scalar_evolution_1 (struct loop *, tree, tree);
|
|
|
|
|
static tree resolve_mixers (struct loop *, tree);
|
|
|
|
|
|
|
|
|
|
/* The cached information about a ssa name VAR, claiming that inside LOOP,
|
|
|
|
|
the value of VAR can be expressed as CHREC. */
|
|
|
|
|
|
|
|
|
|
struct scev_info_str
|
|
|
|
|
{
|
|
|
|
|
tree var;
|
|
|
|
|
tree chrec;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Counters for the scev database. */
|
|
|
|
|
static unsigned nb_set_scev = 0;
|
|
|
|
|
static unsigned nb_get_scev = 0;
|
|
|
|
|
|
|
|
|
|
/* The following trees are unique elements. Thus the comparison of
|
|
|
|
|
another element to these elements should be done on the pointer to
|
|
|
|
|
these trees, and not on their value. */
|
|
|
|
|
|
|
|
|
|
/* The SSA_NAMEs that are not yet analyzed are qualified with NULL_TREE. */
|
|
|
|
|
tree chrec_not_analyzed_yet;
|
|
|
|
|
|
|
|
|
|
/* Reserved to the cases where the analyzer has detected an
|
|
|
|
|
undecidable property at compile time. */
|
|
|
|
|
tree chrec_dont_know;
|
|
|
|
|
|
|
|
|
|
/* When the analyzer has detected that a property will never
|
|
|
|
|
happen, then it qualifies it with chrec_known. */
|
|
|
|
|
tree chrec_known;
|
|
|
|
|
|
|
|
|
|
static bitmap already_instantiated;
|
|
|
|
|
|
|
|
|
|
static htab_t scalar_evolution_info;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Constructs a new SCEV_INFO_STR structure. */
|
|
|
|
|
|
|
|
|
|
static inline struct scev_info_str *
|
|
|
|
|
new_scev_info_str (tree var)
|
|
|
|
|
{
|
|
|
|
|
struct scev_info_str *res;
|
|
|
|
|
|
|
|
|
|
res = xmalloc (sizeof (struct scev_info_str));
|
|
|
|
|
res->var = var;
|
|
|
|
|
res->chrec = chrec_not_analyzed_yet;
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Computes a hash function for database element ELT. */
|
|
|
|
|
|
|
|
|
|
static hashval_t
|
|
|
|
|
hash_scev_info (const void *elt)
|
|
|
|
|
{
|
|
|
|
|
return SSA_NAME_VERSION (((struct scev_info_str *) elt)->var);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Compares database elements E1 and E2. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
eq_scev_info (const void *e1, const void *e2)
|
|
|
|
|
{
|
|
|
|
|
const struct scev_info_str *elt1 = e1;
|
|
|
|
|
const struct scev_info_str *elt2 = e2;
|
|
|
|
|
|
|
|
|
|
return elt1->var == elt2->var;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Deletes database element E. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
del_scev_info (void *e)
|
|
|
|
|
{
|
|
|
|
|
free (e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Get the index corresponding to VAR in the current LOOP. If
|
|
|
|
|
it's the first time we ask for this VAR, then we return
|
basic-block.h, [...]: Fix comment typos.
* basic-block.h, c-decl.c, c-parse.in, cgraphunit.c, ddg.c,
gimplify.c, lambda-code.c, optabs.c, predict.c,
tree-scalar-evolution.c, tree-sra.c, tree-ssa-loop-ch.c,
tree-ssa.c, vec.h: Fix comment typos. Follow spelling
conventions.
From-SVN: r87637
2004-09-17 11:14:12 +02:00
|
|
|
|
chrec_not_analyzed_yet for this VAR and return its index. */
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
static tree *
|
|
|
|
|
find_var_scev_info (tree var)
|
|
|
|
|
{
|
|
|
|
|
struct scev_info_str *res;
|
|
|
|
|
struct scev_info_str tmp;
|
|
|
|
|
PTR *slot;
|
|
|
|
|
|
|
|
|
|
tmp.var = var;
|
|
|
|
|
slot = htab_find_slot (scalar_evolution_info, &tmp, INSERT);
|
|
|
|
|
|
|
|
|
|
if (!*slot)
|
|
|
|
|
*slot = new_scev_info_str (var);
|
|
|
|
|
res = *slot;
|
|
|
|
|
|
|
|
|
|
return &res->chrec;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return true when CHREC contains symbolic names defined in
|
|
|
|
|
LOOP_NB. */
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
chrec_contains_symbols_defined_in_loop (tree chrec, unsigned loop_nb)
|
|
|
|
|
{
|
|
|
|
|
if (chrec == NULL_TREE)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (TREE_INVARIANT (chrec))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (chrec) == VAR_DECL
|
|
|
|
|
|| TREE_CODE (chrec) == PARM_DECL
|
|
|
|
|
|| TREE_CODE (chrec) == FUNCTION_DECL
|
|
|
|
|
|| TREE_CODE (chrec) == LABEL_DECL
|
|
|
|
|
|| TREE_CODE (chrec) == RESULT_DECL
|
|
|
|
|
|| TREE_CODE (chrec) == FIELD_DECL)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (chrec) == SSA_NAME)
|
|
|
|
|
{
|
|
|
|
|
tree def = SSA_NAME_DEF_STMT (chrec);
|
|
|
|
|
struct loop *def_loop = loop_containing_stmt (def);
|
|
|
|
|
struct loop *loop = current_loops->parray[loop_nb];
|
|
|
|
|
|
|
|
|
|
if (def_loop == NULL)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (loop == def_loop || flow_loop_nested_p (loop, def_loop))
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (TREE_CODE_LENGTH (TREE_CODE (chrec)))
|
|
|
|
|
{
|
|
|
|
|
case 3:
|
|
|
|
|
if (chrec_contains_symbols_defined_in_loop (TREE_OPERAND (chrec, 2),
|
|
|
|
|
loop_nb))
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
if (chrec_contains_symbols_defined_in_loop (TREE_OPERAND (chrec, 1),
|
|
|
|
|
loop_nb))
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
if (chrec_contains_symbols_defined_in_loop (TREE_OPERAND (chrec, 0),
|
|
|
|
|
loop_nb))
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return true when PHI is a loop-phi-node. */
|
|
|
|
|
|
|
|
|
|
static bool
|
|
|
|
|
loop_phi_node_p (tree phi)
|
|
|
|
|
{
|
|
|
|
|
/* The implementation of this function is based on the following
|
|
|
|
|
property: "all the loop-phi-nodes of a loop are contained in the
|
|
|
|
|
loop's header basic block". */
|
|
|
|
|
|
|
|
|
|
return loop_containing_stmt (phi)->header == bb_for_stmt (phi);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Compute the scalar evolution for EVOLUTION_FN after crossing LOOP.
|
|
|
|
|
In general, in the case of multivariate evolutions we want to get
|
|
|
|
|
the evolution in different loops. LOOP specifies the level for
|
|
|
|
|
which to get the evolution.
|
|
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
|
|
| for (j = 0; j < 100; j++)
|
|
|
|
|
| {
|
|
|
|
|
| for (k = 0; k < 100; k++)
|
|
|
|
|
| {
|
|
|
|
|
| i = k + j; - Here the value of i is a function of j, k.
|
|
|
|
|
| }
|
|
|
|
|
| ... = i - Here the value of i is a function of j.
|
|
|
|
|
| }
|
|
|
|
|
| ... = i - Here the value of i is a scalar.
|
|
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
|
|
| i_0 = ...
|
|
|
|
|
| loop_1 10 times
|
|
|
|
|
| i_1 = phi (i_0, i_2)
|
|
|
|
|
| i_2 = i_1 + 2
|
|
|
|
|
| endloop
|
|
|
|
|
|
|
|
|
|
This loop has the same effect as:
|
|
|
|
|
LOOP_1 has the same effect as:
|
|
|
|
|
|
|
|
|
|
| i_1 = i_0 + 20
|
|
|
|
|
|
|
|
|
|
The overall effect of the loop, "i_0 + 20" in the previous example,
|
|
|
|
|
is obtained by passing in the parameters: LOOP = 1,
|
|
|
|
|
EVOLUTION_FN = {i_0, +, 2}_1.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static tree
|
|
|
|
|
compute_overall_effect_of_inner_loop (struct loop *loop, tree evolution_fn)
|
|
|
|
|
{
|
|
|
|
|
bool val = false;
|
|
|
|
|
|
|
|
|
|
if (evolution_fn == chrec_dont_know)
|
|
|
|
|
return chrec_dont_know;
|
|
|
|
|
|
|
|
|
|
else if (TREE_CODE (evolution_fn) == POLYNOMIAL_CHREC)
|
|
|
|
|
{
|
|
|
|
|
if (CHREC_VARIABLE (evolution_fn) >= (unsigned) loop->num)
|
|
|
|
|
{
|
|
|
|
|
struct loop *inner_loop =
|
|
|
|
|
current_loops->parray[CHREC_VARIABLE (evolution_fn)];
|
|
|
|
|
tree nb_iter = number_of_iterations_in_loop (inner_loop);
|
|
|
|
|
|
|
|
|
|
if (nb_iter == chrec_dont_know)
|
|
|
|
|
return chrec_dont_know;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tree res;
|
|
|
|
|
|
|
|
|
|
/* Number of iterations is off by one (the ssa name we
|
|
|
|
|
analyze must be defined before the exit). */
|
|
|
|
|
nb_iter = chrec_fold_minus (chrec_type (nb_iter),
|
tree-chrec.c (chrec_fold_plus_poly_poly, [...]): Use fold_convert or build_int_cst_type instead od fonvert.
* tree-chrec.c (chrec_fold_plus_poly_poly, chrec_fold_plus_1,
chrec_fold_multiply): Use fold_convert or build_int_cst_type instead
od fonvert.
* tree-scalar-evolution.c (compute_overall_effect_of_inner_loop,
add_to_evolution, set_nb_iterations_in_loop, follow_ssa_edge_in_rhs,
follow_ssa_edge_in_rhs): Ditto.
* tree-ssa-loop-ivopts.c (struct iv): Add base_object field.
(dump_iv): Dump base_object.
(dump_use, dump_cand): Use dump_iv.
(determine_base_object): New function.
(alloc_iv): Initialize base_object field.
(record_use): Clear the ssa_name field of iv.
(get_computation_cost_at): Do not use difference of addresses of
two different objects.
(may_eliminate_iv): Do not require the loop to have just single exit.
* tree-ssa-loop-niter.c (zero_p): Do not check for overflows.
(nonzero_p): New function.
(inverse, number_of_iterations_cond, simplify_using_outer_evolutions,
tree_simplify_using_condition, simplify_using_initial_conditions,
loop_niter_by_eval, find_loop_niter_by_eval,
estimate_numbers_of_iterations_loop, compare_trees,
upper_bound_in_type, lower_bound_in_type,
can_count_iv_in_wider_type_bound): Use buildN instead of build. Use
fold_convert or build_int_cst_type instead of convert. Use (non)zero_p
instead of integer_(non)zerop.
From-SVN: r88388
2004-10-01 11:06:06 +02:00
|
|
|
|
nb_iter,
|
|
|
|
|
build_int_cst_type (chrec_type (nb_iter), 1));
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
/* evolution_fn is the evolution function in LOOP. Get
|
|
|
|
|
its value in the nb_iter-th iteration. */
|
|
|
|
|
res = chrec_apply (inner_loop->num, evolution_fn, nb_iter);
|
|
|
|
|
|
c-common.c, [...]: Fix comment formatting.
* c-common.c, c-decl.c, combine.c, defaults.h, fold-const.c,
gimplify.c, gthr-nks.h, hooks.c, lambda-code.c, lambda-mat.c,
stor-layout.c, target.h, tree-cfg.c, tree-chrec.c,
tree-if-conv.c, tree-inline.c, tree-into-ssa.c,
tree-mudflap.c, tree-optimize.c, tree-scalar-evolution.c,
tree-ssa-alias.c, tree-ssa-ccp.c, tree-ssa-dce.c,
tree-ssa-pre.c, tree-vectorizer.c, tree-vectorizer.h, tree.h,
vec.h: Fix comment formatting.
From-SVN: r87105
2004-09-05 18:05:06 +02:00
|
|
|
|
/* Continue the computation until ending on a parent of LOOP. */
|
2004-07-12 21:31:16 +02:00
|
|
|
|
return compute_overall_effect_of_inner_loop (loop, res);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return evolution_fn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If the evolution function is an invariant, there is nothing to do. */
|
|
|
|
|
else if (no_evolution_in_loop_p (evolution_fn, loop->num, &val) && val)
|
|
|
|
|
return evolution_fn;
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
return chrec_dont_know;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Determine whether the CHREC is always positive/negative. If the expression
|
|
|
|
|
cannot be statically analyzed, return false, otherwise set the answer into
|
|
|
|
|
VALUE. */
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
chrec_is_positive (tree chrec, bool *value)
|
|
|
|
|
{
|
|
|
|
|
bool value0, value1;
|
|
|
|
|
bool value2;
|
|
|
|
|
tree end_value;
|
|
|
|
|
tree nb_iter;
|
|
|
|
|
|
|
|
|
|
switch (TREE_CODE (chrec))
|
|
|
|
|
{
|
|
|
|
|
case POLYNOMIAL_CHREC:
|
|
|
|
|
if (!chrec_is_positive (CHREC_LEFT (chrec), &value0)
|
|
|
|
|
|| !chrec_is_positive (CHREC_RIGHT (chrec), &value1))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/* FIXME -- overflows. */
|
|
|
|
|
if (value0 == value1)
|
|
|
|
|
{
|
|
|
|
|
*value = value0;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Otherwise the chrec is under the form: "{-197, +, 2}_1",
|
|
|
|
|
and the proof consists in showing that the sign never
|
|
|
|
|
changes during the execution of the loop, from 0 to
|
|
|
|
|
loop->nb_iterations. */
|
|
|
|
|
if (!evolution_function_is_affine_p (chrec))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
nb_iter = number_of_iterations_in_loop
|
|
|
|
|
(current_loops->parray[CHREC_VARIABLE (chrec)]);
|
|
|
|
|
|
|
|
|
|
if (chrec_contains_undetermined (nb_iter))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
nb_iter = chrec_fold_minus
|
|
|
|
|
(chrec_type (nb_iter), nb_iter,
|
2004-09-07 12:22:44 +02:00
|
|
|
|
build_int_cst (chrec_type (nb_iter), 1));
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
/* TODO -- If the test is after the exit, we may decrease the number of
|
|
|
|
|
iterations by one. */
|
|
|
|
|
if (after_exit)
|
|
|
|
|
nb_iter = chrec_fold_minus
|
|
|
|
|
(chrec_type (nb_iter), nb_iter,
|
2004-09-07 12:22:44 +02:00
|
|
|
|
build_int_cst (chrec_type (nb_iter), 1));
|
2004-07-12 21:31:16 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
end_value = chrec_apply (CHREC_VARIABLE (chrec), chrec, nb_iter);
|
|
|
|
|
|
|
|
|
|
if (!chrec_is_positive (end_value, &value2))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
*value = value0;
|
|
|
|
|
return value0 == value1;
|
|
|
|
|
|
|
|
|
|
case INTEGER_CST:
|
|
|
|
|
*value = (tree_int_cst_sgn (chrec) == 1);
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Associate CHREC to SCALAR. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
set_scalar_evolution (tree scalar, tree chrec)
|
|
|
|
|
{
|
|
|
|
|
tree *scalar_info;
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (scalar) != SSA_NAME)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
scalar_info = find_var_scev_info (scalar);
|
|
|
|
|
|
|
|
|
|
if (dump_file)
|
|
|
|
|
{
|
|
|
|
|
if (dump_flags & TDF_DETAILS)
|
|
|
|
|
{
|
|
|
|
|
fprintf (dump_file, "(set_scalar_evolution \n");
|
|
|
|
|
fprintf (dump_file, " (scalar = ");
|
|
|
|
|
print_generic_expr (dump_file, scalar, 0);
|
|
|
|
|
fprintf (dump_file, ")\n (scalar_evolution = ");
|
|
|
|
|
print_generic_expr (dump_file, chrec, 0);
|
|
|
|
|
fprintf (dump_file, "))\n");
|
|
|
|
|
}
|
|
|
|
|
if (dump_flags & TDF_STATS)
|
|
|
|
|
nb_set_scev++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*scalar_info = chrec;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Retrieve the chrec associated to SCALAR in the LOOP. */
|
|
|
|
|
|
|
|
|
|
static tree
|
|
|
|
|
get_scalar_evolution (tree scalar)
|
|
|
|
|
{
|
|
|
|
|
tree res;
|
|
|
|
|
|
|
|
|
|
if (dump_file)
|
|
|
|
|
{
|
|
|
|
|
if (dump_flags & TDF_DETAILS)
|
|
|
|
|
{
|
|
|
|
|
fprintf (dump_file, "(get_scalar_evolution \n");
|
|
|
|
|
fprintf (dump_file, " (scalar = ");
|
|
|
|
|
print_generic_expr (dump_file, scalar, 0);
|
|
|
|
|
fprintf (dump_file, ")\n");
|
|
|
|
|
}
|
|
|
|
|
if (dump_flags & TDF_STATS)
|
|
|
|
|
nb_get_scev++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (TREE_CODE (scalar))
|
|
|
|
|
{
|
|
|
|
|
case SSA_NAME:
|
|
|
|
|
res = *find_var_scev_info (scalar);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case REAL_CST:
|
|
|
|
|
case INTEGER_CST:
|
|
|
|
|
res = scalar;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
res = chrec_not_analyzed_yet;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
|
{
|
|
|
|
|
fprintf (dump_file, " (scalar_evolution = ");
|
|
|
|
|
print_generic_expr (dump_file, res, 0);
|
|
|
|
|
fprintf (dump_file, "))\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Helper function for add_to_evolution. Returns the evolution
|
|
|
|
|
function for an assignment of the form "a = b + c", where "a" and
|
|
|
|
|
"b" are on the strongly connected component. CHREC_BEFORE is the
|
|
|
|
|
information that we already have collected up to this point.
|
|
|
|
|
TO_ADD is the evolution of "c".
|
|
|
|
|
|
|
|
|
|
When CHREC_BEFORE has an evolution part in LOOP_NB, add to this
|
|
|
|
|
evolution the expression TO_ADD, otherwise construct an evolution
|
|
|
|
|
part for this loop. */
|
|
|
|
|
|
|
|
|
|
static tree
|
|
|
|
|
add_to_evolution_1 (unsigned loop_nb,
|
|
|
|
|
tree chrec_before,
|
|
|
|
|
tree to_add)
|
|
|
|
|
{
|
|
|
|
|
switch (TREE_CODE (chrec_before))
|
|
|
|
|
{
|
|
|
|
|
case POLYNOMIAL_CHREC:
|
|
|
|
|
if (CHREC_VARIABLE (chrec_before) <= loop_nb)
|
|
|
|
|
{
|
|
|
|
|
unsigned var;
|
|
|
|
|
tree left, right;
|
|
|
|
|
tree type = chrec_type (chrec_before);
|
|
|
|
|
|
|
|
|
|
/* When there is no evolution part in this loop, build it. */
|
|
|
|
|
if (CHREC_VARIABLE (chrec_before) < loop_nb)
|
|
|
|
|
{
|
|
|
|
|
var = loop_nb;
|
|
|
|
|
left = chrec_before;
|
2005-08-15 14:26:12 +02:00
|
|
|
|
right = SCALAR_FLOAT_TYPE_P (type)
|
|
|
|
|
? build_real (type, dconst0)
|
|
|
|
|
: build_int_cst (type, 0);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var = CHREC_VARIABLE (chrec_before);
|
|
|
|
|
left = CHREC_LEFT (chrec_before);
|
|
|
|
|
right = CHREC_RIGHT (chrec_before);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return build_polynomial_chrec
|
|
|
|
|
(var, left, chrec_fold_plus (type, right, to_add));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
/* Search the evolution in LOOP_NB. */
|
|
|
|
|
return build_polynomial_chrec
|
|
|
|
|
(CHREC_VARIABLE (chrec_before),
|
|
|
|
|
add_to_evolution_1 (loop_nb, CHREC_LEFT (chrec_before), to_add),
|
|
|
|
|
CHREC_RIGHT (chrec_before));
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
/* These nodes do not depend on a loop. */
|
|
|
|
|
if (chrec_before == chrec_dont_know)
|
|
|
|
|
return chrec_dont_know;
|
|
|
|
|
return build_polynomial_chrec (loop_nb, chrec_before, to_add);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Add TO_ADD to the evolution part of CHREC_BEFORE in the dimension
|
|
|
|
|
of LOOP_NB.
|
|
|
|
|
|
|
|
|
|
Description (provided for completeness, for those who read code in
|
|
|
|
|
a plane, and for my poor 62 bytes brain that would have forgotten
|
|
|
|
|
all this in the next two or three months):
|
|
|
|
|
|
|
|
|
|
The algorithm of translation of programs from the SSA representation
|
|
|
|
|
into the chrecs syntax is based on a pattern matching. After having
|
|
|
|
|
reconstructed the overall tree expression for a loop, there are only
|
|
|
|
|
two cases that can arise:
|
|
|
|
|
|
|
|
|
|
1. a = loop-phi (init, a + expr)
|
|
|
|
|
2. a = loop-phi (init, expr)
|
|
|
|
|
|
|
|
|
|
where EXPR is either a scalar constant with respect to the analyzed
|
|
|
|
|
loop (this is a degree 0 polynomial), or an expression containing
|
|
|
|
|
other loop-phi definitions (these are higher degree polynomials).
|
|
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
|
|
|
|
|
1.
|
|
|
|
|
| init = ...
|
|
|
|
|
| loop_1
|
|
|
|
|
| a = phi (init, a + 5)
|
|
|
|
|
| endloop
|
|
|
|
|
|
|
|
|
|
2.
|
|
|
|
|
| inita = ...
|
|
|
|
|
| initb = ...
|
|
|
|
|
| loop_1
|
|
|
|
|
| a = phi (inita, 2 * b + 3)
|
|
|
|
|
| b = phi (initb, b + 1)
|
|
|
|
|
| endloop
|
|
|
|
|
|
|
|
|
|
For the first case, the semantics of the SSA representation is:
|
|
|
|
|
|
|
|
|
|
| a (x) = init + \sum_{j = 0}^{x - 1} expr (j)
|
|
|
|
|
|
|
|
|
|
that is, there is a loop index "x" that determines the scalar value
|
|
|
|
|
of the variable during the loop execution. During the first
|
|
|
|
|
iteration, the value is that of the initial condition INIT, while
|
|
|
|
|
during the subsequent iterations, it is the sum of the initial
|
|
|
|
|
condition with the sum of all the values of EXPR from the initial
|
|
|
|
|
iteration to the before last considered iteration.
|
|
|
|
|
|
|
|
|
|
For the second case, the semantics of the SSA program is:
|
|
|
|
|
|
|
|
|
|
| a (x) = init, if x = 0;
|
|
|
|
|
| expr (x - 1), otherwise.
|
|
|
|
|
|
|
|
|
|
The second case corresponds to the PEELED_CHREC, whose syntax is
|
|
|
|
|
close to the syntax of a loop-phi-node:
|
|
|
|
|
|
|
|
|
|
| phi (init, expr) vs. (init, expr)_x
|
|
|
|
|
|
|
|
|
|
The proof of the translation algorithm for the first case is a
|
|
|
|
|
proof by structural induction based on the degree of EXPR.
|
|
|
|
|
|
|
|
|
|
Degree 0:
|
|
|
|
|
When EXPR is a constant with respect to the analyzed loop, or in
|
|
|
|
|
other words when EXPR is a polynomial of degree 0, the evolution of
|
|
|
|
|
the variable A in the loop is an affine function with an initial
|
|
|
|
|
condition INIT, and a step EXPR. In order to show this, we start
|
|
|
|
|
from the semantics of the SSA representation:
|
|
|
|
|
|
|
|
|
|
f (x) = init + \sum_{j = 0}^{x - 1} expr (j)
|
|
|
|
|
|
|
|
|
|
and since "expr (j)" is a constant with respect to "j",
|
|
|
|
|
|
|
|
|
|
f (x) = init + x * expr
|
|
|
|
|
|
|
|
|
|
Finally, based on the semantics of the pure sum chrecs, by
|
|
|
|
|
identification we get the corresponding chrecs syntax:
|
|
|
|
|
|
|
|
|
|
f (x) = init * \binom{x}{0} + expr * \binom{x}{1}
|
|
|
|
|
f (x) -> {init, +, expr}_x
|
|
|
|
|
|
|
|
|
|
Higher degree:
|
|
|
|
|
Suppose that EXPR is a polynomial of degree N with respect to the
|
|
|
|
|
analyzed loop_x for which we have already determined that it is
|
|
|
|
|
written under the chrecs syntax:
|
|
|
|
|
|
|
|
|
|
| expr (x) -> {b_0, +, b_1, +, ..., +, b_{n-1}} (x)
|
|
|
|
|
|
|
|
|
|
We start from the semantics of the SSA program:
|
|
|
|
|
|
|
|
|
|
| f (x) = init + \sum_{j = 0}^{x - 1} expr (j)
|
|
|
|
|
|
|
|
|
|
|
| f (x) = init + \sum_{j = 0}^{x - 1}
|
|
|
|
|
| (b_0 * \binom{j}{0} + ... + b_{n-1} * \binom{j}{n-1})
|
|
|
|
|
|
|
|
|
|
|
| f (x) = init + \sum_{j = 0}^{x - 1}
|
|
|
|
|
| \sum_{k = 0}^{n - 1} (b_k * \binom{j}{k})
|
|
|
|
|
|
|
|
|
|
|
| f (x) = init + \sum_{k = 0}^{n - 1}
|
|
|
|
|
| (b_k * \sum_{j = 0}^{x - 1} \binom{j}{k})
|
|
|
|
|
|
|
|
|
|
|
| f (x) = init + \sum_{k = 0}^{n - 1}
|
|
|
|
|
| (b_k * \binom{x}{k + 1})
|
|
|
|
|
|
|
|
|
|
|
| f (x) = init + b_0 * \binom{x}{1} + ...
|
|
|
|
|
| + b_{n-1} * \binom{x}{n}
|
|
|
|
|
|
|
|
|
|
|
| f (x) = init * \binom{x}{0} + b_0 * \binom{x}{1} + ...
|
|
|
|
|
| + b_{n-1} * \binom{x}{n}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
And finally from the definition of the chrecs syntax, we identify:
|
|
|
|
|
| f (x) -> {init, +, b_0, +, ..., +, b_{n-1}}_x
|
|
|
|
|
|
|
|
|
|
This shows the mechanism that stands behind the add_to_evolution
|
|
|
|
|
function. An important point is that the use of symbolic
|
|
|
|
|
parameters avoids the need of an analysis schedule.
|
|
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
|
|
| inita = ...
|
|
|
|
|
| initb = ...
|
|
|
|
|
| loop_1
|
|
|
|
|
| a = phi (inita, a + 2 + b)
|
|
|
|
|
| b = phi (initb, b + 1)
|
|
|
|
|
| endloop
|
|
|
|
|
|
|
|
|
|
When analyzing "a", the algorithm keeps "b" symbolically:
|
|
|
|
|
|
|
|
|
|
| a -> {inita, +, 2 + b}_1
|
|
|
|
|
|
|
|
|
|
Then, after instantiation, the analyzer ends on the evolution:
|
|
|
|
|
|
|
|
|
|
| a -> {inita, +, 2 + initb, +, 1}_1
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static tree
|
|
|
|
|
add_to_evolution (unsigned loop_nb,
|
|
|
|
|
tree chrec_before,
|
|
|
|
|
enum tree_code code,
|
|
|
|
|
tree to_add)
|
|
|
|
|
{
|
|
|
|
|
tree type = chrec_type (to_add);
|
|
|
|
|
tree res = NULL_TREE;
|
|
|
|
|
|
|
|
|
|
if (to_add == NULL_TREE)
|
|
|
|
|
return chrec_before;
|
|
|
|
|
|
|
|
|
|
/* TO_ADD is either a scalar, or a parameter. TO_ADD is not
|
|
|
|
|
instantiated at this point. */
|
|
|
|
|
if (TREE_CODE (to_add) == POLYNOMIAL_CHREC)
|
|
|
|
|
/* This should not happen. */
|
|
|
|
|
return chrec_dont_know;
|
|
|
|
|
|
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
|
{
|
|
|
|
|
fprintf (dump_file, "(add_to_evolution \n");
|
|
|
|
|
fprintf (dump_file, " (loop_nb = %d)\n", loop_nb);
|
|
|
|
|
fprintf (dump_file, " (chrec_before = ");
|
|
|
|
|
print_generic_expr (dump_file, chrec_before, 0);
|
|
|
|
|
fprintf (dump_file, ")\n (to_add = ");
|
|
|
|
|
print_generic_expr (dump_file, to_add, 0);
|
|
|
|
|
fprintf (dump_file, ")\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (code == MINUS_EXPR)
|
2005-08-03 16:18:56 +02:00
|
|
|
|
to_add = chrec_fold_multiply (type, to_add, SCALAR_FLOAT_TYPE_P (type)
|
|
|
|
|
? build_real (type, dconstm1)
|
|
|
|
|
: build_int_cst_type (type, -1));
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
res = add_to_evolution_1 (loop_nb, chrec_before, to_add);
|
|
|
|
|
|
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
|
{
|
|
|
|
|
fprintf (dump_file, " (res = ");
|
|
|
|
|
print_generic_expr (dump_file, res, 0);
|
|
|
|
|
fprintf (dump_file, "))\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Helper function. */
|
|
|
|
|
|
|
|
|
|
static inline tree
|
|
|
|
|
set_nb_iterations_in_loop (struct loop *loop,
|
|
|
|
|
tree res)
|
|
|
|
|
{
|
tree-chrec.c (chrec_fold_plus_poly_poly, [...]): Use fold_convert or build_int_cst_type instead od fonvert.
* tree-chrec.c (chrec_fold_plus_poly_poly, chrec_fold_plus_1,
chrec_fold_multiply): Use fold_convert or build_int_cst_type instead
od fonvert.
* tree-scalar-evolution.c (compute_overall_effect_of_inner_loop,
add_to_evolution, set_nb_iterations_in_loop, follow_ssa_edge_in_rhs,
follow_ssa_edge_in_rhs): Ditto.
* tree-ssa-loop-ivopts.c (struct iv): Add base_object field.
(dump_iv): Dump base_object.
(dump_use, dump_cand): Use dump_iv.
(determine_base_object): New function.
(alloc_iv): Initialize base_object field.
(record_use): Clear the ssa_name field of iv.
(get_computation_cost_at): Do not use difference of addresses of
two different objects.
(may_eliminate_iv): Do not require the loop to have just single exit.
* tree-ssa-loop-niter.c (zero_p): Do not check for overflows.
(nonzero_p): New function.
(inverse, number_of_iterations_cond, simplify_using_outer_evolutions,
tree_simplify_using_condition, simplify_using_initial_conditions,
loop_niter_by_eval, find_loop_niter_by_eval,
estimate_numbers_of_iterations_loop, compare_trees,
upper_bound_in_type, lower_bound_in_type,
can_count_iv_in_wider_type_bound): Use buildN instead of build. Use
fold_convert or build_int_cst_type instead of convert. Use (non)zero_p
instead of integer_(non)zerop.
From-SVN: r88388
2004-10-01 11:06:06 +02:00
|
|
|
|
res = chrec_fold_plus (chrec_type (res), res,
|
|
|
|
|
build_int_cst_type (chrec_type (res), 1));
|
|
|
|
|
|
2004-07-12 21:31:16 +02:00
|
|
|
|
/* FIXME HWI: However we want to store one iteration less than the
|
|
|
|
|
count of the loop in order to be compatible with the other
|
|
|
|
|
nb_iter computations in loop-iv. This also allows the
|
|
|
|
|
representation of nb_iters that are equal to MAX_INT. */
|
2005-05-16 06:36:09 +02:00
|
|
|
|
if (TREE_CODE (res) == INTEGER_CST
|
|
|
|
|
&& (TREE_INT_CST_LOW (res) == 0
|
|
|
|
|
|| TREE_OVERFLOW (res)))
|
2004-07-12 21:31:16 +02:00
|
|
|
|
res = chrec_dont_know;
|
|
|
|
|
|
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
|
{
|
|
|
|
|
fprintf (dump_file, " (set_nb_iterations_in_loop = ");
|
|
|
|
|
print_generic_expr (dump_file, res, 0);
|
|
|
|
|
fprintf (dump_file, "))\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loop->nb_iterations = res;
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* This section selects the loops that will be good candidates for the
|
|
|
|
|
scalar evolution analysis. For the moment, greedily select all the
|
|
|
|
|
loop nests we could analyze. */
|
|
|
|
|
|
|
|
|
|
/* Return true when it is possible to analyze the condition expression
|
|
|
|
|
EXPR. */
|
|
|
|
|
|
|
|
|
|
static bool
|
|
|
|
|
analyzable_condition (tree expr)
|
|
|
|
|
{
|
|
|
|
|
tree condition;
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (expr) != COND_EXPR)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
condition = TREE_OPERAND (expr, 0);
|
|
|
|
|
|
|
|
|
|
switch (TREE_CODE (condition))
|
|
|
|
|
{
|
|
|
|
|
case SSA_NAME:
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
case LT_EXPR:
|
|
|
|
|
case LE_EXPR:
|
|
|
|
|
case GT_EXPR:
|
|
|
|
|
case GE_EXPR:
|
|
|
|
|
case EQ_EXPR:
|
|
|
|
|
case NE_EXPR:
|
2004-11-12 14:28:16 +01:00
|
|
|
|
return true;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* For a loop with a single exit edge, return the COND_EXPR that
|
|
|
|
|
guards the exit edge. If the expression is too difficult to
|
|
|
|
|
analyze, then give up. */
|
|
|
|
|
|
|
|
|
|
tree
|
|
|
|
|
get_loop_exit_condition (struct loop *loop)
|
|
|
|
|
{
|
|
|
|
|
tree res = NULL_TREE;
|
tree-ssa-loop-ivcanon.c: New file.
* tree-ssa-loop-ivcanon.c: New file.
* tree-ssa-loop-manip.c (create_iv): New function.
* Makefile.in (tree-ssa-loop-ivcanon.o): Add.
(tree-ssa-loop.o, tree-ssa-loop-manip.o): Add SCEV_H dependency.
* cfgloop.c (mark_single_exit_loops): New function.
(verify_loop_structure): Verify single-exit loops.
* cfgloop.h (struct loop): Add single_exit field.
(LOOPS_HAVE_MARKED_SINGLE_EXITS): New constant.
(mark_single_exit_loops): Declare.
(tree_num_loop_insns): Declare.
* cfgloopmanip.c (update_single_exits_after_duplication): New function.
(duplicate_loop_to_header_edge): Use it.
* common.opt (fivcanon): New flag.
* timevar.def (TV_TREE_LOOP_IVCANON, TV_COMPLETE_UNROLL): New timevars.
* tree-cfg.c (tree_find_edge_insert_loc): Return newly created block.
(bsi_commit_edge_inserts_1): Pass null to tree_find_edge_insert_loc.
(bsi_insert_on_edge_immediate): New function.
* tree-flow.h (bsi_insert_on_edge_immediate,
canonicalize_induction_variables, tree_unroll_loops_completely,
create_iv): Declare.
* tree-optimize.c (init_tree_optimization_passes): Add
pass_iv_canon and pass_complete_unroll.
* tree-pass.h (pass_iv_canon, pass_complete_unroll): Declare.
* tree-scalar-evolution.c (get_loop_exit_condition,
get_exit_conditions_rec, number_of_iterations_in_loop,
scev_initialize): Use single_exit information.
* tree-ssa-loop-niter.c (number_of_iterations_cond): Record
missing assumptions.
(loop_niter_by_eval): Return number of iterations as unsigned
int.
* tree-ssa-loop.c (tree_ssa_loop_init): Mark single exit loops.
(tree_ssa_loop_ivcanon, gate_tree_ssa_loop_ivcanon, pass_iv_canon,
tree_complete_unroll, gate_tree_complete_unroll, pass_complete_unroll):
New passes.
(tree_ssa_loop_done): Call free_numbers_of_iterations_estimates.
* tree-ssanames.c (make_ssa_name): Allow creating ssa name before
the defining statement is ready.
* tree-vectorizer.c (vect_create_iv_simple): Removed.
(vect_create_index_for_array_ref, vect_transform_loop_bound):
Use create_iv.
(vect_transform_loop_bound): Use single_exit information.
(vect_analyze_loop_form): Cleanup bogus tests.
(vectorize_loops): Do not call flow_loop_scan.
* tree.h (may_negate_without_overflow_p): Declare.
* fold-const.c (may_negate_without_overflow_p): Split out from ...
(negate_expr_p): ... this function.
(tree_expr_nonzero_p): Handle overflowed constants correctly.
* doc/invoke.texi (-fivcanon): Document.
* doc/passes.texi: Document canonical induction variable creation.
* gcc.dg/tree-ssa/loop-1.c: New test.
From-SVN: r86516
2004-08-24 22:48:23 +02:00
|
|
|
|
edge exit_edge = loop->single_exit;
|
|
|
|
|
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
|
fprintf (dump_file, "(get_loop_exit_condition \n ");
|
|
|
|
|
|
tree-ssa-loop-ivcanon.c: New file.
* tree-ssa-loop-ivcanon.c: New file.
* tree-ssa-loop-manip.c (create_iv): New function.
* Makefile.in (tree-ssa-loop-ivcanon.o): Add.
(tree-ssa-loop.o, tree-ssa-loop-manip.o): Add SCEV_H dependency.
* cfgloop.c (mark_single_exit_loops): New function.
(verify_loop_structure): Verify single-exit loops.
* cfgloop.h (struct loop): Add single_exit field.
(LOOPS_HAVE_MARKED_SINGLE_EXITS): New constant.
(mark_single_exit_loops): Declare.
(tree_num_loop_insns): Declare.
* cfgloopmanip.c (update_single_exits_after_duplication): New function.
(duplicate_loop_to_header_edge): Use it.
* common.opt (fivcanon): New flag.
* timevar.def (TV_TREE_LOOP_IVCANON, TV_COMPLETE_UNROLL): New timevars.
* tree-cfg.c (tree_find_edge_insert_loc): Return newly created block.
(bsi_commit_edge_inserts_1): Pass null to tree_find_edge_insert_loc.
(bsi_insert_on_edge_immediate): New function.
* tree-flow.h (bsi_insert_on_edge_immediate,
canonicalize_induction_variables, tree_unroll_loops_completely,
create_iv): Declare.
* tree-optimize.c (init_tree_optimization_passes): Add
pass_iv_canon and pass_complete_unroll.
* tree-pass.h (pass_iv_canon, pass_complete_unroll): Declare.
* tree-scalar-evolution.c (get_loop_exit_condition,
get_exit_conditions_rec, number_of_iterations_in_loop,
scev_initialize): Use single_exit information.
* tree-ssa-loop-niter.c (number_of_iterations_cond): Record
missing assumptions.
(loop_niter_by_eval): Return number of iterations as unsigned
int.
* tree-ssa-loop.c (tree_ssa_loop_init): Mark single exit loops.
(tree_ssa_loop_ivcanon, gate_tree_ssa_loop_ivcanon, pass_iv_canon,
tree_complete_unroll, gate_tree_complete_unroll, pass_complete_unroll):
New passes.
(tree_ssa_loop_done): Call free_numbers_of_iterations_estimates.
* tree-ssanames.c (make_ssa_name): Allow creating ssa name before
the defining statement is ready.
* tree-vectorizer.c (vect_create_iv_simple): Removed.
(vect_create_index_for_array_ref, vect_transform_loop_bound):
Use create_iv.
(vect_transform_loop_bound): Use single_exit information.
(vect_analyze_loop_form): Cleanup bogus tests.
(vectorize_loops): Do not call flow_loop_scan.
* tree.h (may_negate_without_overflow_p): Declare.
* fold-const.c (may_negate_without_overflow_p): Split out from ...
(negate_expr_p): ... this function.
(tree_expr_nonzero_p): Handle overflowed constants correctly.
* doc/invoke.texi (-fivcanon): Document.
* doc/passes.texi: Document canonical induction variable creation.
* gcc.dg/tree-ssa/loop-1.c: New test.
From-SVN: r86516
2004-08-24 22:48:23 +02:00
|
|
|
|
if (exit_edge)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
{
|
|
|
|
|
tree expr;
|
|
|
|
|
|
|
|
|
|
expr = last_stmt (exit_edge->src);
|
|
|
|
|
if (analyzable_condition (expr))
|
|
|
|
|
res = expr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
|
{
|
|
|
|
|
print_generic_expr (dump_file, res, 0);
|
|
|
|
|
fprintf (dump_file, ")\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Recursively determine and enqueue the exit conditions for a loop. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
get_exit_conditions_rec (struct loop *loop,
|
2005-05-02 10:56:52 +02:00
|
|
|
|
VEC(tree,heap) **exit_conditions)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
{
|
|
|
|
|
if (!loop)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* Recurse on the inner loops, then on the next (sibling) loops. */
|
|
|
|
|
get_exit_conditions_rec (loop->inner, exit_conditions);
|
|
|
|
|
get_exit_conditions_rec (loop->next, exit_conditions);
|
|
|
|
|
|
tree-ssa-loop-ivcanon.c: New file.
* tree-ssa-loop-ivcanon.c: New file.
* tree-ssa-loop-manip.c (create_iv): New function.
* Makefile.in (tree-ssa-loop-ivcanon.o): Add.
(tree-ssa-loop.o, tree-ssa-loop-manip.o): Add SCEV_H dependency.
* cfgloop.c (mark_single_exit_loops): New function.
(verify_loop_structure): Verify single-exit loops.
* cfgloop.h (struct loop): Add single_exit field.
(LOOPS_HAVE_MARKED_SINGLE_EXITS): New constant.
(mark_single_exit_loops): Declare.
(tree_num_loop_insns): Declare.
* cfgloopmanip.c (update_single_exits_after_duplication): New function.
(duplicate_loop_to_header_edge): Use it.
* common.opt (fivcanon): New flag.
* timevar.def (TV_TREE_LOOP_IVCANON, TV_COMPLETE_UNROLL): New timevars.
* tree-cfg.c (tree_find_edge_insert_loc): Return newly created block.
(bsi_commit_edge_inserts_1): Pass null to tree_find_edge_insert_loc.
(bsi_insert_on_edge_immediate): New function.
* tree-flow.h (bsi_insert_on_edge_immediate,
canonicalize_induction_variables, tree_unroll_loops_completely,
create_iv): Declare.
* tree-optimize.c (init_tree_optimization_passes): Add
pass_iv_canon and pass_complete_unroll.
* tree-pass.h (pass_iv_canon, pass_complete_unroll): Declare.
* tree-scalar-evolution.c (get_loop_exit_condition,
get_exit_conditions_rec, number_of_iterations_in_loop,
scev_initialize): Use single_exit information.
* tree-ssa-loop-niter.c (number_of_iterations_cond): Record
missing assumptions.
(loop_niter_by_eval): Return number of iterations as unsigned
int.
* tree-ssa-loop.c (tree_ssa_loop_init): Mark single exit loops.
(tree_ssa_loop_ivcanon, gate_tree_ssa_loop_ivcanon, pass_iv_canon,
tree_complete_unroll, gate_tree_complete_unroll, pass_complete_unroll):
New passes.
(tree_ssa_loop_done): Call free_numbers_of_iterations_estimates.
* tree-ssanames.c (make_ssa_name): Allow creating ssa name before
the defining statement is ready.
* tree-vectorizer.c (vect_create_iv_simple): Removed.
(vect_create_index_for_array_ref, vect_transform_loop_bound):
Use create_iv.
(vect_transform_loop_bound): Use single_exit information.
(vect_analyze_loop_form): Cleanup bogus tests.
(vectorize_loops): Do not call flow_loop_scan.
* tree.h (may_negate_without_overflow_p): Declare.
* fold-const.c (may_negate_without_overflow_p): Split out from ...
(negate_expr_p): ... this function.
(tree_expr_nonzero_p): Handle overflowed constants correctly.
* doc/invoke.texi (-fivcanon): Document.
* doc/passes.texi: Document canonical induction variable creation.
* gcc.dg/tree-ssa/loop-1.c: New test.
From-SVN: r86516
2004-08-24 22:48:23 +02:00
|
|
|
|
if (loop->single_exit)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
{
|
|
|
|
|
tree loop_condition = get_loop_exit_condition (loop);
|
|
|
|
|
|
|
|
|
|
if (loop_condition)
|
2005-05-02 10:56:52 +02:00
|
|
|
|
VEC_safe_push (tree, heap, *exit_conditions, loop_condition);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Select the candidate loop nests for the analysis. This function
|
alias.c, [...]: Fix comment formatting.
* alias.c, basic-block.h, cgraphunit.c, combine.c, domwalk.h,
final.c, gengtype.c, genpreds.c, ggc-page.c, insn-notes.def,
lambda-code.c, loop-unroll.c, modulo-sched.c, pointer-set.c,
pretty-print.c, ra-colorize.c, sbitmap.c, tree-complex.c,
tree-data-ref.c, tree-dfa.c, tree-inline.c, tree-into-ssa.c,
tree-scalar-evolution.c, tree-ssa-dom.c,
tree-ssa-loop-manip.c, tree-ssa-loop-niter.c,
tree-ssa-phiopt.c, tree-ssa-pre.c, tree-ssa-threadupdate.c,
tree-vectorizer.c, vec.h: Fix comment formatting.
From-SVN: r89453
2004-10-22 19:05:11 +02:00
|
|
|
|
initializes the EXIT_CONDITIONS array. */
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
select_loops_exit_conditions (struct loops *loops,
|
2005-05-02 10:56:52 +02:00
|
|
|
|
VEC(tree,heap) **exit_conditions)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
{
|
|
|
|
|
struct loop *function_body = loops->parray[0];
|
|
|
|
|
|
|
|
|
|
get_exit_conditions_rec (function_body->inner, exit_conditions);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Depth first search algorithm. */
|
|
|
|
|
|
2005-09-26 20:44:16 +02:00
|
|
|
|
typedef enum t_bool {
|
|
|
|
|
t_false,
|
|
|
|
|
t_true,
|
|
|
|
|
t_dont_know
|
|
|
|
|
} t_bool;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static t_bool follow_ssa_edge (struct loop *loop, tree, tree, tree *, int);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
/* Follow the ssa edge into the right hand side RHS of an assignment.
|
|
|
|
|
Return true if the strongly connected component has been found. */
|
|
|
|
|
|
2005-09-26 20:44:16 +02:00
|
|
|
|
static t_bool
|
|
|
|
|
follow_ssa_edge_in_rhs (struct loop *loop, tree at_stmt, tree rhs,
|
|
|
|
|
tree halting_phi, tree *evolution_of_loop, int limit)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
{
|
2005-09-26 20:44:16 +02:00
|
|
|
|
t_bool res = t_false;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
tree rhs0, rhs1;
|
|
|
|
|
tree type_rhs = TREE_TYPE (rhs);
|
|
|
|
|
|
|
|
|
|
/* The RHS is one of the following cases:
|
|
|
|
|
- an SSA_NAME,
|
|
|
|
|
- an INTEGER_CST,
|
|
|
|
|
- a PLUS_EXPR,
|
|
|
|
|
- a MINUS_EXPR,
|
backport: copy-prop, incremental SSA updating of FUD chains and newly exposed symbols.
Merge from tree-cleanup-branch: VRP, store CCP, store
copy-prop, incremental SSA updating of FUD chains and
newly exposed symbols.
* Makefile.in (tree-ssa-copy.o): Depend on tree-ssa-propagate.h.
(OBJS-common): Add tree-vrp.o.
(tree-vrp.o): New rule.
* basic-block.h (nearest_common_dominator_for_set): Declare.
* common.opt (ftree-store-ccp): New flag.
(ftree-copy-prop): New flag.
(ftree-vrp): New flag.
(ftree-store-copy-prop): New flag.
* dominance.c (nearest_common_dominator_for_set): New.
* domwalk.c (walk_dominator_tree): Only traverse
statements in blocks marked in walk_data->interesting_blocks.
* domwalk.h (struct dom_walk_data): Add field interesting_blocks.
* fold-const.c (fold): Handle ASSERT_EXPR.
* opts.c (decode_options): Set flag_tree_copy_prop at -O1.
Set flag_tree_store_ccp, flag_tree_store_copy_prop and
flag_tree_vrp at -O2.
* timevar.def (TV_TREE_VRP): Define.
(TV_TREE_COPY_PROP): Define.
(TV_TREE_STORE_COPY_PROP): Define.
(TV_TREE_SSA_INCREMENTAL): Define.
(TV_TREE_STORE_CCP): Define.
* tree-cfg.c (tree_can_merge_blocks_p): Remove reference
to kill_redundant_phi_nodes from comment.
(verify_expr): Handle ASSERT_EXPR.
* tree-dfa.c (mark_new_vars_to_rename): Remove second
argument. Update all users.
(mark_call_clobbered_vars_to_rename): Remove. Update all
users.
* tree-flow-inline.h (unmodifiable_var_p): New.
* tree-flow.h (enum value_range_type): Declare.
(struct value_range_def): Declare.
(value_range): Declare.
(remove_all_phi_nodes_for): Remove. Update all users.
(find_phi_node_for): Declare.
(add_type_alias): Declare.
(count_uses_and_derefs): Declare.
(kill_redundant_phi_nodes): Remove.
(rewrite_into_ssa): Remove.
(rewrite_def_def_chains): Remove.
(update_ssa, register_new_name_mapping, create_new_def_for,
need_ssa_update_p, name_registered_for_update_p,
release_ssa_name_after_update_ssa, dump_repl_tbl,
debug_repl_tbl, dump_names_replaced_by,
debug_names_replaced_by, mark_sym_for_renaming,
mark_set_for_renaming, get_current_def, set_current_def,
get_value_range, dump_value_range, debug_value_range,
dump_all_value_ranges, debug_all_value_ranges,
expr_computes_nonzero, loop_depth_of_name,
unmodifiable_var_p): Declare.
* tree-gimple.c (is_gimple_formal_tmp_rhs): Handle
ASSERT_EXPR.
* tree-into-ssa.c (block_defs_stack): Update comment.
(old_ssa_names, new_ssa_names, old_virtual_ssa_names,
syms_to_rename, names_to_release, repl_tbl,
need_to_initialize_update_ssa_p, need_to_update_vops_p,
need_to_replace_names_p): New locals.
(NAME_SETS_GROWTH_FACTOR): Define.
(struct repl_map_d): Declare.
(struct mark_def_sites_global_data): Add field
interesting_blocks.
(enum rewrite_mode): Declare.
(REGISTER_DEFS_IN_THIS_STMT): Define.
(compute_global_livein): Use last_basic_block instead of
n_basic_blocks.
(set_def_block): Remove last argument. Update all callers.
(prepare_use_operand_for_rename): Remove. Update all callers.
(prepare_def_operand_for_rename): Remove. Update all callers.
(symbol_marked_for_renaming): New.
(is_old_name): New.
(is_new_name): New.
(repl_map_hash): New.
(repl_map_eq): New.
(repl_map_free): New.
(names_replaced_by): New.
(add_to_repl_tbl): New.
(add_new_name_mapping): New.
(mark_def_sites): Assume that all the operands in the
statement are in normal form.
(find_idf): Assert that the block in the stack is valid.
(get_default_def_for): New.
(insert_phi_nodes_for): Add new argument 'update_p'.
Add documentation.
If update_p is true, add a new mapping between the LHS of
each new PHI and the name that it replaces.
(insert_phi_nodes_1): Only call find_idf if needed.
(get_reaching_def): Call get_default_def_for.
(rewrite_operand): Remove.
(rewrite_stmt): Do nothing if REGISTER_DEFS_IN_THIS_STMT
and REWRITE_THIS_STMT are false.
Assume that all the operands in the statement are in
normal form.
(rewrite_add_phi_arguments): Don't use PHI_REWRITTEN.
(rewrite_virtual_phi_arguments): Remove.
(invalidate_name_tags): Remove.
(register_new_update_single, register_new_update_set,
rewrite_update_init_block, replace_use,
rewrite_update_fini_block, rewrite_update_stmt,
rewrite_update_phi_arguments): New.
rewrite_blocks): Remove argument 'fix_virtual_phis'.
Add arguments 'entry', 'what' and 'blocks'.
Initialize the dominator walker according to 'what' and
'blocks'.
Start the dominator walk at 'entry'.
(mark_def_site_blocks): Add argument 'interesting_blocks'.
Use it to configure the dominator walker.
(rewrite_into_ssa): Remove argument 'all'.
Make internal.
(rewrite_all_into_ssa): Remove.
(rewrite_def_def_chains): Remove.
(mark_def_interesting, mark_use_interesting,
prepare_phi_args_for_update, prepare_block_for_update,
prepare_def_site_for, prepare_def_sites,
dump_names_replaced_by, debug_names_replaced_by,
dump_repl_tbl, debug_repl_tbl, init_update_ssa,
delete_update_ssa, create_new_def_for,
register_new_name_mapping, mark_sym_for_renaming,
mark_set_for_renaming, need_ssa_update_p,
name_registered_for_update_p, ssa_names_to_replace,
release_ssa_name_after_update_ssa,
insert_updated_phi_nodes_for, update_ssa): New.
* tree-loop-linear.c (linear_transform_loops): Call
update_ssa instead of rewrite_into_ssa.
* tree-optimize.c (vars_to_rename): Remove.
Update all users.
(init_tree_optimization_passes): Replace
pass_redundant_phi with pass_copy_prop.
Add pass_vrp.
Replace pass_ccp with pass_store_ccp.
Add pass_store_copy_prop after pass_store_ccp.
(execute_todo): If the TODO_ flags don't include updating
the SSA form, assert that it does not need to be updated.
Call update_ssa instead of rewrite_into_ssa and
rewrite_def_def_chains.
If TODO_verify_loops is set, call verify_loop_closed_ssa.
(tree_rest_of_compilation):
* tree-pass.h (TODO_dump_func, TODO_ggc_collect,
TODO_verify_ssa, TODO_verify_flow, TODO_verify_stmts,
TODO_cleanup_cfg): Renumber.
(TODO_verify_loops, TODO_update_ssa,
TODO_update_ssa_no_phi, TODO_update_ssa_full_phi,
TODO_update_ssa_only_virtuals): Define.
(pass_copy_prop, pass_store_ccp, pass_store_copy_prop, pass_vrp):
Declare.
* tree-phinodes.c (make_phi_node): Update documentation.
(remove_all_phi_nodes_for): Remove.
(find_phi_node_for): New.
* tree-pretty-print.c (dump_generic_node): Handle ASSERT_EXPR.
* tree-scalar-evolution.c (follow_ssa_edge_in_rhs): Likewise.
(interpret_rhs_modify_expr): Likewise.
* tree-sra.c (decide_instantiations): Mark all symbols in
SRA_CANDIDATES for renaming.
(mark_all_v_defs_1): Rename from mark_all_v_defs.
(mark_all_v_defs): New function. Update all users to call it
with the whole list of scalarized statements, not just the
first one.
* tree-ssa-alias.c (count_ptr_derefs): Make extern.
(compute_flow_insensitive_aliasing): If the tag is
unmodifiable and the variable isn't or vice-versa, don't
make them alias of each other.
(setup_pointers_and_addressables): If the type tag for
VAR is about to change, mark the old one for renaming.
(add_type_alias): New.
* tree-ssa-ccp.c: Document SSA-CCP and STORE-CCP.
(ccp_lattice_t): Rename from latticevalue.
(value): Remove. Update all users.
(const_val): New local variable.
(do_store_ccp): New local variable.
(dump_lattice_value): Handle UNINITIALIZED.
(debug_lattice_value): New.
(get_default_value): Re-write.
(set_lattice_value): Re-write.
(def_to_varying): Remove. Update all users.
(likely_value): Return VARYING for statements that make
stores when STORE_CCP is false.
Return VARYING for any statement other than MODIFY_EXPR,
COND_EXPR and SWITCH_EXPR.
(ccp_initialize): Re-write.
(replace_uses_in, replace_vuse_in, substitute_and_fold):
Move to tree-ssa-propagate.c.
(ccp_lattice_meet): Handle memory stores when
DO_STORE_CCP is true.
(ccp_visit_phi_node): Likewise.
(ccp_fold): Likewise.
(evaluate_stmt): Likewise.
(visit_assignment): Likewise.
(ccp_visit_stmt): Likewise.
(execute_ssa_ccp): Add argument 'store_ccp'. Copy it
into DO_STORE_CCP.
(do_ssa_ccp): New.
(pass_ccp): Use it.
(do_ssa_store_ccp): New.
(gate_store_ccp): New.
(pass_store_ccp): Declare.
* tree-ssa-copy.c: Include tree-ssa-propagate.h.
(may_propagate_copy): Reformat.
Don't abort if ORIG is a virtual and DEST isn't.
If NEW does not have alias information but DEST does,
copy it.
(copy_of, cached_last_copy_of, do_store_copy_prop, enum
copy_prop_kind, which_copy_prop): Declare.
(stmt_may_generate_copy, get_copy_of_val,
get_last_copy_of, set_copy_of_val, dump_copy_of,
copy_prop_visit_assignment, copy_prop_visit_cond_stmt,
copy_prop_visit_stmt, copy_prop_visit_phi_node,
init_copy_prop, fini_copy_prop, execute_copy_prop,
gate_copy_prop, do_copy_prop, gate_store_copy_prop,
store_copy_prop): New.
(pass_copy_prop, pass_store_copy_prop): Declare.
* tree-ssa-dom.c (struct opt_stats_d): Add fields
'num_const_prop' and 'num_copy_prop'.
(cprop_operand): Update them.
(dump_dominator_optimization_stats): Dump them.
(tree_ssa_dominator_optimize): Call update_ssa instead of
rewrite_into_ssa.
(loop_depth_of_name): Declare extern.
(simplify_cond_and_lookup_avail_expr): Guard against NULL
values for LOW or HIGH.
(cprop_into_successor_phis): Only propagate if NEW != ORIG.
(record_equivalences_from_stmt): Call expr_computes_nonzero.
(cprop_operand): Only propagate if VAL != OP.
* tree-ssa-dse.c (dse_optimize_stmt): Mark symbols in removed
statement for renaming.
* tree-ssa-loop-im.c (move_computations): Call update_ssa.
* tree-ssa-loop-ivopts.c (rewrite_address_base): Call
add_type_alias if necessary.
Call mark_new_vars_to_rename.
(tree_ssa_iv_optimize): If new symbols need to be renamed,
mark every statement updated, call update_ssa and
rewrite_into_loop_closed_ssa.
* tree-ssa-loop-manip.c (add_exit_phis): Do not remove DEF_BB
from LIVEIN if VAR is a virtual.
* tree-ssa-loop.c (tree_loop_optimizer_init): Call update_ssa.
* tree-ssa-operands.c (get_expr_operands): Handle ASSERT_EXPR.
(get_call_expr_operands): Reformat statement.
(add_stmt_operand): Don't create V_MAY_DEFs for read-only
symbols.
* tree-ssa-propagate.c (ssa_prop_init): Initialize
SSA_NAME_VALUE for every name.
(first_vdef, stmt_makes_single_load, stmt_makes_single_store,
get_value_loaded_by): New.
(replace_uses_in, replace_vuses_in, replace_phi_args_in,
substitute_and_fold): Move from tree-ssa-ccp.c.
* tree-ssa-propagate.h (struct prop_value_d, prop_value_t,
first_vdef, stmt_makes_single_load, stmt_makes_single_store,
get_value_loaded_by, replace_uses_in, substitute_and_fold):
Declare.
* tree-ssa.c (verify_use): Fix error message.
(propagate_into_addr, replace_immediate_uses, get_eq_name,
check_phi_redundancy, kill_redundant_phi_nodes,
pass_redundant_phi): Remove. Update all users.
* tree-vect-transform.c (vect_create_data_ref_ptr): Call
add_type_alias, if necessary.
* tree-vectorizer.h (struct _stmt_vect_info): Update
documentation for field 'memtag'.
* tree-vrp.c: New file.
* tree.def (ASSERT_EXPR): Define.
* tree.h (ASSERT_EXPR_VAR): Define.
(ASSERT_EXPR_COND): Define.
(SSA_NAME_VALUE_RANGE): Define.
(struct tree_ssa_name): Add field 'value_range'.
(PHI_REWRITTEN): Remove.
(struct tree_phi_node): Remove field 'rewritten'.
* doc/invoke.texi (-fdump-tree-storeccp, -ftree-copy-prop,
-ftree-store-copy-prop): Document.
* doc/tree-ssa.texi: Remove broken link to McCAT's compiler.
Document usage of update_ssa.
testsuite/ChangeLog
* g++.dg/tree-ssa/pr18178.C: New test.
* gcc.c-torture/execute/20030216-1.x: Ignore at -O1.
* gcc.c-torture/execute/20041019-1.c: New test.
* gcc.dg/tree-ssa/20041008-1.c: New test.
* gcc.dg/tree-ssa/ssa-ccp-12.c: New test.
* gcc.dg/tree-ssa/20030731-2.c: Update to use -fdump-tree-store_ccp.
* gcc.dg/tree-ssa/20030917-1.c: Likewise.
* gcc.dg/tree-ssa/20030917-3.c: Likewise.
* gcc.dg/tree-ssa/20040721-1.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-1.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-2.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-3.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-7.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-9.c: Likewise.
From-SVN: r97884
2005-04-09 03:37:54 +02:00
|
|
|
|
- an ASSERT_EXPR,
|
|
|
|
|
- other cases are not yet handled. */
|
2004-07-12 21:31:16 +02:00
|
|
|
|
switch (TREE_CODE (rhs))
|
|
|
|
|
{
|
|
|
|
|
case NOP_EXPR:
|
|
|
|
|
/* This assignment is under the form "a_1 = (cast) rhs. */
|
2005-06-07 21:51:25 +02:00
|
|
|
|
res = follow_ssa_edge_in_rhs (loop, at_stmt, TREE_OPERAND (rhs, 0),
|
2005-09-26 20:44:16 +02:00
|
|
|
|
halting_phi, evolution_of_loop, limit);
|
2005-06-07 21:51:25 +02:00
|
|
|
|
*evolution_of_loop = chrec_convert (TREE_TYPE (rhs),
|
|
|
|
|
*evolution_of_loop, at_stmt);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case INTEGER_CST:
|
|
|
|
|
/* This assignment is under the form "a_1 = 7". */
|
2005-09-26 20:44:16 +02:00
|
|
|
|
res = t_false;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SSA_NAME:
|
|
|
|
|
/* This assignment is under the form: "a_1 = b_2". */
|
|
|
|
|
res = follow_ssa_edge
|
2005-09-26 20:44:16 +02:00
|
|
|
|
(loop, SSA_NAME_DEF_STMT (rhs), halting_phi, evolution_of_loop, limit);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PLUS_EXPR:
|
|
|
|
|
/* This case is under the form "rhs0 + rhs1". */
|
|
|
|
|
rhs0 = TREE_OPERAND (rhs, 0);
|
|
|
|
|
rhs1 = TREE_OPERAND (rhs, 1);
|
|
|
|
|
STRIP_TYPE_NOPS (rhs0);
|
|
|
|
|
STRIP_TYPE_NOPS (rhs1);
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (rhs0) == SSA_NAME)
|
|
|
|
|
{
|
|
|
|
|
if (TREE_CODE (rhs1) == SSA_NAME)
|
|
|
|
|
{
|
|
|
|
|
/* Match an assignment under the form:
|
|
|
|
|
"a = b + c". */
|
|
|
|
|
res = follow_ssa_edge
|
|
|
|
|
(loop, SSA_NAME_DEF_STMT (rhs0), halting_phi,
|
2005-09-26 20:44:16 +02:00
|
|
|
|
evolution_of_loop, limit);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
2005-09-26 20:44:16 +02:00
|
|
|
|
if (res == t_true)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
*evolution_of_loop = add_to_evolution
|
|
|
|
|
(loop->num,
|
2005-06-07 21:51:25 +02:00
|
|
|
|
chrec_convert (type_rhs, *evolution_of_loop, at_stmt),
|
2004-07-12 21:31:16 +02:00
|
|
|
|
PLUS_EXPR, rhs1);
|
|
|
|
|
|
2005-09-26 20:44:16 +02:00
|
|
|
|
else if (res == t_false)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
{
|
|
|
|
|
res = follow_ssa_edge
|
|
|
|
|
(loop, SSA_NAME_DEF_STMT (rhs1), halting_phi,
|
2005-09-26 20:44:16 +02:00
|
|
|
|
evolution_of_loop, limit);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
2005-09-26 20:44:16 +02:00
|
|
|
|
if (res == t_true)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
*evolution_of_loop = add_to_evolution
|
|
|
|
|
(loop->num,
|
2005-06-07 21:51:25 +02:00
|
|
|
|
chrec_convert (type_rhs, *evolution_of_loop, at_stmt),
|
2004-07-12 21:31:16 +02:00
|
|
|
|
PLUS_EXPR, rhs0);
|
2005-09-26 20:44:16 +02:00
|
|
|
|
|
|
|
|
|
else if (res == t_dont_know)
|
|
|
|
|
*evolution_of_loop = chrec_dont_know;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
}
|
2005-09-26 20:44:16 +02:00
|
|
|
|
|
|
|
|
|
else if (res == t_dont_know)
|
|
|
|
|
*evolution_of_loop = chrec_dont_know;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Match an assignment under the form:
|
|
|
|
|
"a = b + ...". */
|
|
|
|
|
res = follow_ssa_edge
|
|
|
|
|
(loop, SSA_NAME_DEF_STMT (rhs0), halting_phi,
|
2005-09-26 20:44:16 +02:00
|
|
|
|
evolution_of_loop, limit);
|
|
|
|
|
if (res == t_true)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
*evolution_of_loop = add_to_evolution
|
2005-06-07 21:51:25 +02:00
|
|
|
|
(loop->num, chrec_convert (type_rhs, *evolution_of_loop,
|
|
|
|
|
at_stmt),
|
2004-07-12 21:31:16 +02:00
|
|
|
|
PLUS_EXPR, rhs1);
|
2005-09-26 20:44:16 +02:00
|
|
|
|
|
|
|
|
|
else if (res == t_dont_know)
|
|
|
|
|
*evolution_of_loop = chrec_dont_know;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (TREE_CODE (rhs1) == SSA_NAME)
|
|
|
|
|
{
|
|
|
|
|
/* Match an assignment under the form:
|
|
|
|
|
"a = ... + c". */
|
|
|
|
|
res = follow_ssa_edge
|
|
|
|
|
(loop, SSA_NAME_DEF_STMT (rhs1), halting_phi,
|
2005-09-26 20:44:16 +02:00
|
|
|
|
evolution_of_loop, limit);
|
|
|
|
|
if (res == t_true)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
*evolution_of_loop = add_to_evolution
|
2005-06-07 21:51:25 +02:00
|
|
|
|
(loop->num, chrec_convert (type_rhs, *evolution_of_loop,
|
|
|
|
|
at_stmt),
|
2004-07-12 21:31:16 +02:00
|
|
|
|
PLUS_EXPR, rhs0);
|
2005-09-26 20:44:16 +02:00
|
|
|
|
|
|
|
|
|
else if (res == t_dont_know)
|
|
|
|
|
*evolution_of_loop = chrec_dont_know;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
/* Otherwise, match an assignment under the form:
|
|
|
|
|
"a = ... + ...". */
|
|
|
|
|
/* And there is nothing to do. */
|
2005-09-26 20:44:16 +02:00
|
|
|
|
res = t_false;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case MINUS_EXPR:
|
|
|
|
|
/* This case is under the form "opnd0 = rhs0 - rhs1". */
|
|
|
|
|
rhs0 = TREE_OPERAND (rhs, 0);
|
|
|
|
|
rhs1 = TREE_OPERAND (rhs, 1);
|
|
|
|
|
STRIP_TYPE_NOPS (rhs0);
|
|
|
|
|
STRIP_TYPE_NOPS (rhs1);
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (rhs0) == SSA_NAME)
|
|
|
|
|
{
|
|
|
|
|
/* Match an assignment under the form:
|
2004-11-11 21:12:34 +01:00
|
|
|
|
"a = b - ...". */
|
|
|
|
|
res = follow_ssa_edge (loop, SSA_NAME_DEF_STMT (rhs0), halting_phi,
|
2005-09-26 20:44:16 +02:00
|
|
|
|
evolution_of_loop, limit);
|
|
|
|
|
if (res == t_true)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
*evolution_of_loop = add_to_evolution
|
2005-09-26 20:44:16 +02:00
|
|
|
|
(loop->num, chrec_convert (type_rhs, *evolution_of_loop, at_stmt),
|
|
|
|
|
MINUS_EXPR, rhs1);
|
|
|
|
|
|
|
|
|
|
else if (res == t_dont_know)
|
|
|
|
|
*evolution_of_loop = chrec_dont_know;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
/* Otherwise, match an assignment under the form:
|
|
|
|
|
"a = ... - ...". */
|
|
|
|
|
/* And there is nothing to do. */
|
2005-09-26 20:44:16 +02:00
|
|
|
|
res = t_false;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case MULT_EXPR:
|
|
|
|
|
/* This case is under the form "opnd0 = rhs0 * rhs1". */
|
|
|
|
|
rhs0 = TREE_OPERAND (rhs, 0);
|
|
|
|
|
rhs1 = TREE_OPERAND (rhs, 1);
|
|
|
|
|
STRIP_TYPE_NOPS (rhs0);
|
|
|
|
|
STRIP_TYPE_NOPS (rhs1);
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (rhs0) == SSA_NAME)
|
|
|
|
|
{
|
|
|
|
|
if (TREE_CODE (rhs1) == SSA_NAME)
|
|
|
|
|
{
|
|
|
|
|
/* Match an assignment under the form:
|
|
|
|
|
"a = b * c". */
|
|
|
|
|
res = follow_ssa_edge
|
|
|
|
|
(loop, SSA_NAME_DEF_STMT (rhs0), halting_phi,
|
2005-09-26 20:44:16 +02:00
|
|
|
|
evolution_of_loop, limit);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
2005-09-26 20:44:16 +02:00
|
|
|
|
if (res == t_true || res == t_dont_know)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
*evolution_of_loop = chrec_dont_know;
|
|
|
|
|
|
2005-09-26 20:44:16 +02:00
|
|
|
|
else if (res == t_false)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
{
|
|
|
|
|
res = follow_ssa_edge
|
|
|
|
|
(loop, SSA_NAME_DEF_STMT (rhs1), halting_phi,
|
2005-09-26 20:44:16 +02:00
|
|
|
|
evolution_of_loop, limit);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
2005-09-26 20:44:16 +02:00
|
|
|
|
if (res == t_true || res == t_dont_know)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
*evolution_of_loop = chrec_dont_know;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Match an assignment under the form:
|
|
|
|
|
"a = b * ...". */
|
|
|
|
|
res = follow_ssa_edge
|
|
|
|
|
(loop, SSA_NAME_DEF_STMT (rhs0), halting_phi,
|
2005-09-26 20:44:16 +02:00
|
|
|
|
evolution_of_loop, limit);
|
|
|
|
|
if (res == t_true || res == t_dont_know)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
*evolution_of_loop = chrec_dont_know;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (TREE_CODE (rhs1) == SSA_NAME)
|
|
|
|
|
{
|
|
|
|
|
/* Match an assignment under the form:
|
|
|
|
|
"a = ... * c". */
|
|
|
|
|
res = follow_ssa_edge
|
|
|
|
|
(loop, SSA_NAME_DEF_STMT (rhs1), halting_phi,
|
2005-09-26 20:44:16 +02:00
|
|
|
|
evolution_of_loop, limit);
|
|
|
|
|
if (res == t_true || res == t_dont_know)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
*evolution_of_loop = chrec_dont_know;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
/* Otherwise, match an assignment under the form:
|
|
|
|
|
"a = ... * ...". */
|
|
|
|
|
/* And there is nothing to do. */
|
2005-09-26 20:44:16 +02:00
|
|
|
|
res = t_false;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
backport: copy-prop, incremental SSA updating of FUD chains and newly exposed symbols.
Merge from tree-cleanup-branch: VRP, store CCP, store
copy-prop, incremental SSA updating of FUD chains and
newly exposed symbols.
* Makefile.in (tree-ssa-copy.o): Depend on tree-ssa-propagate.h.
(OBJS-common): Add tree-vrp.o.
(tree-vrp.o): New rule.
* basic-block.h (nearest_common_dominator_for_set): Declare.
* common.opt (ftree-store-ccp): New flag.
(ftree-copy-prop): New flag.
(ftree-vrp): New flag.
(ftree-store-copy-prop): New flag.
* dominance.c (nearest_common_dominator_for_set): New.
* domwalk.c (walk_dominator_tree): Only traverse
statements in blocks marked in walk_data->interesting_blocks.
* domwalk.h (struct dom_walk_data): Add field interesting_blocks.
* fold-const.c (fold): Handle ASSERT_EXPR.
* opts.c (decode_options): Set flag_tree_copy_prop at -O1.
Set flag_tree_store_ccp, flag_tree_store_copy_prop and
flag_tree_vrp at -O2.
* timevar.def (TV_TREE_VRP): Define.
(TV_TREE_COPY_PROP): Define.
(TV_TREE_STORE_COPY_PROP): Define.
(TV_TREE_SSA_INCREMENTAL): Define.
(TV_TREE_STORE_CCP): Define.
* tree-cfg.c (tree_can_merge_blocks_p): Remove reference
to kill_redundant_phi_nodes from comment.
(verify_expr): Handle ASSERT_EXPR.
* tree-dfa.c (mark_new_vars_to_rename): Remove second
argument. Update all users.
(mark_call_clobbered_vars_to_rename): Remove. Update all
users.
* tree-flow-inline.h (unmodifiable_var_p): New.
* tree-flow.h (enum value_range_type): Declare.
(struct value_range_def): Declare.
(value_range): Declare.
(remove_all_phi_nodes_for): Remove. Update all users.
(find_phi_node_for): Declare.
(add_type_alias): Declare.
(count_uses_and_derefs): Declare.
(kill_redundant_phi_nodes): Remove.
(rewrite_into_ssa): Remove.
(rewrite_def_def_chains): Remove.
(update_ssa, register_new_name_mapping, create_new_def_for,
need_ssa_update_p, name_registered_for_update_p,
release_ssa_name_after_update_ssa, dump_repl_tbl,
debug_repl_tbl, dump_names_replaced_by,
debug_names_replaced_by, mark_sym_for_renaming,
mark_set_for_renaming, get_current_def, set_current_def,
get_value_range, dump_value_range, debug_value_range,
dump_all_value_ranges, debug_all_value_ranges,
expr_computes_nonzero, loop_depth_of_name,
unmodifiable_var_p): Declare.
* tree-gimple.c (is_gimple_formal_tmp_rhs): Handle
ASSERT_EXPR.
* tree-into-ssa.c (block_defs_stack): Update comment.
(old_ssa_names, new_ssa_names, old_virtual_ssa_names,
syms_to_rename, names_to_release, repl_tbl,
need_to_initialize_update_ssa_p, need_to_update_vops_p,
need_to_replace_names_p): New locals.
(NAME_SETS_GROWTH_FACTOR): Define.
(struct repl_map_d): Declare.
(struct mark_def_sites_global_data): Add field
interesting_blocks.
(enum rewrite_mode): Declare.
(REGISTER_DEFS_IN_THIS_STMT): Define.
(compute_global_livein): Use last_basic_block instead of
n_basic_blocks.
(set_def_block): Remove last argument. Update all callers.
(prepare_use_operand_for_rename): Remove. Update all callers.
(prepare_def_operand_for_rename): Remove. Update all callers.
(symbol_marked_for_renaming): New.
(is_old_name): New.
(is_new_name): New.
(repl_map_hash): New.
(repl_map_eq): New.
(repl_map_free): New.
(names_replaced_by): New.
(add_to_repl_tbl): New.
(add_new_name_mapping): New.
(mark_def_sites): Assume that all the operands in the
statement are in normal form.
(find_idf): Assert that the block in the stack is valid.
(get_default_def_for): New.
(insert_phi_nodes_for): Add new argument 'update_p'.
Add documentation.
If update_p is true, add a new mapping between the LHS of
each new PHI and the name that it replaces.
(insert_phi_nodes_1): Only call find_idf if needed.
(get_reaching_def): Call get_default_def_for.
(rewrite_operand): Remove.
(rewrite_stmt): Do nothing if REGISTER_DEFS_IN_THIS_STMT
and REWRITE_THIS_STMT are false.
Assume that all the operands in the statement are in
normal form.
(rewrite_add_phi_arguments): Don't use PHI_REWRITTEN.
(rewrite_virtual_phi_arguments): Remove.
(invalidate_name_tags): Remove.
(register_new_update_single, register_new_update_set,
rewrite_update_init_block, replace_use,
rewrite_update_fini_block, rewrite_update_stmt,
rewrite_update_phi_arguments): New.
rewrite_blocks): Remove argument 'fix_virtual_phis'.
Add arguments 'entry', 'what' and 'blocks'.
Initialize the dominator walker according to 'what' and
'blocks'.
Start the dominator walk at 'entry'.
(mark_def_site_blocks): Add argument 'interesting_blocks'.
Use it to configure the dominator walker.
(rewrite_into_ssa): Remove argument 'all'.
Make internal.
(rewrite_all_into_ssa): Remove.
(rewrite_def_def_chains): Remove.
(mark_def_interesting, mark_use_interesting,
prepare_phi_args_for_update, prepare_block_for_update,
prepare_def_site_for, prepare_def_sites,
dump_names_replaced_by, debug_names_replaced_by,
dump_repl_tbl, debug_repl_tbl, init_update_ssa,
delete_update_ssa, create_new_def_for,
register_new_name_mapping, mark_sym_for_renaming,
mark_set_for_renaming, need_ssa_update_p,
name_registered_for_update_p, ssa_names_to_replace,
release_ssa_name_after_update_ssa,
insert_updated_phi_nodes_for, update_ssa): New.
* tree-loop-linear.c (linear_transform_loops): Call
update_ssa instead of rewrite_into_ssa.
* tree-optimize.c (vars_to_rename): Remove.
Update all users.
(init_tree_optimization_passes): Replace
pass_redundant_phi with pass_copy_prop.
Add pass_vrp.
Replace pass_ccp with pass_store_ccp.
Add pass_store_copy_prop after pass_store_ccp.
(execute_todo): If the TODO_ flags don't include updating
the SSA form, assert that it does not need to be updated.
Call update_ssa instead of rewrite_into_ssa and
rewrite_def_def_chains.
If TODO_verify_loops is set, call verify_loop_closed_ssa.
(tree_rest_of_compilation):
* tree-pass.h (TODO_dump_func, TODO_ggc_collect,
TODO_verify_ssa, TODO_verify_flow, TODO_verify_stmts,
TODO_cleanup_cfg): Renumber.
(TODO_verify_loops, TODO_update_ssa,
TODO_update_ssa_no_phi, TODO_update_ssa_full_phi,
TODO_update_ssa_only_virtuals): Define.
(pass_copy_prop, pass_store_ccp, pass_store_copy_prop, pass_vrp):
Declare.
* tree-phinodes.c (make_phi_node): Update documentation.
(remove_all_phi_nodes_for): Remove.
(find_phi_node_for): New.
* tree-pretty-print.c (dump_generic_node): Handle ASSERT_EXPR.
* tree-scalar-evolution.c (follow_ssa_edge_in_rhs): Likewise.
(interpret_rhs_modify_expr): Likewise.
* tree-sra.c (decide_instantiations): Mark all symbols in
SRA_CANDIDATES for renaming.
(mark_all_v_defs_1): Rename from mark_all_v_defs.
(mark_all_v_defs): New function. Update all users to call it
with the whole list of scalarized statements, not just the
first one.
* tree-ssa-alias.c (count_ptr_derefs): Make extern.
(compute_flow_insensitive_aliasing): If the tag is
unmodifiable and the variable isn't or vice-versa, don't
make them alias of each other.
(setup_pointers_and_addressables): If the type tag for
VAR is about to change, mark the old one for renaming.
(add_type_alias): New.
* tree-ssa-ccp.c: Document SSA-CCP and STORE-CCP.
(ccp_lattice_t): Rename from latticevalue.
(value): Remove. Update all users.
(const_val): New local variable.
(do_store_ccp): New local variable.
(dump_lattice_value): Handle UNINITIALIZED.
(debug_lattice_value): New.
(get_default_value): Re-write.
(set_lattice_value): Re-write.
(def_to_varying): Remove. Update all users.
(likely_value): Return VARYING for statements that make
stores when STORE_CCP is false.
Return VARYING for any statement other than MODIFY_EXPR,
COND_EXPR and SWITCH_EXPR.
(ccp_initialize): Re-write.
(replace_uses_in, replace_vuse_in, substitute_and_fold):
Move to tree-ssa-propagate.c.
(ccp_lattice_meet): Handle memory stores when
DO_STORE_CCP is true.
(ccp_visit_phi_node): Likewise.
(ccp_fold): Likewise.
(evaluate_stmt): Likewise.
(visit_assignment): Likewise.
(ccp_visit_stmt): Likewise.
(execute_ssa_ccp): Add argument 'store_ccp'. Copy it
into DO_STORE_CCP.
(do_ssa_ccp): New.
(pass_ccp): Use it.
(do_ssa_store_ccp): New.
(gate_store_ccp): New.
(pass_store_ccp): Declare.
* tree-ssa-copy.c: Include tree-ssa-propagate.h.
(may_propagate_copy): Reformat.
Don't abort if ORIG is a virtual and DEST isn't.
If NEW does not have alias information but DEST does,
copy it.
(copy_of, cached_last_copy_of, do_store_copy_prop, enum
copy_prop_kind, which_copy_prop): Declare.
(stmt_may_generate_copy, get_copy_of_val,
get_last_copy_of, set_copy_of_val, dump_copy_of,
copy_prop_visit_assignment, copy_prop_visit_cond_stmt,
copy_prop_visit_stmt, copy_prop_visit_phi_node,
init_copy_prop, fini_copy_prop, execute_copy_prop,
gate_copy_prop, do_copy_prop, gate_store_copy_prop,
store_copy_prop): New.
(pass_copy_prop, pass_store_copy_prop): Declare.
* tree-ssa-dom.c (struct opt_stats_d): Add fields
'num_const_prop' and 'num_copy_prop'.
(cprop_operand): Update them.
(dump_dominator_optimization_stats): Dump them.
(tree_ssa_dominator_optimize): Call update_ssa instead of
rewrite_into_ssa.
(loop_depth_of_name): Declare extern.
(simplify_cond_and_lookup_avail_expr): Guard against NULL
values for LOW or HIGH.
(cprop_into_successor_phis): Only propagate if NEW != ORIG.
(record_equivalences_from_stmt): Call expr_computes_nonzero.
(cprop_operand): Only propagate if VAL != OP.
* tree-ssa-dse.c (dse_optimize_stmt): Mark symbols in removed
statement for renaming.
* tree-ssa-loop-im.c (move_computations): Call update_ssa.
* tree-ssa-loop-ivopts.c (rewrite_address_base): Call
add_type_alias if necessary.
Call mark_new_vars_to_rename.
(tree_ssa_iv_optimize): If new symbols need to be renamed,
mark every statement updated, call update_ssa and
rewrite_into_loop_closed_ssa.
* tree-ssa-loop-manip.c (add_exit_phis): Do not remove DEF_BB
from LIVEIN if VAR is a virtual.
* tree-ssa-loop.c (tree_loop_optimizer_init): Call update_ssa.
* tree-ssa-operands.c (get_expr_operands): Handle ASSERT_EXPR.
(get_call_expr_operands): Reformat statement.
(add_stmt_operand): Don't create V_MAY_DEFs for read-only
symbols.
* tree-ssa-propagate.c (ssa_prop_init): Initialize
SSA_NAME_VALUE for every name.
(first_vdef, stmt_makes_single_load, stmt_makes_single_store,
get_value_loaded_by): New.
(replace_uses_in, replace_vuses_in, replace_phi_args_in,
substitute_and_fold): Move from tree-ssa-ccp.c.
* tree-ssa-propagate.h (struct prop_value_d, prop_value_t,
first_vdef, stmt_makes_single_load, stmt_makes_single_store,
get_value_loaded_by, replace_uses_in, substitute_and_fold):
Declare.
* tree-ssa.c (verify_use): Fix error message.
(propagate_into_addr, replace_immediate_uses, get_eq_name,
check_phi_redundancy, kill_redundant_phi_nodes,
pass_redundant_phi): Remove. Update all users.
* tree-vect-transform.c (vect_create_data_ref_ptr): Call
add_type_alias, if necessary.
* tree-vectorizer.h (struct _stmt_vect_info): Update
documentation for field 'memtag'.
* tree-vrp.c: New file.
* tree.def (ASSERT_EXPR): Define.
* tree.h (ASSERT_EXPR_VAR): Define.
(ASSERT_EXPR_COND): Define.
(SSA_NAME_VALUE_RANGE): Define.
(struct tree_ssa_name): Add field 'value_range'.
(PHI_REWRITTEN): Remove.
(struct tree_phi_node): Remove field 'rewritten'.
* doc/invoke.texi (-fdump-tree-storeccp, -ftree-copy-prop,
-ftree-store-copy-prop): Document.
* doc/tree-ssa.texi: Remove broken link to McCAT's compiler.
Document usage of update_ssa.
testsuite/ChangeLog
* g++.dg/tree-ssa/pr18178.C: New test.
* gcc.c-torture/execute/20030216-1.x: Ignore at -O1.
* gcc.c-torture/execute/20041019-1.c: New test.
* gcc.dg/tree-ssa/20041008-1.c: New test.
* gcc.dg/tree-ssa/ssa-ccp-12.c: New test.
* gcc.dg/tree-ssa/20030731-2.c: Update to use -fdump-tree-store_ccp.
* gcc.dg/tree-ssa/20030917-1.c: Likewise.
* gcc.dg/tree-ssa/20030917-3.c: Likewise.
* gcc.dg/tree-ssa/20040721-1.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-1.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-2.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-3.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-7.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-9.c: Likewise.
From-SVN: r97884
2005-04-09 03:37:54 +02:00
|
|
|
|
case ASSERT_EXPR:
|
|
|
|
|
{
|
|
|
|
|
/* This assignment is of the form: "a_1 = ASSERT_EXPR <a_2, ...>"
|
|
|
|
|
It must be handled as a copy assignment of the form a_1 = a_2. */
|
|
|
|
|
tree op0 = ASSERT_EXPR_VAR (rhs);
|
|
|
|
|
if (TREE_CODE (op0) == SSA_NAME)
|
|
|
|
|
res = follow_ssa_edge (loop, SSA_NAME_DEF_STMT (op0),
|
2005-09-26 20:44:16 +02:00
|
|
|
|
halting_phi, evolution_of_loop, limit);
|
backport: copy-prop, incremental SSA updating of FUD chains and newly exposed symbols.
Merge from tree-cleanup-branch: VRP, store CCP, store
copy-prop, incremental SSA updating of FUD chains and
newly exposed symbols.
* Makefile.in (tree-ssa-copy.o): Depend on tree-ssa-propagate.h.
(OBJS-common): Add tree-vrp.o.
(tree-vrp.o): New rule.
* basic-block.h (nearest_common_dominator_for_set): Declare.
* common.opt (ftree-store-ccp): New flag.
(ftree-copy-prop): New flag.
(ftree-vrp): New flag.
(ftree-store-copy-prop): New flag.
* dominance.c (nearest_common_dominator_for_set): New.
* domwalk.c (walk_dominator_tree): Only traverse
statements in blocks marked in walk_data->interesting_blocks.
* domwalk.h (struct dom_walk_data): Add field interesting_blocks.
* fold-const.c (fold): Handle ASSERT_EXPR.
* opts.c (decode_options): Set flag_tree_copy_prop at -O1.
Set flag_tree_store_ccp, flag_tree_store_copy_prop and
flag_tree_vrp at -O2.
* timevar.def (TV_TREE_VRP): Define.
(TV_TREE_COPY_PROP): Define.
(TV_TREE_STORE_COPY_PROP): Define.
(TV_TREE_SSA_INCREMENTAL): Define.
(TV_TREE_STORE_CCP): Define.
* tree-cfg.c (tree_can_merge_blocks_p): Remove reference
to kill_redundant_phi_nodes from comment.
(verify_expr): Handle ASSERT_EXPR.
* tree-dfa.c (mark_new_vars_to_rename): Remove second
argument. Update all users.
(mark_call_clobbered_vars_to_rename): Remove. Update all
users.
* tree-flow-inline.h (unmodifiable_var_p): New.
* tree-flow.h (enum value_range_type): Declare.
(struct value_range_def): Declare.
(value_range): Declare.
(remove_all_phi_nodes_for): Remove. Update all users.
(find_phi_node_for): Declare.
(add_type_alias): Declare.
(count_uses_and_derefs): Declare.
(kill_redundant_phi_nodes): Remove.
(rewrite_into_ssa): Remove.
(rewrite_def_def_chains): Remove.
(update_ssa, register_new_name_mapping, create_new_def_for,
need_ssa_update_p, name_registered_for_update_p,
release_ssa_name_after_update_ssa, dump_repl_tbl,
debug_repl_tbl, dump_names_replaced_by,
debug_names_replaced_by, mark_sym_for_renaming,
mark_set_for_renaming, get_current_def, set_current_def,
get_value_range, dump_value_range, debug_value_range,
dump_all_value_ranges, debug_all_value_ranges,
expr_computes_nonzero, loop_depth_of_name,
unmodifiable_var_p): Declare.
* tree-gimple.c (is_gimple_formal_tmp_rhs): Handle
ASSERT_EXPR.
* tree-into-ssa.c (block_defs_stack): Update comment.
(old_ssa_names, new_ssa_names, old_virtual_ssa_names,
syms_to_rename, names_to_release, repl_tbl,
need_to_initialize_update_ssa_p, need_to_update_vops_p,
need_to_replace_names_p): New locals.
(NAME_SETS_GROWTH_FACTOR): Define.
(struct repl_map_d): Declare.
(struct mark_def_sites_global_data): Add field
interesting_blocks.
(enum rewrite_mode): Declare.
(REGISTER_DEFS_IN_THIS_STMT): Define.
(compute_global_livein): Use last_basic_block instead of
n_basic_blocks.
(set_def_block): Remove last argument. Update all callers.
(prepare_use_operand_for_rename): Remove. Update all callers.
(prepare_def_operand_for_rename): Remove. Update all callers.
(symbol_marked_for_renaming): New.
(is_old_name): New.
(is_new_name): New.
(repl_map_hash): New.
(repl_map_eq): New.
(repl_map_free): New.
(names_replaced_by): New.
(add_to_repl_tbl): New.
(add_new_name_mapping): New.
(mark_def_sites): Assume that all the operands in the
statement are in normal form.
(find_idf): Assert that the block in the stack is valid.
(get_default_def_for): New.
(insert_phi_nodes_for): Add new argument 'update_p'.
Add documentation.
If update_p is true, add a new mapping between the LHS of
each new PHI and the name that it replaces.
(insert_phi_nodes_1): Only call find_idf if needed.
(get_reaching_def): Call get_default_def_for.
(rewrite_operand): Remove.
(rewrite_stmt): Do nothing if REGISTER_DEFS_IN_THIS_STMT
and REWRITE_THIS_STMT are false.
Assume that all the operands in the statement are in
normal form.
(rewrite_add_phi_arguments): Don't use PHI_REWRITTEN.
(rewrite_virtual_phi_arguments): Remove.
(invalidate_name_tags): Remove.
(register_new_update_single, register_new_update_set,
rewrite_update_init_block, replace_use,
rewrite_update_fini_block, rewrite_update_stmt,
rewrite_update_phi_arguments): New.
rewrite_blocks): Remove argument 'fix_virtual_phis'.
Add arguments 'entry', 'what' and 'blocks'.
Initialize the dominator walker according to 'what' and
'blocks'.
Start the dominator walk at 'entry'.
(mark_def_site_blocks): Add argument 'interesting_blocks'.
Use it to configure the dominator walker.
(rewrite_into_ssa): Remove argument 'all'.
Make internal.
(rewrite_all_into_ssa): Remove.
(rewrite_def_def_chains): Remove.
(mark_def_interesting, mark_use_interesting,
prepare_phi_args_for_update, prepare_block_for_update,
prepare_def_site_for, prepare_def_sites,
dump_names_replaced_by, debug_names_replaced_by,
dump_repl_tbl, debug_repl_tbl, init_update_ssa,
delete_update_ssa, create_new_def_for,
register_new_name_mapping, mark_sym_for_renaming,
mark_set_for_renaming, need_ssa_update_p,
name_registered_for_update_p, ssa_names_to_replace,
release_ssa_name_after_update_ssa,
insert_updated_phi_nodes_for, update_ssa): New.
* tree-loop-linear.c (linear_transform_loops): Call
update_ssa instead of rewrite_into_ssa.
* tree-optimize.c (vars_to_rename): Remove.
Update all users.
(init_tree_optimization_passes): Replace
pass_redundant_phi with pass_copy_prop.
Add pass_vrp.
Replace pass_ccp with pass_store_ccp.
Add pass_store_copy_prop after pass_store_ccp.
(execute_todo): If the TODO_ flags don't include updating
the SSA form, assert that it does not need to be updated.
Call update_ssa instead of rewrite_into_ssa and
rewrite_def_def_chains.
If TODO_verify_loops is set, call verify_loop_closed_ssa.
(tree_rest_of_compilation):
* tree-pass.h (TODO_dump_func, TODO_ggc_collect,
TODO_verify_ssa, TODO_verify_flow, TODO_verify_stmts,
TODO_cleanup_cfg): Renumber.
(TODO_verify_loops, TODO_update_ssa,
TODO_update_ssa_no_phi, TODO_update_ssa_full_phi,
TODO_update_ssa_only_virtuals): Define.
(pass_copy_prop, pass_store_ccp, pass_store_copy_prop, pass_vrp):
Declare.
* tree-phinodes.c (make_phi_node): Update documentation.
(remove_all_phi_nodes_for): Remove.
(find_phi_node_for): New.
* tree-pretty-print.c (dump_generic_node): Handle ASSERT_EXPR.
* tree-scalar-evolution.c (follow_ssa_edge_in_rhs): Likewise.
(interpret_rhs_modify_expr): Likewise.
* tree-sra.c (decide_instantiations): Mark all symbols in
SRA_CANDIDATES for renaming.
(mark_all_v_defs_1): Rename from mark_all_v_defs.
(mark_all_v_defs): New function. Update all users to call it
with the whole list of scalarized statements, not just the
first one.
* tree-ssa-alias.c (count_ptr_derefs): Make extern.
(compute_flow_insensitive_aliasing): If the tag is
unmodifiable and the variable isn't or vice-versa, don't
make them alias of each other.
(setup_pointers_and_addressables): If the type tag for
VAR is about to change, mark the old one for renaming.
(add_type_alias): New.
* tree-ssa-ccp.c: Document SSA-CCP and STORE-CCP.
(ccp_lattice_t): Rename from latticevalue.
(value): Remove. Update all users.
(const_val): New local variable.
(do_store_ccp): New local variable.
(dump_lattice_value): Handle UNINITIALIZED.
(debug_lattice_value): New.
(get_default_value): Re-write.
(set_lattice_value): Re-write.
(def_to_varying): Remove. Update all users.
(likely_value): Return VARYING for statements that make
stores when STORE_CCP is false.
Return VARYING for any statement other than MODIFY_EXPR,
COND_EXPR and SWITCH_EXPR.
(ccp_initialize): Re-write.
(replace_uses_in, replace_vuse_in, substitute_and_fold):
Move to tree-ssa-propagate.c.
(ccp_lattice_meet): Handle memory stores when
DO_STORE_CCP is true.
(ccp_visit_phi_node): Likewise.
(ccp_fold): Likewise.
(evaluate_stmt): Likewise.
(visit_assignment): Likewise.
(ccp_visit_stmt): Likewise.
(execute_ssa_ccp): Add argument 'store_ccp'. Copy it
into DO_STORE_CCP.
(do_ssa_ccp): New.
(pass_ccp): Use it.
(do_ssa_store_ccp): New.
(gate_store_ccp): New.
(pass_store_ccp): Declare.
* tree-ssa-copy.c: Include tree-ssa-propagate.h.
(may_propagate_copy): Reformat.
Don't abort if ORIG is a virtual and DEST isn't.
If NEW does not have alias information but DEST does,
copy it.
(copy_of, cached_last_copy_of, do_store_copy_prop, enum
copy_prop_kind, which_copy_prop): Declare.
(stmt_may_generate_copy, get_copy_of_val,
get_last_copy_of, set_copy_of_val, dump_copy_of,
copy_prop_visit_assignment, copy_prop_visit_cond_stmt,
copy_prop_visit_stmt, copy_prop_visit_phi_node,
init_copy_prop, fini_copy_prop, execute_copy_prop,
gate_copy_prop, do_copy_prop, gate_store_copy_prop,
store_copy_prop): New.
(pass_copy_prop, pass_store_copy_prop): Declare.
* tree-ssa-dom.c (struct opt_stats_d): Add fields
'num_const_prop' and 'num_copy_prop'.
(cprop_operand): Update them.
(dump_dominator_optimization_stats): Dump them.
(tree_ssa_dominator_optimize): Call update_ssa instead of
rewrite_into_ssa.
(loop_depth_of_name): Declare extern.
(simplify_cond_and_lookup_avail_expr): Guard against NULL
values for LOW or HIGH.
(cprop_into_successor_phis): Only propagate if NEW != ORIG.
(record_equivalences_from_stmt): Call expr_computes_nonzero.
(cprop_operand): Only propagate if VAL != OP.
* tree-ssa-dse.c (dse_optimize_stmt): Mark symbols in removed
statement for renaming.
* tree-ssa-loop-im.c (move_computations): Call update_ssa.
* tree-ssa-loop-ivopts.c (rewrite_address_base): Call
add_type_alias if necessary.
Call mark_new_vars_to_rename.
(tree_ssa_iv_optimize): If new symbols need to be renamed,
mark every statement updated, call update_ssa and
rewrite_into_loop_closed_ssa.
* tree-ssa-loop-manip.c (add_exit_phis): Do not remove DEF_BB
from LIVEIN if VAR is a virtual.
* tree-ssa-loop.c (tree_loop_optimizer_init): Call update_ssa.
* tree-ssa-operands.c (get_expr_operands): Handle ASSERT_EXPR.
(get_call_expr_operands): Reformat statement.
(add_stmt_operand): Don't create V_MAY_DEFs for read-only
symbols.
* tree-ssa-propagate.c (ssa_prop_init): Initialize
SSA_NAME_VALUE for every name.
(first_vdef, stmt_makes_single_load, stmt_makes_single_store,
get_value_loaded_by): New.
(replace_uses_in, replace_vuses_in, replace_phi_args_in,
substitute_and_fold): Move from tree-ssa-ccp.c.
* tree-ssa-propagate.h (struct prop_value_d, prop_value_t,
first_vdef, stmt_makes_single_load, stmt_makes_single_store,
get_value_loaded_by, replace_uses_in, substitute_and_fold):
Declare.
* tree-ssa.c (verify_use): Fix error message.
(propagate_into_addr, replace_immediate_uses, get_eq_name,
check_phi_redundancy, kill_redundant_phi_nodes,
pass_redundant_phi): Remove. Update all users.
* tree-vect-transform.c (vect_create_data_ref_ptr): Call
add_type_alias, if necessary.
* tree-vectorizer.h (struct _stmt_vect_info): Update
documentation for field 'memtag'.
* tree-vrp.c: New file.
* tree.def (ASSERT_EXPR): Define.
* tree.h (ASSERT_EXPR_VAR): Define.
(ASSERT_EXPR_COND): Define.
(SSA_NAME_VALUE_RANGE): Define.
(struct tree_ssa_name): Add field 'value_range'.
(PHI_REWRITTEN): Remove.
(struct tree_phi_node): Remove field 'rewritten'.
* doc/invoke.texi (-fdump-tree-storeccp, -ftree-copy-prop,
-ftree-store-copy-prop): Document.
* doc/tree-ssa.texi: Remove broken link to McCAT's compiler.
Document usage of update_ssa.
testsuite/ChangeLog
* g++.dg/tree-ssa/pr18178.C: New test.
* gcc.c-torture/execute/20030216-1.x: Ignore at -O1.
* gcc.c-torture/execute/20041019-1.c: New test.
* gcc.dg/tree-ssa/20041008-1.c: New test.
* gcc.dg/tree-ssa/ssa-ccp-12.c: New test.
* gcc.dg/tree-ssa/20030731-2.c: Update to use -fdump-tree-store_ccp.
* gcc.dg/tree-ssa/20030917-1.c: Likewise.
* gcc.dg/tree-ssa/20030917-3.c: Likewise.
* gcc.dg/tree-ssa/20040721-1.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-1.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-2.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-3.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-7.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-9.c: Likewise.
From-SVN: r97884
2005-04-09 03:37:54 +02:00
|
|
|
|
else
|
2005-09-26 20:44:16 +02:00
|
|
|
|
res = t_false;
|
backport: copy-prop, incremental SSA updating of FUD chains and newly exposed symbols.
Merge from tree-cleanup-branch: VRP, store CCP, store
copy-prop, incremental SSA updating of FUD chains and
newly exposed symbols.
* Makefile.in (tree-ssa-copy.o): Depend on tree-ssa-propagate.h.
(OBJS-common): Add tree-vrp.o.
(tree-vrp.o): New rule.
* basic-block.h (nearest_common_dominator_for_set): Declare.
* common.opt (ftree-store-ccp): New flag.
(ftree-copy-prop): New flag.
(ftree-vrp): New flag.
(ftree-store-copy-prop): New flag.
* dominance.c (nearest_common_dominator_for_set): New.
* domwalk.c (walk_dominator_tree): Only traverse
statements in blocks marked in walk_data->interesting_blocks.
* domwalk.h (struct dom_walk_data): Add field interesting_blocks.
* fold-const.c (fold): Handle ASSERT_EXPR.
* opts.c (decode_options): Set flag_tree_copy_prop at -O1.
Set flag_tree_store_ccp, flag_tree_store_copy_prop and
flag_tree_vrp at -O2.
* timevar.def (TV_TREE_VRP): Define.
(TV_TREE_COPY_PROP): Define.
(TV_TREE_STORE_COPY_PROP): Define.
(TV_TREE_SSA_INCREMENTAL): Define.
(TV_TREE_STORE_CCP): Define.
* tree-cfg.c (tree_can_merge_blocks_p): Remove reference
to kill_redundant_phi_nodes from comment.
(verify_expr): Handle ASSERT_EXPR.
* tree-dfa.c (mark_new_vars_to_rename): Remove second
argument. Update all users.
(mark_call_clobbered_vars_to_rename): Remove. Update all
users.
* tree-flow-inline.h (unmodifiable_var_p): New.
* tree-flow.h (enum value_range_type): Declare.
(struct value_range_def): Declare.
(value_range): Declare.
(remove_all_phi_nodes_for): Remove. Update all users.
(find_phi_node_for): Declare.
(add_type_alias): Declare.
(count_uses_and_derefs): Declare.
(kill_redundant_phi_nodes): Remove.
(rewrite_into_ssa): Remove.
(rewrite_def_def_chains): Remove.
(update_ssa, register_new_name_mapping, create_new_def_for,
need_ssa_update_p, name_registered_for_update_p,
release_ssa_name_after_update_ssa, dump_repl_tbl,
debug_repl_tbl, dump_names_replaced_by,
debug_names_replaced_by, mark_sym_for_renaming,
mark_set_for_renaming, get_current_def, set_current_def,
get_value_range, dump_value_range, debug_value_range,
dump_all_value_ranges, debug_all_value_ranges,
expr_computes_nonzero, loop_depth_of_name,
unmodifiable_var_p): Declare.
* tree-gimple.c (is_gimple_formal_tmp_rhs): Handle
ASSERT_EXPR.
* tree-into-ssa.c (block_defs_stack): Update comment.
(old_ssa_names, new_ssa_names, old_virtual_ssa_names,
syms_to_rename, names_to_release, repl_tbl,
need_to_initialize_update_ssa_p, need_to_update_vops_p,
need_to_replace_names_p): New locals.
(NAME_SETS_GROWTH_FACTOR): Define.
(struct repl_map_d): Declare.
(struct mark_def_sites_global_data): Add field
interesting_blocks.
(enum rewrite_mode): Declare.
(REGISTER_DEFS_IN_THIS_STMT): Define.
(compute_global_livein): Use last_basic_block instead of
n_basic_blocks.
(set_def_block): Remove last argument. Update all callers.
(prepare_use_operand_for_rename): Remove. Update all callers.
(prepare_def_operand_for_rename): Remove. Update all callers.
(symbol_marked_for_renaming): New.
(is_old_name): New.
(is_new_name): New.
(repl_map_hash): New.
(repl_map_eq): New.
(repl_map_free): New.
(names_replaced_by): New.
(add_to_repl_tbl): New.
(add_new_name_mapping): New.
(mark_def_sites): Assume that all the operands in the
statement are in normal form.
(find_idf): Assert that the block in the stack is valid.
(get_default_def_for): New.
(insert_phi_nodes_for): Add new argument 'update_p'.
Add documentation.
If update_p is true, add a new mapping between the LHS of
each new PHI and the name that it replaces.
(insert_phi_nodes_1): Only call find_idf if needed.
(get_reaching_def): Call get_default_def_for.
(rewrite_operand): Remove.
(rewrite_stmt): Do nothing if REGISTER_DEFS_IN_THIS_STMT
and REWRITE_THIS_STMT are false.
Assume that all the operands in the statement are in
normal form.
(rewrite_add_phi_arguments): Don't use PHI_REWRITTEN.
(rewrite_virtual_phi_arguments): Remove.
(invalidate_name_tags): Remove.
(register_new_update_single, register_new_update_set,
rewrite_update_init_block, replace_use,
rewrite_update_fini_block, rewrite_update_stmt,
rewrite_update_phi_arguments): New.
rewrite_blocks): Remove argument 'fix_virtual_phis'.
Add arguments 'entry', 'what' and 'blocks'.
Initialize the dominator walker according to 'what' and
'blocks'.
Start the dominator walk at 'entry'.
(mark_def_site_blocks): Add argument 'interesting_blocks'.
Use it to configure the dominator walker.
(rewrite_into_ssa): Remove argument 'all'.
Make internal.
(rewrite_all_into_ssa): Remove.
(rewrite_def_def_chains): Remove.
(mark_def_interesting, mark_use_interesting,
prepare_phi_args_for_update, prepare_block_for_update,
prepare_def_site_for, prepare_def_sites,
dump_names_replaced_by, debug_names_replaced_by,
dump_repl_tbl, debug_repl_tbl, init_update_ssa,
delete_update_ssa, create_new_def_for,
register_new_name_mapping, mark_sym_for_renaming,
mark_set_for_renaming, need_ssa_update_p,
name_registered_for_update_p, ssa_names_to_replace,
release_ssa_name_after_update_ssa,
insert_updated_phi_nodes_for, update_ssa): New.
* tree-loop-linear.c (linear_transform_loops): Call
update_ssa instead of rewrite_into_ssa.
* tree-optimize.c (vars_to_rename): Remove.
Update all users.
(init_tree_optimization_passes): Replace
pass_redundant_phi with pass_copy_prop.
Add pass_vrp.
Replace pass_ccp with pass_store_ccp.
Add pass_store_copy_prop after pass_store_ccp.
(execute_todo): If the TODO_ flags don't include updating
the SSA form, assert that it does not need to be updated.
Call update_ssa instead of rewrite_into_ssa and
rewrite_def_def_chains.
If TODO_verify_loops is set, call verify_loop_closed_ssa.
(tree_rest_of_compilation):
* tree-pass.h (TODO_dump_func, TODO_ggc_collect,
TODO_verify_ssa, TODO_verify_flow, TODO_verify_stmts,
TODO_cleanup_cfg): Renumber.
(TODO_verify_loops, TODO_update_ssa,
TODO_update_ssa_no_phi, TODO_update_ssa_full_phi,
TODO_update_ssa_only_virtuals): Define.
(pass_copy_prop, pass_store_ccp, pass_store_copy_prop, pass_vrp):
Declare.
* tree-phinodes.c (make_phi_node): Update documentation.
(remove_all_phi_nodes_for): Remove.
(find_phi_node_for): New.
* tree-pretty-print.c (dump_generic_node): Handle ASSERT_EXPR.
* tree-scalar-evolution.c (follow_ssa_edge_in_rhs): Likewise.
(interpret_rhs_modify_expr): Likewise.
* tree-sra.c (decide_instantiations): Mark all symbols in
SRA_CANDIDATES for renaming.
(mark_all_v_defs_1): Rename from mark_all_v_defs.
(mark_all_v_defs): New function. Update all users to call it
with the whole list of scalarized statements, not just the
first one.
* tree-ssa-alias.c (count_ptr_derefs): Make extern.
(compute_flow_insensitive_aliasing): If the tag is
unmodifiable and the variable isn't or vice-versa, don't
make them alias of each other.
(setup_pointers_and_addressables): If the type tag for
VAR is about to change, mark the old one for renaming.
(add_type_alias): New.
* tree-ssa-ccp.c: Document SSA-CCP and STORE-CCP.
(ccp_lattice_t): Rename from latticevalue.
(value): Remove. Update all users.
(const_val): New local variable.
(do_store_ccp): New local variable.
(dump_lattice_value): Handle UNINITIALIZED.
(debug_lattice_value): New.
(get_default_value): Re-write.
(set_lattice_value): Re-write.
(def_to_varying): Remove. Update all users.
(likely_value): Return VARYING for statements that make
stores when STORE_CCP is false.
Return VARYING for any statement other than MODIFY_EXPR,
COND_EXPR and SWITCH_EXPR.
(ccp_initialize): Re-write.
(replace_uses_in, replace_vuse_in, substitute_and_fold):
Move to tree-ssa-propagate.c.
(ccp_lattice_meet): Handle memory stores when
DO_STORE_CCP is true.
(ccp_visit_phi_node): Likewise.
(ccp_fold): Likewise.
(evaluate_stmt): Likewise.
(visit_assignment): Likewise.
(ccp_visit_stmt): Likewise.
(execute_ssa_ccp): Add argument 'store_ccp'. Copy it
into DO_STORE_CCP.
(do_ssa_ccp): New.
(pass_ccp): Use it.
(do_ssa_store_ccp): New.
(gate_store_ccp): New.
(pass_store_ccp): Declare.
* tree-ssa-copy.c: Include tree-ssa-propagate.h.
(may_propagate_copy): Reformat.
Don't abort if ORIG is a virtual and DEST isn't.
If NEW does not have alias information but DEST does,
copy it.
(copy_of, cached_last_copy_of, do_store_copy_prop, enum
copy_prop_kind, which_copy_prop): Declare.
(stmt_may_generate_copy, get_copy_of_val,
get_last_copy_of, set_copy_of_val, dump_copy_of,
copy_prop_visit_assignment, copy_prop_visit_cond_stmt,
copy_prop_visit_stmt, copy_prop_visit_phi_node,
init_copy_prop, fini_copy_prop, execute_copy_prop,
gate_copy_prop, do_copy_prop, gate_store_copy_prop,
store_copy_prop): New.
(pass_copy_prop, pass_store_copy_prop): Declare.
* tree-ssa-dom.c (struct opt_stats_d): Add fields
'num_const_prop' and 'num_copy_prop'.
(cprop_operand): Update them.
(dump_dominator_optimization_stats): Dump them.
(tree_ssa_dominator_optimize): Call update_ssa instead of
rewrite_into_ssa.
(loop_depth_of_name): Declare extern.
(simplify_cond_and_lookup_avail_expr): Guard against NULL
values for LOW or HIGH.
(cprop_into_successor_phis): Only propagate if NEW != ORIG.
(record_equivalences_from_stmt): Call expr_computes_nonzero.
(cprop_operand): Only propagate if VAL != OP.
* tree-ssa-dse.c (dse_optimize_stmt): Mark symbols in removed
statement for renaming.
* tree-ssa-loop-im.c (move_computations): Call update_ssa.
* tree-ssa-loop-ivopts.c (rewrite_address_base): Call
add_type_alias if necessary.
Call mark_new_vars_to_rename.
(tree_ssa_iv_optimize): If new symbols need to be renamed,
mark every statement updated, call update_ssa and
rewrite_into_loop_closed_ssa.
* tree-ssa-loop-manip.c (add_exit_phis): Do not remove DEF_BB
from LIVEIN if VAR is a virtual.
* tree-ssa-loop.c (tree_loop_optimizer_init): Call update_ssa.
* tree-ssa-operands.c (get_expr_operands): Handle ASSERT_EXPR.
(get_call_expr_operands): Reformat statement.
(add_stmt_operand): Don't create V_MAY_DEFs for read-only
symbols.
* tree-ssa-propagate.c (ssa_prop_init): Initialize
SSA_NAME_VALUE for every name.
(first_vdef, stmt_makes_single_load, stmt_makes_single_store,
get_value_loaded_by): New.
(replace_uses_in, replace_vuses_in, replace_phi_args_in,
substitute_and_fold): Move from tree-ssa-ccp.c.
* tree-ssa-propagate.h (struct prop_value_d, prop_value_t,
first_vdef, stmt_makes_single_load, stmt_makes_single_store,
get_value_loaded_by, replace_uses_in, substitute_and_fold):
Declare.
* tree-ssa.c (verify_use): Fix error message.
(propagate_into_addr, replace_immediate_uses, get_eq_name,
check_phi_redundancy, kill_redundant_phi_nodes,
pass_redundant_phi): Remove. Update all users.
* tree-vect-transform.c (vect_create_data_ref_ptr): Call
add_type_alias, if necessary.
* tree-vectorizer.h (struct _stmt_vect_info): Update
documentation for field 'memtag'.
* tree-vrp.c: New file.
* tree.def (ASSERT_EXPR): Define.
* tree.h (ASSERT_EXPR_VAR): Define.
(ASSERT_EXPR_COND): Define.
(SSA_NAME_VALUE_RANGE): Define.
(struct tree_ssa_name): Add field 'value_range'.
(PHI_REWRITTEN): Remove.
(struct tree_phi_node): Remove field 'rewritten'.
* doc/invoke.texi (-fdump-tree-storeccp, -ftree-copy-prop,
-ftree-store-copy-prop): Document.
* doc/tree-ssa.texi: Remove broken link to McCAT's compiler.
Document usage of update_ssa.
testsuite/ChangeLog
* g++.dg/tree-ssa/pr18178.C: New test.
* gcc.c-torture/execute/20030216-1.x: Ignore at -O1.
* gcc.c-torture/execute/20041019-1.c: New test.
* gcc.dg/tree-ssa/20041008-1.c: New test.
* gcc.dg/tree-ssa/ssa-ccp-12.c: New test.
* gcc.dg/tree-ssa/20030731-2.c: Update to use -fdump-tree-store_ccp.
* gcc.dg/tree-ssa/20030917-1.c: Likewise.
* gcc.dg/tree-ssa/20030917-3.c: Likewise.
* gcc.dg/tree-ssa/20040721-1.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-1.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-2.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-3.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-7.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-9.c: Likewise.
From-SVN: r97884
2005-04-09 03:37:54 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-07-12 21:31:16 +02:00
|
|
|
|
default:
|
2005-09-26 20:44:16 +02:00
|
|
|
|
res = t_false;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Checks whether the I-th argument of a PHI comes from a backedge. */
|
|
|
|
|
|
|
|
|
|
static bool
|
|
|
|
|
backedge_phi_arg_p (tree phi, int i)
|
|
|
|
|
{
|
|
|
|
|
edge e = PHI_ARG_EDGE (phi, i);
|
|
|
|
|
|
|
|
|
|
/* We would in fact like to test EDGE_DFS_BACK here, but we do not care
|
|
|
|
|
about updating it anywhere, and this should work as well most of the
|
|
|
|
|
time. */
|
|
|
|
|
if (e->flags & EDGE_IRREDUCIBLE_LOOP)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Helper function for one branch of the condition-phi-node. Return
|
|
|
|
|
true if the strongly connected component has been found following
|
|
|
|
|
this path. */
|
|
|
|
|
|
2005-09-26 20:44:16 +02:00
|
|
|
|
static inline t_bool
|
2004-07-12 21:31:16 +02:00
|
|
|
|
follow_ssa_edge_in_condition_phi_branch (int i,
|
|
|
|
|
struct loop *loop,
|
|
|
|
|
tree condition_phi,
|
|
|
|
|
tree halting_phi,
|
|
|
|
|
tree *evolution_of_branch,
|
2005-09-26 20:44:16 +02:00
|
|
|
|
tree init_cond, int limit)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
{
|
|
|
|
|
tree branch = PHI_ARG_DEF (condition_phi, i);
|
|
|
|
|
*evolution_of_branch = chrec_dont_know;
|
|
|
|
|
|
|
|
|
|
/* Do not follow back edges (they must belong to an irreducible loop, which
|
|
|
|
|
we really do not want to worry about). */
|
|
|
|
|
if (backedge_phi_arg_p (condition_phi, i))
|
2005-09-26 20:44:16 +02:00
|
|
|
|
return t_false;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
if (TREE_CODE (branch) == SSA_NAME)
|
|
|
|
|
{
|
|
|
|
|
*evolution_of_branch = init_cond;
|
|
|
|
|
return follow_ssa_edge (loop, SSA_NAME_DEF_STMT (branch), halting_phi,
|
2005-09-26 20:44:16 +02:00
|
|
|
|
evolution_of_branch, limit);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This case occurs when one of the condition branches sets
|
bb-reorder.c, [...]: Fix comment typos.
* bb-reorder.c, c-common.c, c-incpath.c, c-typeck.c,
genrecog.c, lambda-code.c, mips-tdump.c, mips-tfile.c,
passes.c, tree-data-ref.c, tree-data-ref.h, tree-mudflap.c,
tree-scalar-evolution.c, tree-ssa-copyrename.c,
tree-ssa-live.c, tree-ssa-live.h: Fix comment typos.
From-SVN: r87302
2004-09-10 17:09:39 +02:00
|
|
|
|
the variable to a constant: i.e. a phi-node like
|
2004-07-12 21:31:16 +02:00
|
|
|
|
"a_2 = PHI <a_7(5), 2(6)>;".
|
|
|
|
|
|
|
|
|
|
FIXME: This case have to be refined correctly:
|
|
|
|
|
in some cases it is possible to say something better than
|
|
|
|
|
chrec_dont_know, for example using a wrap-around notation. */
|
2005-09-26 20:44:16 +02:00
|
|
|
|
return t_false;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This function merges the branches of a condition-phi-node in a
|
|
|
|
|
loop. */
|
|
|
|
|
|
2005-09-26 20:44:16 +02:00
|
|
|
|
static t_bool
|
2004-07-12 21:31:16 +02:00
|
|
|
|
follow_ssa_edge_in_condition_phi (struct loop *loop,
|
|
|
|
|
tree condition_phi,
|
|
|
|
|
tree halting_phi,
|
2005-09-26 20:44:16 +02:00
|
|
|
|
tree *evolution_of_loop, int limit)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
tree init = *evolution_of_loop;
|
|
|
|
|
tree evolution_of_branch;
|
2005-09-26 20:44:16 +02:00
|
|
|
|
t_bool res = follow_ssa_edge_in_condition_phi_branch (0, loop, condition_phi,
|
|
|
|
|
halting_phi,
|
|
|
|
|
&evolution_of_branch,
|
|
|
|
|
init, limit);
|
|
|
|
|
if (res == t_false || res == t_dont_know)
|
|
|
|
|
return res;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
*evolution_of_loop = evolution_of_branch;
|
|
|
|
|
|
|
|
|
|
for (i = 1; i < PHI_NUM_ARGS (condition_phi); i++)
|
|
|
|
|
{
|
2004-11-11 20:25:58 +01:00
|
|
|
|
/* Quickly give up when the evolution of one of the branches is
|
|
|
|
|
not known. */
|
|
|
|
|
if (*evolution_of_loop == chrec_dont_know)
|
2005-09-26 20:44:16 +02:00
|
|
|
|
return t_true;
|
2004-11-11 20:25:58 +01:00
|
|
|
|
|
2005-09-26 20:44:16 +02:00
|
|
|
|
res = follow_ssa_edge_in_condition_phi_branch (i, loop, condition_phi,
|
|
|
|
|
halting_phi,
|
|
|
|
|
&evolution_of_branch,
|
|
|
|
|
init, limit);
|
|
|
|
|
if (res == t_false || res == t_dont_know)
|
|
|
|
|
return res;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
*evolution_of_loop = chrec_merge (*evolution_of_loop,
|
|
|
|
|
evolution_of_branch);
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-26 20:44:16 +02:00
|
|
|
|
return t_true;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Follow an SSA edge in an inner loop. It computes the overall
|
|
|
|
|
effect of the loop, and following the symbolic initial conditions,
|
|
|
|
|
it follows the edges in the parent loop. The inner loop is
|
|
|
|
|
considered as a single statement. */
|
|
|
|
|
|
2005-09-26 20:44:16 +02:00
|
|
|
|
static t_bool
|
2004-07-12 21:31:16 +02:00
|
|
|
|
follow_ssa_edge_inner_loop_phi (struct loop *outer_loop,
|
|
|
|
|
tree loop_phi_node,
|
|
|
|
|
tree halting_phi,
|
2005-09-26 20:44:16 +02:00
|
|
|
|
tree *evolution_of_loop, int limit)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
{
|
|
|
|
|
struct loop *loop = loop_containing_stmt (loop_phi_node);
|
|
|
|
|
tree ev = analyze_scalar_evolution (loop, PHI_RESULT (loop_phi_node));
|
|
|
|
|
|
|
|
|
|
/* Sometimes, the inner loop is too difficult to analyze, and the
|
|
|
|
|
result of the analysis is a symbolic parameter. */
|
|
|
|
|
if (ev == PHI_RESULT (loop_phi_node))
|
|
|
|
|
{
|
2005-09-26 20:44:16 +02:00
|
|
|
|
t_bool res = t_false;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < PHI_NUM_ARGS (loop_phi_node); i++)
|
|
|
|
|
{
|
|
|
|
|
tree arg = PHI_ARG_DEF (loop_phi_node, i);
|
|
|
|
|
basic_block bb;
|
|
|
|
|
|
|
|
|
|
/* Follow the edges that exit the inner loop. */
|
|
|
|
|
bb = PHI_ARG_EDGE (loop_phi_node, i)->src;
|
|
|
|
|
if (!flow_bb_inside_loop_p (loop, bb))
|
2005-09-26 20:44:16 +02:00
|
|
|
|
res = follow_ssa_edge_in_rhs (outer_loop, loop_phi_node,
|
|
|
|
|
arg, halting_phi,
|
|
|
|
|
evolution_of_loop, limit);
|
|
|
|
|
if (res == t_true)
|
|
|
|
|
break;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If the path crosses this loop-phi, give up. */
|
2005-09-26 20:44:16 +02:00
|
|
|
|
if (res == t_true)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
*evolution_of_loop = chrec_dont_know;
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Otherwise, compute the overall effect of the inner loop. */
|
|
|
|
|
ev = compute_overall_effect_of_inner_loop (loop, ev);
|
2005-06-07 21:51:25 +02:00
|
|
|
|
return follow_ssa_edge_in_rhs (outer_loop, loop_phi_node, ev, halting_phi,
|
2005-09-26 20:44:16 +02:00
|
|
|
|
evolution_of_loop, limit);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Follow an SSA edge from a loop-phi-node to itself, constructing a
|
|
|
|
|
path that is analyzed on the return walk. */
|
|
|
|
|
|
2005-09-26 20:44:16 +02:00
|
|
|
|
static t_bool
|
|
|
|
|
follow_ssa_edge (struct loop *loop, tree def, tree halting_phi,
|
|
|
|
|
tree *evolution_of_loop, int limit)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
{
|
|
|
|
|
struct loop *def_loop;
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (def) == NOP_EXPR)
|
2005-09-26 20:44:16 +02:00
|
|
|
|
return t_false;
|
|
|
|
|
|
|
|
|
|
/* Give up if the path is longer than the MAX that we allow. */
|
|
|
|
|
if (limit++ > PARAM_VALUE (PARAM_SCEV_MAX_EXPR_SIZE))
|
|
|
|
|
return t_dont_know;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
def_loop = loop_containing_stmt (def);
|
|
|
|
|
|
|
|
|
|
switch (TREE_CODE (def))
|
|
|
|
|
{
|
|
|
|
|
case PHI_NODE:
|
|
|
|
|
if (!loop_phi_node_p (def))
|
|
|
|
|
/* DEF is a condition-phi-node. Follow the branches, and
|
|
|
|
|
record their evolutions. Finally, merge the collected
|
|
|
|
|
information and set the approximation to the main
|
|
|
|
|
variable. */
|
|
|
|
|
return follow_ssa_edge_in_condition_phi
|
2005-09-26 20:44:16 +02:00
|
|
|
|
(loop, def, halting_phi, evolution_of_loop, limit);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
/* When the analyzed phi is the halting_phi, the
|
|
|
|
|
depth-first search is over: we have found a path from
|
|
|
|
|
the halting_phi to itself in the loop. */
|
|
|
|
|
if (def == halting_phi)
|
2005-09-26 20:44:16 +02:00
|
|
|
|
return t_true;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
/* Otherwise, the evolution of the HALTING_PHI depends
|
bb-reorder.c, [...]: Fix comment typos.
* bb-reorder.c, c-common.c, c-incpath.c, c-typeck.c,
genrecog.c, lambda-code.c, mips-tdump.c, mips-tfile.c,
passes.c, tree-data-ref.c, tree-data-ref.h, tree-mudflap.c,
tree-scalar-evolution.c, tree-ssa-copyrename.c,
tree-ssa-live.c, tree-ssa-live.h: Fix comment typos.
From-SVN: r87302
2004-09-10 17:09:39 +02:00
|
|
|
|
on the evolution of another loop-phi-node, i.e. the
|
2004-07-12 21:31:16 +02:00
|
|
|
|
evolution function is a higher degree polynomial. */
|
|
|
|
|
if (def_loop == loop)
|
2005-09-26 20:44:16 +02:00
|
|
|
|
return t_false;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
/* Inner loop. */
|
|
|
|
|
if (flow_loop_nested_p (loop, def_loop))
|
|
|
|
|
return follow_ssa_edge_inner_loop_phi
|
2005-09-26 20:44:16 +02:00
|
|
|
|
(loop, def, halting_phi, evolution_of_loop, limit);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
/* Outer loop. */
|
2005-09-26 20:44:16 +02:00
|
|
|
|
return t_false;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
case MODIFY_EXPR:
|
2005-06-07 21:51:25 +02:00
|
|
|
|
return follow_ssa_edge_in_rhs (loop, def,
|
2004-07-12 21:31:16 +02:00
|
|
|
|
TREE_OPERAND (def, 1),
|
|
|
|
|
halting_phi,
|
2005-09-26 20:44:16 +02:00
|
|
|
|
evolution_of_loop, limit);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
/* At this level of abstraction, the program is just a set
|
|
|
|
|
of MODIFY_EXPRs and PHI_NODEs. In principle there is no
|
|
|
|
|
other node to be handled. */
|
2005-09-26 20:44:16 +02:00
|
|
|
|
return t_false;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Given a LOOP_PHI_NODE, this function determines the evolution
|
|
|
|
|
function from LOOP_PHI_NODE to LOOP_PHI_NODE in the loop. */
|
|
|
|
|
|
|
|
|
|
static tree
|
|
|
|
|
analyze_evolution_in_loop (tree loop_phi_node,
|
|
|
|
|
tree init_cond)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
tree evolution_function = chrec_not_analyzed_yet;
|
|
|
|
|
struct loop *loop = loop_containing_stmt (loop_phi_node);
|
|
|
|
|
basic_block bb;
|
|
|
|
|
|
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
|
{
|
|
|
|
|
fprintf (dump_file, "(analyze_evolution_in_loop \n");
|
|
|
|
|
fprintf (dump_file, " (loop_phi_node = ");
|
|
|
|
|
print_generic_expr (dump_file, loop_phi_node, 0);
|
|
|
|
|
fprintf (dump_file, ")\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < PHI_NUM_ARGS (loop_phi_node); i++)
|
|
|
|
|
{
|
|
|
|
|
tree arg = PHI_ARG_DEF (loop_phi_node, i);
|
|
|
|
|
tree ssa_chain, ev_fn;
|
|
|
|
|
bool res;
|
|
|
|
|
|
|
|
|
|
/* Select the edges that enter the loop body. */
|
|
|
|
|
bb = PHI_ARG_EDGE (loop_phi_node, i)->src;
|
|
|
|
|
if (!flow_bb_inside_loop_p (loop, bb))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (arg) == SSA_NAME)
|
|
|
|
|
{
|
|
|
|
|
ssa_chain = SSA_NAME_DEF_STMT (arg);
|
|
|
|
|
|
|
|
|
|
/* Pass in the initial condition to the follow edge function. */
|
|
|
|
|
ev_fn = init_cond;
|
2005-09-26 20:44:16 +02:00
|
|
|
|
res = follow_ssa_edge (loop, ssa_chain, loop_phi_node, &ev_fn, 0);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
res = false;
|
|
|
|
|
|
|
|
|
|
/* When it is impossible to go back on the same
|
|
|
|
|
loop_phi_node by following the ssa edges, the
|
bb-reorder.c, [...]: Fix comment typos.
* bb-reorder.c, c-common.c, c-incpath.c, c-typeck.c,
genrecog.c, lambda-code.c, mips-tdump.c, mips-tfile.c,
passes.c, tree-data-ref.c, tree-data-ref.h, tree-mudflap.c,
tree-scalar-evolution.c, tree-ssa-copyrename.c,
tree-ssa-live.c, tree-ssa-live.h: Fix comment typos.
From-SVN: r87302
2004-09-10 17:09:39 +02:00
|
|
|
|
evolution is represented by a peeled chrec, i.e. the
|
2004-07-12 21:31:16 +02:00
|
|
|
|
first iteration, EV_FN has the value INIT_COND, then
|
|
|
|
|
all the other iterations it has the value of ARG.
|
|
|
|
|
For the moment, PEELED_CHREC nodes are not built. */
|
|
|
|
|
if (!res)
|
|
|
|
|
ev_fn = chrec_dont_know;
|
|
|
|
|
|
|
|
|
|
/* When there are multiple back edges of the loop (which in fact never
|
c-common.c, [...]: Fix comment formatting.
* c-common.c, c-decl.c, combine.c, defaults.h, fold-const.c,
gimplify.c, gthr-nks.h, hooks.c, lambda-code.c, lambda-mat.c,
stor-layout.c, target.h, tree-cfg.c, tree-chrec.c,
tree-if-conv.c, tree-inline.c, tree-into-ssa.c,
tree-mudflap.c, tree-optimize.c, tree-scalar-evolution.c,
tree-ssa-alias.c, tree-ssa-ccp.c, tree-ssa-dce.c,
tree-ssa-pre.c, tree-vectorizer.c, tree-vectorizer.h, tree.h,
vec.h: Fix comment formatting.
From-SVN: r87105
2004-09-05 18:05:06 +02:00
|
|
|
|
happens currently, but nevertheless), merge their evolutions. */
|
2004-07-12 21:31:16 +02:00
|
|
|
|
evolution_function = chrec_merge (evolution_function, ev_fn);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
|
{
|
|
|
|
|
fprintf (dump_file, " (evolution_function = ");
|
|
|
|
|
print_generic_expr (dump_file, evolution_function, 0);
|
|
|
|
|
fprintf (dump_file, "))\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return evolution_function;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Given a loop-phi-node, return the initial conditions of the
|
|
|
|
|
variable on entry of the loop. When the CCP has propagated
|
|
|
|
|
constants into the loop-phi-node, the initial condition is
|
|
|
|
|
instantiated, otherwise the initial condition is kept symbolic.
|
|
|
|
|
This analyzer does not analyze the evolution outside the current
|
|
|
|
|
loop, and leaves this task to the on-demand tree reconstructor. */
|
|
|
|
|
|
|
|
|
|
static tree
|
|
|
|
|
analyze_initial_condition (tree loop_phi_node)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
tree init_cond = chrec_not_analyzed_yet;
|
|
|
|
|
struct loop *loop = bb_for_stmt (loop_phi_node)->loop_father;
|
|
|
|
|
|
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
|
{
|
|
|
|
|
fprintf (dump_file, "(analyze_initial_condition \n");
|
|
|
|
|
fprintf (dump_file, " (loop_phi_node = \n");
|
|
|
|
|
print_generic_expr (dump_file, loop_phi_node, 0);
|
|
|
|
|
fprintf (dump_file, ")\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < PHI_NUM_ARGS (loop_phi_node); i++)
|
|
|
|
|
{
|
|
|
|
|
tree branch = PHI_ARG_DEF (loop_phi_node, i);
|
|
|
|
|
basic_block bb = PHI_ARG_EDGE (loop_phi_node, i)->src;
|
|
|
|
|
|
|
|
|
|
/* When the branch is oriented to the loop's body, it does
|
|
|
|
|
not contribute to the initial condition. */
|
|
|
|
|
if (flow_bb_inside_loop_p (loop, bb))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (init_cond == chrec_not_analyzed_yet)
|
|
|
|
|
{
|
|
|
|
|
init_cond = branch;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (branch) == SSA_NAME)
|
|
|
|
|
{
|
|
|
|
|
init_cond = chrec_dont_know;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
init_cond = chrec_merge (init_cond, branch);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Ooops -- a loop without an entry??? */
|
|
|
|
|
if (init_cond == chrec_not_analyzed_yet)
|
|
|
|
|
init_cond = chrec_dont_know;
|
|
|
|
|
|
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
|
{
|
|
|
|
|
fprintf (dump_file, " (init_cond = ");
|
|
|
|
|
print_generic_expr (dump_file, init_cond, 0);
|
|
|
|
|
fprintf (dump_file, "))\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return init_cond;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Analyze the scalar evolution for LOOP_PHI_NODE. */
|
|
|
|
|
|
|
|
|
|
static tree
|
|
|
|
|
interpret_loop_phi (struct loop *loop, tree loop_phi_node)
|
|
|
|
|
{
|
|
|
|
|
tree res;
|
|
|
|
|
struct loop *phi_loop = loop_containing_stmt (loop_phi_node);
|
|
|
|
|
tree init_cond;
|
|
|
|
|
|
|
|
|
|
if (phi_loop != loop)
|
|
|
|
|
{
|
|
|
|
|
struct loop *subloop;
|
|
|
|
|
tree evolution_fn = analyze_scalar_evolution
|
|
|
|
|
(phi_loop, PHI_RESULT (loop_phi_node));
|
|
|
|
|
|
|
|
|
|
/* Dive one level deeper. */
|
|
|
|
|
subloop = superloop_at_depth (phi_loop, loop->depth + 1);
|
|
|
|
|
|
|
|
|
|
/* Interpret the subloop. */
|
|
|
|
|
res = compute_overall_effect_of_inner_loop (subloop, evolution_fn);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Otherwise really interpret the loop phi. */
|
|
|
|
|
init_cond = analyze_initial_condition (loop_phi_node);
|
|
|
|
|
res = analyze_evolution_in_loop (loop_phi_node, init_cond);
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This function merges the branches of a condition-phi-node,
|
|
|
|
|
contained in the outermost loop, and whose arguments are already
|
|
|
|
|
analyzed. */
|
|
|
|
|
|
|
|
|
|
static tree
|
|
|
|
|
interpret_condition_phi (struct loop *loop, tree condition_phi)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
tree res = chrec_not_analyzed_yet;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < PHI_NUM_ARGS (condition_phi); i++)
|
|
|
|
|
{
|
|
|
|
|
tree branch_chrec;
|
|
|
|
|
|
|
|
|
|
if (backedge_phi_arg_p (condition_phi, i))
|
|
|
|
|
{
|
|
|
|
|
res = chrec_dont_know;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
branch_chrec = analyze_scalar_evolution
|
|
|
|
|
(loop, PHI_ARG_DEF (condition_phi, i));
|
|
|
|
|
|
|
|
|
|
res = chrec_merge (res, branch_chrec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Interpret the right hand side of a modify_expr OPND1. If we didn't
|
2005-04-16 23:28:15 +02:00
|
|
|
|
analyze this node before, follow the definitions until ending
|
2004-07-12 21:31:16 +02:00
|
|
|
|
either on an analyzed modify_expr, or on a loop-phi-node. On the
|
|
|
|
|
return path, this function propagates evolutions (ala constant copy
|
|
|
|
|
propagation). OPND1 is not a GIMPLE expression because we could
|
|
|
|
|
analyze the effect of an inner loop: see interpret_loop_phi. */
|
|
|
|
|
|
|
|
|
|
static tree
|
2005-06-07 21:51:25 +02:00
|
|
|
|
interpret_rhs_modify_expr (struct loop *loop, tree at_stmt,
|
2004-07-12 21:31:16 +02:00
|
|
|
|
tree opnd1, tree type)
|
|
|
|
|
{
|
|
|
|
|
tree res, opnd10, opnd11, chrec10, chrec11;
|
2005-06-07 21:51:25 +02:00
|
|
|
|
|
2004-07-12 21:31:16 +02:00
|
|
|
|
if (is_gimple_min_invariant (opnd1))
|
2005-06-07 21:51:25 +02:00
|
|
|
|
return chrec_convert (type, opnd1, at_stmt);
|
|
|
|
|
|
2004-07-12 21:31:16 +02:00
|
|
|
|
switch (TREE_CODE (opnd1))
|
|
|
|
|
{
|
|
|
|
|
case PLUS_EXPR:
|
|
|
|
|
opnd10 = TREE_OPERAND (opnd1, 0);
|
|
|
|
|
opnd11 = TREE_OPERAND (opnd1, 1);
|
|
|
|
|
chrec10 = analyze_scalar_evolution (loop, opnd10);
|
|
|
|
|
chrec11 = analyze_scalar_evolution (loop, opnd11);
|
2005-06-07 21:51:25 +02:00
|
|
|
|
chrec10 = chrec_convert (type, chrec10, at_stmt);
|
|
|
|
|
chrec11 = chrec_convert (type, chrec11, at_stmt);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
res = chrec_fold_plus (type, chrec10, chrec11);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case MINUS_EXPR:
|
|
|
|
|
opnd10 = TREE_OPERAND (opnd1, 0);
|
|
|
|
|
opnd11 = TREE_OPERAND (opnd1, 1);
|
|
|
|
|
chrec10 = analyze_scalar_evolution (loop, opnd10);
|
|
|
|
|
chrec11 = analyze_scalar_evolution (loop, opnd11);
|
2005-06-07 21:51:25 +02:00
|
|
|
|
chrec10 = chrec_convert (type, chrec10, at_stmt);
|
|
|
|
|
chrec11 = chrec_convert (type, chrec11, at_stmt);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
res = chrec_fold_minus (type, chrec10, chrec11);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case NEGATE_EXPR:
|
|
|
|
|
opnd10 = TREE_OPERAND (opnd1, 0);
|
|
|
|
|
chrec10 = analyze_scalar_evolution (loop, opnd10);
|
2005-06-07 21:51:25 +02:00
|
|
|
|
chrec10 = chrec_convert (type, chrec10, at_stmt);
|
2005-08-15 14:26:12 +02:00
|
|
|
|
res = chrec_fold_multiply (type, chrec10, SCALAR_FLOAT_TYPE_P (type)
|
|
|
|
|
? build_real (type, dconstm1)
|
|
|
|
|
: build_int_cst_type (type, -1));
|
2004-07-12 21:31:16 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case MULT_EXPR:
|
|
|
|
|
opnd10 = TREE_OPERAND (opnd1, 0);
|
|
|
|
|
opnd11 = TREE_OPERAND (opnd1, 1);
|
|
|
|
|
chrec10 = analyze_scalar_evolution (loop, opnd10);
|
|
|
|
|
chrec11 = analyze_scalar_evolution (loop, opnd11);
|
2005-06-07 21:51:25 +02:00
|
|
|
|
chrec10 = chrec_convert (type, chrec10, at_stmt);
|
|
|
|
|
chrec11 = chrec_convert (type, chrec11, at_stmt);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
res = chrec_fold_multiply (type, chrec10, chrec11);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SSA_NAME:
|
2005-06-07 21:51:25 +02:00
|
|
|
|
res = chrec_convert (type, analyze_scalar_evolution (loop, opnd1),
|
|
|
|
|
at_stmt);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
break;
|
backport: copy-prop, incremental SSA updating of FUD chains and newly exposed symbols.
Merge from tree-cleanup-branch: VRP, store CCP, store
copy-prop, incremental SSA updating of FUD chains and
newly exposed symbols.
* Makefile.in (tree-ssa-copy.o): Depend on tree-ssa-propagate.h.
(OBJS-common): Add tree-vrp.o.
(tree-vrp.o): New rule.
* basic-block.h (nearest_common_dominator_for_set): Declare.
* common.opt (ftree-store-ccp): New flag.
(ftree-copy-prop): New flag.
(ftree-vrp): New flag.
(ftree-store-copy-prop): New flag.
* dominance.c (nearest_common_dominator_for_set): New.
* domwalk.c (walk_dominator_tree): Only traverse
statements in blocks marked in walk_data->interesting_blocks.
* domwalk.h (struct dom_walk_data): Add field interesting_blocks.
* fold-const.c (fold): Handle ASSERT_EXPR.
* opts.c (decode_options): Set flag_tree_copy_prop at -O1.
Set flag_tree_store_ccp, flag_tree_store_copy_prop and
flag_tree_vrp at -O2.
* timevar.def (TV_TREE_VRP): Define.
(TV_TREE_COPY_PROP): Define.
(TV_TREE_STORE_COPY_PROP): Define.
(TV_TREE_SSA_INCREMENTAL): Define.
(TV_TREE_STORE_CCP): Define.
* tree-cfg.c (tree_can_merge_blocks_p): Remove reference
to kill_redundant_phi_nodes from comment.
(verify_expr): Handle ASSERT_EXPR.
* tree-dfa.c (mark_new_vars_to_rename): Remove second
argument. Update all users.
(mark_call_clobbered_vars_to_rename): Remove. Update all
users.
* tree-flow-inline.h (unmodifiable_var_p): New.
* tree-flow.h (enum value_range_type): Declare.
(struct value_range_def): Declare.
(value_range): Declare.
(remove_all_phi_nodes_for): Remove. Update all users.
(find_phi_node_for): Declare.
(add_type_alias): Declare.
(count_uses_and_derefs): Declare.
(kill_redundant_phi_nodes): Remove.
(rewrite_into_ssa): Remove.
(rewrite_def_def_chains): Remove.
(update_ssa, register_new_name_mapping, create_new_def_for,
need_ssa_update_p, name_registered_for_update_p,
release_ssa_name_after_update_ssa, dump_repl_tbl,
debug_repl_tbl, dump_names_replaced_by,
debug_names_replaced_by, mark_sym_for_renaming,
mark_set_for_renaming, get_current_def, set_current_def,
get_value_range, dump_value_range, debug_value_range,
dump_all_value_ranges, debug_all_value_ranges,
expr_computes_nonzero, loop_depth_of_name,
unmodifiable_var_p): Declare.
* tree-gimple.c (is_gimple_formal_tmp_rhs): Handle
ASSERT_EXPR.
* tree-into-ssa.c (block_defs_stack): Update comment.
(old_ssa_names, new_ssa_names, old_virtual_ssa_names,
syms_to_rename, names_to_release, repl_tbl,
need_to_initialize_update_ssa_p, need_to_update_vops_p,
need_to_replace_names_p): New locals.
(NAME_SETS_GROWTH_FACTOR): Define.
(struct repl_map_d): Declare.
(struct mark_def_sites_global_data): Add field
interesting_blocks.
(enum rewrite_mode): Declare.
(REGISTER_DEFS_IN_THIS_STMT): Define.
(compute_global_livein): Use last_basic_block instead of
n_basic_blocks.
(set_def_block): Remove last argument. Update all callers.
(prepare_use_operand_for_rename): Remove. Update all callers.
(prepare_def_operand_for_rename): Remove. Update all callers.
(symbol_marked_for_renaming): New.
(is_old_name): New.
(is_new_name): New.
(repl_map_hash): New.
(repl_map_eq): New.
(repl_map_free): New.
(names_replaced_by): New.
(add_to_repl_tbl): New.
(add_new_name_mapping): New.
(mark_def_sites): Assume that all the operands in the
statement are in normal form.
(find_idf): Assert that the block in the stack is valid.
(get_default_def_for): New.
(insert_phi_nodes_for): Add new argument 'update_p'.
Add documentation.
If update_p is true, add a new mapping between the LHS of
each new PHI and the name that it replaces.
(insert_phi_nodes_1): Only call find_idf if needed.
(get_reaching_def): Call get_default_def_for.
(rewrite_operand): Remove.
(rewrite_stmt): Do nothing if REGISTER_DEFS_IN_THIS_STMT
and REWRITE_THIS_STMT are false.
Assume that all the operands in the statement are in
normal form.
(rewrite_add_phi_arguments): Don't use PHI_REWRITTEN.
(rewrite_virtual_phi_arguments): Remove.
(invalidate_name_tags): Remove.
(register_new_update_single, register_new_update_set,
rewrite_update_init_block, replace_use,
rewrite_update_fini_block, rewrite_update_stmt,
rewrite_update_phi_arguments): New.
rewrite_blocks): Remove argument 'fix_virtual_phis'.
Add arguments 'entry', 'what' and 'blocks'.
Initialize the dominator walker according to 'what' and
'blocks'.
Start the dominator walk at 'entry'.
(mark_def_site_blocks): Add argument 'interesting_blocks'.
Use it to configure the dominator walker.
(rewrite_into_ssa): Remove argument 'all'.
Make internal.
(rewrite_all_into_ssa): Remove.
(rewrite_def_def_chains): Remove.
(mark_def_interesting, mark_use_interesting,
prepare_phi_args_for_update, prepare_block_for_update,
prepare_def_site_for, prepare_def_sites,
dump_names_replaced_by, debug_names_replaced_by,
dump_repl_tbl, debug_repl_tbl, init_update_ssa,
delete_update_ssa, create_new_def_for,
register_new_name_mapping, mark_sym_for_renaming,
mark_set_for_renaming, need_ssa_update_p,
name_registered_for_update_p, ssa_names_to_replace,
release_ssa_name_after_update_ssa,
insert_updated_phi_nodes_for, update_ssa): New.
* tree-loop-linear.c (linear_transform_loops): Call
update_ssa instead of rewrite_into_ssa.
* tree-optimize.c (vars_to_rename): Remove.
Update all users.
(init_tree_optimization_passes): Replace
pass_redundant_phi with pass_copy_prop.
Add pass_vrp.
Replace pass_ccp with pass_store_ccp.
Add pass_store_copy_prop after pass_store_ccp.
(execute_todo): If the TODO_ flags don't include updating
the SSA form, assert that it does not need to be updated.
Call update_ssa instead of rewrite_into_ssa and
rewrite_def_def_chains.
If TODO_verify_loops is set, call verify_loop_closed_ssa.
(tree_rest_of_compilation):
* tree-pass.h (TODO_dump_func, TODO_ggc_collect,
TODO_verify_ssa, TODO_verify_flow, TODO_verify_stmts,
TODO_cleanup_cfg): Renumber.
(TODO_verify_loops, TODO_update_ssa,
TODO_update_ssa_no_phi, TODO_update_ssa_full_phi,
TODO_update_ssa_only_virtuals): Define.
(pass_copy_prop, pass_store_ccp, pass_store_copy_prop, pass_vrp):
Declare.
* tree-phinodes.c (make_phi_node): Update documentation.
(remove_all_phi_nodes_for): Remove.
(find_phi_node_for): New.
* tree-pretty-print.c (dump_generic_node): Handle ASSERT_EXPR.
* tree-scalar-evolution.c (follow_ssa_edge_in_rhs): Likewise.
(interpret_rhs_modify_expr): Likewise.
* tree-sra.c (decide_instantiations): Mark all symbols in
SRA_CANDIDATES for renaming.
(mark_all_v_defs_1): Rename from mark_all_v_defs.
(mark_all_v_defs): New function. Update all users to call it
with the whole list of scalarized statements, not just the
first one.
* tree-ssa-alias.c (count_ptr_derefs): Make extern.
(compute_flow_insensitive_aliasing): If the tag is
unmodifiable and the variable isn't or vice-versa, don't
make them alias of each other.
(setup_pointers_and_addressables): If the type tag for
VAR is about to change, mark the old one for renaming.
(add_type_alias): New.
* tree-ssa-ccp.c: Document SSA-CCP and STORE-CCP.
(ccp_lattice_t): Rename from latticevalue.
(value): Remove. Update all users.
(const_val): New local variable.
(do_store_ccp): New local variable.
(dump_lattice_value): Handle UNINITIALIZED.
(debug_lattice_value): New.
(get_default_value): Re-write.
(set_lattice_value): Re-write.
(def_to_varying): Remove. Update all users.
(likely_value): Return VARYING for statements that make
stores when STORE_CCP is false.
Return VARYING for any statement other than MODIFY_EXPR,
COND_EXPR and SWITCH_EXPR.
(ccp_initialize): Re-write.
(replace_uses_in, replace_vuse_in, substitute_and_fold):
Move to tree-ssa-propagate.c.
(ccp_lattice_meet): Handle memory stores when
DO_STORE_CCP is true.
(ccp_visit_phi_node): Likewise.
(ccp_fold): Likewise.
(evaluate_stmt): Likewise.
(visit_assignment): Likewise.
(ccp_visit_stmt): Likewise.
(execute_ssa_ccp): Add argument 'store_ccp'. Copy it
into DO_STORE_CCP.
(do_ssa_ccp): New.
(pass_ccp): Use it.
(do_ssa_store_ccp): New.
(gate_store_ccp): New.
(pass_store_ccp): Declare.
* tree-ssa-copy.c: Include tree-ssa-propagate.h.
(may_propagate_copy): Reformat.
Don't abort if ORIG is a virtual and DEST isn't.
If NEW does not have alias information but DEST does,
copy it.
(copy_of, cached_last_copy_of, do_store_copy_prop, enum
copy_prop_kind, which_copy_prop): Declare.
(stmt_may_generate_copy, get_copy_of_val,
get_last_copy_of, set_copy_of_val, dump_copy_of,
copy_prop_visit_assignment, copy_prop_visit_cond_stmt,
copy_prop_visit_stmt, copy_prop_visit_phi_node,
init_copy_prop, fini_copy_prop, execute_copy_prop,
gate_copy_prop, do_copy_prop, gate_store_copy_prop,
store_copy_prop): New.
(pass_copy_prop, pass_store_copy_prop): Declare.
* tree-ssa-dom.c (struct opt_stats_d): Add fields
'num_const_prop' and 'num_copy_prop'.
(cprop_operand): Update them.
(dump_dominator_optimization_stats): Dump them.
(tree_ssa_dominator_optimize): Call update_ssa instead of
rewrite_into_ssa.
(loop_depth_of_name): Declare extern.
(simplify_cond_and_lookup_avail_expr): Guard against NULL
values for LOW or HIGH.
(cprop_into_successor_phis): Only propagate if NEW != ORIG.
(record_equivalences_from_stmt): Call expr_computes_nonzero.
(cprop_operand): Only propagate if VAL != OP.
* tree-ssa-dse.c (dse_optimize_stmt): Mark symbols in removed
statement for renaming.
* tree-ssa-loop-im.c (move_computations): Call update_ssa.
* tree-ssa-loop-ivopts.c (rewrite_address_base): Call
add_type_alias if necessary.
Call mark_new_vars_to_rename.
(tree_ssa_iv_optimize): If new symbols need to be renamed,
mark every statement updated, call update_ssa and
rewrite_into_loop_closed_ssa.
* tree-ssa-loop-manip.c (add_exit_phis): Do not remove DEF_BB
from LIVEIN if VAR is a virtual.
* tree-ssa-loop.c (tree_loop_optimizer_init): Call update_ssa.
* tree-ssa-operands.c (get_expr_operands): Handle ASSERT_EXPR.
(get_call_expr_operands): Reformat statement.
(add_stmt_operand): Don't create V_MAY_DEFs for read-only
symbols.
* tree-ssa-propagate.c (ssa_prop_init): Initialize
SSA_NAME_VALUE for every name.
(first_vdef, stmt_makes_single_load, stmt_makes_single_store,
get_value_loaded_by): New.
(replace_uses_in, replace_vuses_in, replace_phi_args_in,
substitute_and_fold): Move from tree-ssa-ccp.c.
* tree-ssa-propagate.h (struct prop_value_d, prop_value_t,
first_vdef, stmt_makes_single_load, stmt_makes_single_store,
get_value_loaded_by, replace_uses_in, substitute_and_fold):
Declare.
* tree-ssa.c (verify_use): Fix error message.
(propagate_into_addr, replace_immediate_uses, get_eq_name,
check_phi_redundancy, kill_redundant_phi_nodes,
pass_redundant_phi): Remove. Update all users.
* tree-vect-transform.c (vect_create_data_ref_ptr): Call
add_type_alias, if necessary.
* tree-vectorizer.h (struct _stmt_vect_info): Update
documentation for field 'memtag'.
* tree-vrp.c: New file.
* tree.def (ASSERT_EXPR): Define.
* tree.h (ASSERT_EXPR_VAR): Define.
(ASSERT_EXPR_COND): Define.
(SSA_NAME_VALUE_RANGE): Define.
(struct tree_ssa_name): Add field 'value_range'.
(PHI_REWRITTEN): Remove.
(struct tree_phi_node): Remove field 'rewritten'.
* doc/invoke.texi (-fdump-tree-storeccp, -ftree-copy-prop,
-ftree-store-copy-prop): Document.
* doc/tree-ssa.texi: Remove broken link to McCAT's compiler.
Document usage of update_ssa.
testsuite/ChangeLog
* g++.dg/tree-ssa/pr18178.C: New test.
* gcc.c-torture/execute/20030216-1.x: Ignore at -O1.
* gcc.c-torture/execute/20041019-1.c: New test.
* gcc.dg/tree-ssa/20041008-1.c: New test.
* gcc.dg/tree-ssa/ssa-ccp-12.c: New test.
* gcc.dg/tree-ssa/20030731-2.c: Update to use -fdump-tree-store_ccp.
* gcc.dg/tree-ssa/20030917-1.c: Likewise.
* gcc.dg/tree-ssa/20030917-3.c: Likewise.
* gcc.dg/tree-ssa/20040721-1.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-1.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-2.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-3.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-7.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-9.c: Likewise.
From-SVN: r97884
2005-04-09 03:37:54 +02:00
|
|
|
|
|
|
|
|
|
case ASSERT_EXPR:
|
|
|
|
|
opnd10 = ASSERT_EXPR_VAR (opnd1);
|
2005-06-07 21:51:25 +02:00
|
|
|
|
res = chrec_convert (type, analyze_scalar_evolution (loop, opnd10),
|
|
|
|
|
at_stmt);
|
backport: copy-prop, incremental SSA updating of FUD chains and newly exposed symbols.
Merge from tree-cleanup-branch: VRP, store CCP, store
copy-prop, incremental SSA updating of FUD chains and
newly exposed symbols.
* Makefile.in (tree-ssa-copy.o): Depend on tree-ssa-propagate.h.
(OBJS-common): Add tree-vrp.o.
(tree-vrp.o): New rule.
* basic-block.h (nearest_common_dominator_for_set): Declare.
* common.opt (ftree-store-ccp): New flag.
(ftree-copy-prop): New flag.
(ftree-vrp): New flag.
(ftree-store-copy-prop): New flag.
* dominance.c (nearest_common_dominator_for_set): New.
* domwalk.c (walk_dominator_tree): Only traverse
statements in blocks marked in walk_data->interesting_blocks.
* domwalk.h (struct dom_walk_data): Add field interesting_blocks.
* fold-const.c (fold): Handle ASSERT_EXPR.
* opts.c (decode_options): Set flag_tree_copy_prop at -O1.
Set flag_tree_store_ccp, flag_tree_store_copy_prop and
flag_tree_vrp at -O2.
* timevar.def (TV_TREE_VRP): Define.
(TV_TREE_COPY_PROP): Define.
(TV_TREE_STORE_COPY_PROP): Define.
(TV_TREE_SSA_INCREMENTAL): Define.
(TV_TREE_STORE_CCP): Define.
* tree-cfg.c (tree_can_merge_blocks_p): Remove reference
to kill_redundant_phi_nodes from comment.
(verify_expr): Handle ASSERT_EXPR.
* tree-dfa.c (mark_new_vars_to_rename): Remove second
argument. Update all users.
(mark_call_clobbered_vars_to_rename): Remove. Update all
users.
* tree-flow-inline.h (unmodifiable_var_p): New.
* tree-flow.h (enum value_range_type): Declare.
(struct value_range_def): Declare.
(value_range): Declare.
(remove_all_phi_nodes_for): Remove. Update all users.
(find_phi_node_for): Declare.
(add_type_alias): Declare.
(count_uses_and_derefs): Declare.
(kill_redundant_phi_nodes): Remove.
(rewrite_into_ssa): Remove.
(rewrite_def_def_chains): Remove.
(update_ssa, register_new_name_mapping, create_new_def_for,
need_ssa_update_p, name_registered_for_update_p,
release_ssa_name_after_update_ssa, dump_repl_tbl,
debug_repl_tbl, dump_names_replaced_by,
debug_names_replaced_by, mark_sym_for_renaming,
mark_set_for_renaming, get_current_def, set_current_def,
get_value_range, dump_value_range, debug_value_range,
dump_all_value_ranges, debug_all_value_ranges,
expr_computes_nonzero, loop_depth_of_name,
unmodifiable_var_p): Declare.
* tree-gimple.c (is_gimple_formal_tmp_rhs): Handle
ASSERT_EXPR.
* tree-into-ssa.c (block_defs_stack): Update comment.
(old_ssa_names, new_ssa_names, old_virtual_ssa_names,
syms_to_rename, names_to_release, repl_tbl,
need_to_initialize_update_ssa_p, need_to_update_vops_p,
need_to_replace_names_p): New locals.
(NAME_SETS_GROWTH_FACTOR): Define.
(struct repl_map_d): Declare.
(struct mark_def_sites_global_data): Add field
interesting_blocks.
(enum rewrite_mode): Declare.
(REGISTER_DEFS_IN_THIS_STMT): Define.
(compute_global_livein): Use last_basic_block instead of
n_basic_blocks.
(set_def_block): Remove last argument. Update all callers.
(prepare_use_operand_for_rename): Remove. Update all callers.
(prepare_def_operand_for_rename): Remove. Update all callers.
(symbol_marked_for_renaming): New.
(is_old_name): New.
(is_new_name): New.
(repl_map_hash): New.
(repl_map_eq): New.
(repl_map_free): New.
(names_replaced_by): New.
(add_to_repl_tbl): New.
(add_new_name_mapping): New.
(mark_def_sites): Assume that all the operands in the
statement are in normal form.
(find_idf): Assert that the block in the stack is valid.
(get_default_def_for): New.
(insert_phi_nodes_for): Add new argument 'update_p'.
Add documentation.
If update_p is true, add a new mapping between the LHS of
each new PHI and the name that it replaces.
(insert_phi_nodes_1): Only call find_idf if needed.
(get_reaching_def): Call get_default_def_for.
(rewrite_operand): Remove.
(rewrite_stmt): Do nothing if REGISTER_DEFS_IN_THIS_STMT
and REWRITE_THIS_STMT are false.
Assume that all the operands in the statement are in
normal form.
(rewrite_add_phi_arguments): Don't use PHI_REWRITTEN.
(rewrite_virtual_phi_arguments): Remove.
(invalidate_name_tags): Remove.
(register_new_update_single, register_new_update_set,
rewrite_update_init_block, replace_use,
rewrite_update_fini_block, rewrite_update_stmt,
rewrite_update_phi_arguments): New.
rewrite_blocks): Remove argument 'fix_virtual_phis'.
Add arguments 'entry', 'what' and 'blocks'.
Initialize the dominator walker according to 'what' and
'blocks'.
Start the dominator walk at 'entry'.
(mark_def_site_blocks): Add argument 'interesting_blocks'.
Use it to configure the dominator walker.
(rewrite_into_ssa): Remove argument 'all'.
Make internal.
(rewrite_all_into_ssa): Remove.
(rewrite_def_def_chains): Remove.
(mark_def_interesting, mark_use_interesting,
prepare_phi_args_for_update, prepare_block_for_update,
prepare_def_site_for, prepare_def_sites,
dump_names_replaced_by, debug_names_replaced_by,
dump_repl_tbl, debug_repl_tbl, init_update_ssa,
delete_update_ssa, create_new_def_for,
register_new_name_mapping, mark_sym_for_renaming,
mark_set_for_renaming, need_ssa_update_p,
name_registered_for_update_p, ssa_names_to_replace,
release_ssa_name_after_update_ssa,
insert_updated_phi_nodes_for, update_ssa): New.
* tree-loop-linear.c (linear_transform_loops): Call
update_ssa instead of rewrite_into_ssa.
* tree-optimize.c (vars_to_rename): Remove.
Update all users.
(init_tree_optimization_passes): Replace
pass_redundant_phi with pass_copy_prop.
Add pass_vrp.
Replace pass_ccp with pass_store_ccp.
Add pass_store_copy_prop after pass_store_ccp.
(execute_todo): If the TODO_ flags don't include updating
the SSA form, assert that it does not need to be updated.
Call update_ssa instead of rewrite_into_ssa and
rewrite_def_def_chains.
If TODO_verify_loops is set, call verify_loop_closed_ssa.
(tree_rest_of_compilation):
* tree-pass.h (TODO_dump_func, TODO_ggc_collect,
TODO_verify_ssa, TODO_verify_flow, TODO_verify_stmts,
TODO_cleanup_cfg): Renumber.
(TODO_verify_loops, TODO_update_ssa,
TODO_update_ssa_no_phi, TODO_update_ssa_full_phi,
TODO_update_ssa_only_virtuals): Define.
(pass_copy_prop, pass_store_ccp, pass_store_copy_prop, pass_vrp):
Declare.
* tree-phinodes.c (make_phi_node): Update documentation.
(remove_all_phi_nodes_for): Remove.
(find_phi_node_for): New.
* tree-pretty-print.c (dump_generic_node): Handle ASSERT_EXPR.
* tree-scalar-evolution.c (follow_ssa_edge_in_rhs): Likewise.
(interpret_rhs_modify_expr): Likewise.
* tree-sra.c (decide_instantiations): Mark all symbols in
SRA_CANDIDATES for renaming.
(mark_all_v_defs_1): Rename from mark_all_v_defs.
(mark_all_v_defs): New function. Update all users to call it
with the whole list of scalarized statements, not just the
first one.
* tree-ssa-alias.c (count_ptr_derefs): Make extern.
(compute_flow_insensitive_aliasing): If the tag is
unmodifiable and the variable isn't or vice-versa, don't
make them alias of each other.
(setup_pointers_and_addressables): If the type tag for
VAR is about to change, mark the old one for renaming.
(add_type_alias): New.
* tree-ssa-ccp.c: Document SSA-CCP and STORE-CCP.
(ccp_lattice_t): Rename from latticevalue.
(value): Remove. Update all users.
(const_val): New local variable.
(do_store_ccp): New local variable.
(dump_lattice_value): Handle UNINITIALIZED.
(debug_lattice_value): New.
(get_default_value): Re-write.
(set_lattice_value): Re-write.
(def_to_varying): Remove. Update all users.
(likely_value): Return VARYING for statements that make
stores when STORE_CCP is false.
Return VARYING for any statement other than MODIFY_EXPR,
COND_EXPR and SWITCH_EXPR.
(ccp_initialize): Re-write.
(replace_uses_in, replace_vuse_in, substitute_and_fold):
Move to tree-ssa-propagate.c.
(ccp_lattice_meet): Handle memory stores when
DO_STORE_CCP is true.
(ccp_visit_phi_node): Likewise.
(ccp_fold): Likewise.
(evaluate_stmt): Likewise.
(visit_assignment): Likewise.
(ccp_visit_stmt): Likewise.
(execute_ssa_ccp): Add argument 'store_ccp'. Copy it
into DO_STORE_CCP.
(do_ssa_ccp): New.
(pass_ccp): Use it.
(do_ssa_store_ccp): New.
(gate_store_ccp): New.
(pass_store_ccp): Declare.
* tree-ssa-copy.c: Include tree-ssa-propagate.h.
(may_propagate_copy): Reformat.
Don't abort if ORIG is a virtual and DEST isn't.
If NEW does not have alias information but DEST does,
copy it.
(copy_of, cached_last_copy_of, do_store_copy_prop, enum
copy_prop_kind, which_copy_prop): Declare.
(stmt_may_generate_copy, get_copy_of_val,
get_last_copy_of, set_copy_of_val, dump_copy_of,
copy_prop_visit_assignment, copy_prop_visit_cond_stmt,
copy_prop_visit_stmt, copy_prop_visit_phi_node,
init_copy_prop, fini_copy_prop, execute_copy_prop,
gate_copy_prop, do_copy_prop, gate_store_copy_prop,
store_copy_prop): New.
(pass_copy_prop, pass_store_copy_prop): Declare.
* tree-ssa-dom.c (struct opt_stats_d): Add fields
'num_const_prop' and 'num_copy_prop'.
(cprop_operand): Update them.
(dump_dominator_optimization_stats): Dump them.
(tree_ssa_dominator_optimize): Call update_ssa instead of
rewrite_into_ssa.
(loop_depth_of_name): Declare extern.
(simplify_cond_and_lookup_avail_expr): Guard against NULL
values for LOW or HIGH.
(cprop_into_successor_phis): Only propagate if NEW != ORIG.
(record_equivalences_from_stmt): Call expr_computes_nonzero.
(cprop_operand): Only propagate if VAL != OP.
* tree-ssa-dse.c (dse_optimize_stmt): Mark symbols in removed
statement for renaming.
* tree-ssa-loop-im.c (move_computations): Call update_ssa.
* tree-ssa-loop-ivopts.c (rewrite_address_base): Call
add_type_alias if necessary.
Call mark_new_vars_to_rename.
(tree_ssa_iv_optimize): If new symbols need to be renamed,
mark every statement updated, call update_ssa and
rewrite_into_loop_closed_ssa.
* tree-ssa-loop-manip.c (add_exit_phis): Do not remove DEF_BB
from LIVEIN if VAR is a virtual.
* tree-ssa-loop.c (tree_loop_optimizer_init): Call update_ssa.
* tree-ssa-operands.c (get_expr_operands): Handle ASSERT_EXPR.
(get_call_expr_operands): Reformat statement.
(add_stmt_operand): Don't create V_MAY_DEFs for read-only
symbols.
* tree-ssa-propagate.c (ssa_prop_init): Initialize
SSA_NAME_VALUE for every name.
(first_vdef, stmt_makes_single_load, stmt_makes_single_store,
get_value_loaded_by): New.
(replace_uses_in, replace_vuses_in, replace_phi_args_in,
substitute_and_fold): Move from tree-ssa-ccp.c.
* tree-ssa-propagate.h (struct prop_value_d, prop_value_t,
first_vdef, stmt_makes_single_load, stmt_makes_single_store,
get_value_loaded_by, replace_uses_in, substitute_and_fold):
Declare.
* tree-ssa.c (verify_use): Fix error message.
(propagate_into_addr, replace_immediate_uses, get_eq_name,
check_phi_redundancy, kill_redundant_phi_nodes,
pass_redundant_phi): Remove. Update all users.
* tree-vect-transform.c (vect_create_data_ref_ptr): Call
add_type_alias, if necessary.
* tree-vectorizer.h (struct _stmt_vect_info): Update
documentation for field 'memtag'.
* tree-vrp.c: New file.
* tree.def (ASSERT_EXPR): Define.
* tree.h (ASSERT_EXPR_VAR): Define.
(ASSERT_EXPR_COND): Define.
(SSA_NAME_VALUE_RANGE): Define.
(struct tree_ssa_name): Add field 'value_range'.
(PHI_REWRITTEN): Remove.
(struct tree_phi_node): Remove field 'rewritten'.
* doc/invoke.texi (-fdump-tree-storeccp, -ftree-copy-prop,
-ftree-store-copy-prop): Document.
* doc/tree-ssa.texi: Remove broken link to McCAT's compiler.
Document usage of update_ssa.
testsuite/ChangeLog
* g++.dg/tree-ssa/pr18178.C: New test.
* gcc.c-torture/execute/20030216-1.x: Ignore at -O1.
* gcc.c-torture/execute/20041019-1.c: New test.
* gcc.dg/tree-ssa/20041008-1.c: New test.
* gcc.dg/tree-ssa/ssa-ccp-12.c: New test.
* gcc.dg/tree-ssa/20030731-2.c: Update to use -fdump-tree-store_ccp.
* gcc.dg/tree-ssa/20030917-1.c: Likewise.
* gcc.dg/tree-ssa/20030917-3.c: Likewise.
* gcc.dg/tree-ssa/20040721-1.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-1.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-2.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-3.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-7.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-9.c: Likewise.
From-SVN: r97884
2005-04-09 03:37:54 +02:00
|
|
|
|
break;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
case NOP_EXPR:
|
|
|
|
|
case CONVERT_EXPR:
|
|
|
|
|
opnd10 = TREE_OPERAND (opnd1, 0);
|
|
|
|
|
chrec10 = analyze_scalar_evolution (loop, opnd10);
|
2005-06-07 21:51:25 +02:00
|
|
|
|
res = chrec_convert (type, chrec10, at_stmt);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
res = chrec_dont_know;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* This section contains all the entry points:
|
|
|
|
|
- number_of_iterations_in_loop,
|
|
|
|
|
- analyze_scalar_evolution,
|
|
|
|
|
- instantiate_parameters.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* Compute and return the evolution function in WRTO_LOOP, the nearest
|
|
|
|
|
common ancestor of DEF_LOOP and USE_LOOP. */
|
|
|
|
|
|
|
|
|
|
static tree
|
|
|
|
|
compute_scalar_evolution_in_loop (struct loop *wrto_loop,
|
|
|
|
|
struct loop *def_loop,
|
|
|
|
|
tree ev)
|
|
|
|
|
{
|
|
|
|
|
tree res;
|
|
|
|
|
if (def_loop == wrto_loop)
|
|
|
|
|
return ev;
|
|
|
|
|
|
|
|
|
|
def_loop = superloop_at_depth (def_loop, wrto_loop->depth + 1);
|
|
|
|
|
res = compute_overall_effect_of_inner_loop (def_loop, ev);
|
|
|
|
|
|
|
|
|
|
return analyze_scalar_evolution_1 (wrto_loop, res, chrec_not_analyzed_yet);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Helper recursive function. */
|
|
|
|
|
|
|
|
|
|
static tree
|
|
|
|
|
analyze_scalar_evolution_1 (struct loop *loop, tree var, tree res)
|
|
|
|
|
{
|
|
|
|
|
tree def, type = TREE_TYPE (var);
|
|
|
|
|
basic_block bb;
|
|
|
|
|
struct loop *def_loop;
|
|
|
|
|
|
|
|
|
|
if (loop == NULL)
|
|
|
|
|
return chrec_dont_know;
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (var) != SSA_NAME)
|
2005-06-07 21:51:25 +02:00
|
|
|
|
return interpret_rhs_modify_expr (loop, NULL_TREE, var, type);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
def = SSA_NAME_DEF_STMT (var);
|
|
|
|
|
bb = bb_for_stmt (def);
|
|
|
|
|
def_loop = bb ? bb->loop_father : NULL;
|
|
|
|
|
|
|
|
|
|
if (bb == NULL
|
|
|
|
|
|| !flow_bb_inside_loop_p (loop, bb))
|
|
|
|
|
{
|
|
|
|
|
/* Keep the symbolic form. */
|
|
|
|
|
res = var;
|
|
|
|
|
goto set_and_end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (res != chrec_not_analyzed_yet)
|
|
|
|
|
{
|
|
|
|
|
if (loop != bb->loop_father)
|
|
|
|
|
res = compute_scalar_evolution_in_loop
|
|
|
|
|
(find_common_loop (loop, bb->loop_father), bb->loop_father, res);
|
|
|
|
|
|
|
|
|
|
goto set_and_end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (loop != def_loop)
|
|
|
|
|
{
|
|
|
|
|
res = analyze_scalar_evolution_1 (def_loop, var, chrec_not_analyzed_yet);
|
|
|
|
|
res = compute_scalar_evolution_in_loop (loop, def_loop, res);
|
|
|
|
|
|
|
|
|
|
goto set_and_end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (TREE_CODE (def))
|
|
|
|
|
{
|
|
|
|
|
case MODIFY_EXPR:
|
2005-06-07 21:51:25 +02:00
|
|
|
|
res = interpret_rhs_modify_expr (loop, def, TREE_OPERAND (def, 1), type);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PHI_NODE:
|
|
|
|
|
if (loop_phi_node_p (def))
|
|
|
|
|
res = interpret_loop_phi (loop, def);
|
|
|
|
|
else
|
|
|
|
|
res = interpret_condition_phi (loop, def);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
res = chrec_dont_know;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set_and_end:
|
|
|
|
|
|
|
|
|
|
/* Keep the symbolic form. */
|
|
|
|
|
if (res == chrec_dont_know)
|
|
|
|
|
res = var;
|
|
|
|
|
|
|
|
|
|
if (loop == def_loop)
|
|
|
|
|
set_scalar_evolution (var, res);
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Entry point for the scalar evolution analyzer.
|
|
|
|
|
Analyzes and returns the scalar evolution of the ssa_name VAR.
|
|
|
|
|
LOOP_NB is the identifier number of the loop in which the variable
|
|
|
|
|
is used.
|
|
|
|
|
|
|
|
|
|
Example of use: having a pointer VAR to a SSA_NAME node, STMT a
|
|
|
|
|
pointer to the statement that uses this variable, in order to
|
|
|
|
|
determine the evolution function of the variable, use the following
|
|
|
|
|
calls:
|
|
|
|
|
|
|
|
|
|
unsigned loop_nb = loop_containing_stmt (stmt)->num;
|
|
|
|
|
tree chrec_with_symbols = analyze_scalar_evolution (loop_nb, var);
|
|
|
|
|
tree chrec_instantiated = instantiate_parameters
|
|
|
|
|
(loop_nb, chrec_with_symbols);
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
tree
|
|
|
|
|
analyze_scalar_evolution (struct loop *loop, tree var)
|
|
|
|
|
{
|
|
|
|
|
tree res;
|
|
|
|
|
|
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
|
{
|
|
|
|
|
fprintf (dump_file, "(analyze_scalar_evolution \n");
|
|
|
|
|
fprintf (dump_file, " (loop_nb = %d)\n", loop->num);
|
|
|
|
|
fprintf (dump_file, " (scalar = ");
|
|
|
|
|
print_generic_expr (dump_file, var, 0);
|
|
|
|
|
fprintf (dump_file, ")\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
res = analyze_scalar_evolution_1 (loop, var, get_scalar_evolution (var));
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (var) == SSA_NAME && res == chrec_dont_know)
|
|
|
|
|
res = var;
|
|
|
|
|
|
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
|
fprintf (dump_file, ")\n");
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Analyze scalar evolution of use of VERSION in USE_LOOP with respect to
|
|
|
|
|
WRTO_LOOP (which should be a superloop of both USE_LOOP and definition
|
|
|
|
|
of VERSION). */
|
|
|
|
|
|
|
|
|
|
static tree
|
|
|
|
|
analyze_scalar_evolution_in_loop (struct loop *wrto_loop, struct loop *use_loop,
|
|
|
|
|
tree version)
|
|
|
|
|
{
|
|
|
|
|
bool val = false;
|
|
|
|
|
tree ev = version;
|
|
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
ev = analyze_scalar_evolution (use_loop, ev);
|
|
|
|
|
ev = resolve_mixers (use_loop, ev);
|
|
|
|
|
|
|
|
|
|
if (use_loop == wrto_loop)
|
|
|
|
|
return ev;
|
|
|
|
|
|
|
|
|
|
/* If the value of the use changes in the inner loop, we cannot express
|
|
|
|
|
its value in the outer loop (we might try to return interval chrec,
|
|
|
|
|
but we do not have a user for it anyway) */
|
|
|
|
|
if (!no_evolution_in_loop_p (ev, use_loop->num, &val)
|
|
|
|
|
|| !val)
|
|
|
|
|
return chrec_dont_know;
|
|
|
|
|
|
|
|
|
|
use_loop = use_loop->outer;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-01-09 09:22:10 +01:00
|
|
|
|
/* Returns instantiated value for VERSION in CACHE. */
|
|
|
|
|
|
|
|
|
|
static tree
|
|
|
|
|
get_instantiated_value (htab_t cache, tree version)
|
|
|
|
|
{
|
|
|
|
|
struct scev_info_str *info, pattern;
|
|
|
|
|
|
|
|
|
|
pattern.var = version;
|
|
|
|
|
info = htab_find (cache, &pattern);
|
|
|
|
|
|
|
|
|
|
if (info)
|
|
|
|
|
return info->chrec;
|
|
|
|
|
else
|
|
|
|
|
return NULL_TREE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Sets instantiated value for VERSION to VAL in CACHE. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
set_instantiated_value (htab_t cache, tree version, tree val)
|
|
|
|
|
{
|
|
|
|
|
struct scev_info_str *info, pattern;
|
|
|
|
|
PTR *slot;
|
|
|
|
|
|
|
|
|
|
pattern.var = version;
|
|
|
|
|
slot = htab_find_slot (cache, &pattern, INSERT);
|
|
|
|
|
|
|
|
|
|
if (*slot)
|
|
|
|
|
info = *slot;
|
|
|
|
|
else
|
|
|
|
|
info = *slot = new_scev_info_str (version);
|
|
|
|
|
info->chrec = val;
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-09 12:56:41 +02:00
|
|
|
|
/* Return the closed_loop_phi node for VAR. If there is none, return
|
|
|
|
|
NULL_TREE. */
|
|
|
|
|
|
|
|
|
|
static tree
|
|
|
|
|
loop_closed_phi_def (tree var)
|
|
|
|
|
{
|
|
|
|
|
struct loop *loop;
|
|
|
|
|
edge exit;
|
|
|
|
|
tree phi;
|
|
|
|
|
|
|
|
|
|
if (var == NULL_TREE
|
|
|
|
|
|| TREE_CODE (var) != SSA_NAME)
|
|
|
|
|
return NULL_TREE;
|
|
|
|
|
|
|
|
|
|
loop = loop_containing_stmt (SSA_NAME_DEF_STMT (var));
|
|
|
|
|
exit = loop->single_exit;
|
|
|
|
|
if (!exit)
|
|
|
|
|
return NULL_TREE;
|
|
|
|
|
|
|
|
|
|
for (phi = phi_nodes (exit->dest); phi; phi = PHI_CHAIN (phi))
|
|
|
|
|
if (PHI_ARG_DEF_FROM_EDGE (phi, exit) == var)
|
|
|
|
|
return PHI_RESULT (phi);
|
|
|
|
|
|
|
|
|
|
return NULL_TREE;
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-12 21:31:16 +02:00
|
|
|
|
/* Analyze all the parameters of the chrec that were left under a symbolic form,
|
2005-09-20 09:09:20 +02:00
|
|
|
|
with respect to LOOP. CHREC is the chrec to instantiate. CACHE is the cache
|
|
|
|
|
of already instantiated values. FLAGS modify the way chrecs are
|
2005-11-04 20:10:04 +01:00
|
|
|
|
instantiated. SIZE_EXPR is used for computing the size of the expression to
|
|
|
|
|
be instantiated, and to stop if it exceeds some limit. */
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
2005-09-20 09:09:20 +02:00
|
|
|
|
/* Values for FLAGS. */
|
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
INSERT_SUPERLOOP_CHRECS = 1, /* Loop invariants are replaced with chrecs
|
|
|
|
|
in outer loops. */
|
|
|
|
|
FOLD_CONVERSIONS = 2 /* The conversions that may wrap in
|
|
|
|
|
signed/pointer type are folded, as long as the
|
|
|
|
|
value of the chrec is preserved. */
|
|
|
|
|
};
|
|
|
|
|
|
2004-07-12 21:31:16 +02:00
|
|
|
|
static tree
|
2005-11-04 20:10:04 +01:00
|
|
|
|
instantiate_parameters_1 (struct loop *loop, tree chrec, int flags, htab_t cache,
|
|
|
|
|
int size_expr)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
{
|
|
|
|
|
tree res, op0, op1, op2;
|
|
|
|
|
basic_block def_bb;
|
|
|
|
|
struct loop *def_loop;
|
2005-09-20 09:09:20 +02:00
|
|
|
|
|
2005-11-04 20:10:04 +01:00
|
|
|
|
/* Give up if the expression is larger than the MAX that we allow. */
|
|
|
|
|
if (size_expr++ > PARAM_VALUE (PARAM_SCEV_MAX_EXPR_SIZE))
|
|
|
|
|
return chrec_dont_know;
|
|
|
|
|
|
2005-08-13 19:28:43 +02:00
|
|
|
|
if (automatically_generated_chrec_p (chrec)
|
|
|
|
|
|| is_gimple_min_invariant (chrec))
|
2004-07-12 21:31:16 +02:00
|
|
|
|
return chrec;
|
|
|
|
|
|
|
|
|
|
switch (TREE_CODE (chrec))
|
|
|
|
|
{
|
|
|
|
|
case SSA_NAME:
|
|
|
|
|
def_bb = bb_for_stmt (SSA_NAME_DEF_STMT (chrec));
|
|
|
|
|
|
|
|
|
|
/* A parameter (or loop invariant and we do not want to include
|
|
|
|
|
evolutions in outer loops), nothing to do. */
|
|
|
|
|
if (!def_bb
|
2005-09-20 09:09:20 +02:00
|
|
|
|
|| (!(flags & INSERT_SUPERLOOP_CHRECS)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
&& !flow_bb_inside_loop_p (loop, def_bb)))
|
|
|
|
|
return chrec;
|
|
|
|
|
|
2005-01-09 09:22:10 +01:00
|
|
|
|
/* We cache the value of instantiated variable to avoid exponential
|
|
|
|
|
time complexity due to reevaluations. We also store the convenient
|
|
|
|
|
value in the cache in order to prevent infinite recursion -- we do
|
|
|
|
|
not want to instantiate the SSA_NAME if it is in a mixer
|
2004-07-12 21:31:16 +02:00
|
|
|
|
structure. This is used for avoiding the instantiation of
|
|
|
|
|
recursively defined functions, such as:
|
|
|
|
|
|
|
|
|
|
| a_2 -> {0, +, 1, +, a_2}_1 */
|
2005-01-09 09:22:10 +01:00
|
|
|
|
|
|
|
|
|
res = get_instantiated_value (cache, chrec);
|
|
|
|
|
if (res)
|
|
|
|
|
return res;
|
|
|
|
|
|
|
|
|
|
/* Store the convenient value for chrec in the structure. If it
|
|
|
|
|
is defined outside of the loop, we may just leave it in symbolic
|
|
|
|
|
form, otherwise we need to admit that we do not know its behavior
|
|
|
|
|
inside the loop. */
|
|
|
|
|
res = !flow_bb_inside_loop_p (loop, def_bb) ? chrec : chrec_dont_know;
|
|
|
|
|
set_instantiated_value (cache, chrec, res);
|
|
|
|
|
|
|
|
|
|
/* To make things even more complicated, instantiate_parameters_1
|
|
|
|
|
calls analyze_scalar_evolution that may call # of iterations
|
|
|
|
|
analysis that may in turn call instantiate_parameters_1 again.
|
|
|
|
|
To prevent the infinite recursion, keep also the bitmap of
|
|
|
|
|
ssa names that are being instantiated globally. */
|
2004-07-12 21:31:16 +02:00
|
|
|
|
if (bitmap_bit_p (already_instantiated, SSA_NAME_VERSION (chrec)))
|
2005-01-09 09:22:10 +01:00
|
|
|
|
return res;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
def_loop = find_common_loop (loop, def_bb->loop_father);
|
|
|
|
|
|
|
|
|
|
/* If the analysis yields a parametric chrec, instantiate the
|
2005-01-09 09:22:10 +01:00
|
|
|
|
result again. */
|
2004-07-12 21:31:16 +02:00
|
|
|
|
bitmap_set_bit (already_instantiated, SSA_NAME_VERSION (chrec));
|
|
|
|
|
res = analyze_scalar_evolution (def_loop, chrec);
|
2005-09-09 12:56:41 +02:00
|
|
|
|
|
|
|
|
|
/* Don't instantiate loop-closed-ssa phi nodes. */
|
|
|
|
|
if (TREE_CODE (res) == SSA_NAME
|
|
|
|
|
&& (loop_containing_stmt (SSA_NAME_DEF_STMT (res)) == NULL
|
|
|
|
|
|| (loop_containing_stmt (SSA_NAME_DEF_STMT (res))->depth
|
|
|
|
|
> def_loop->depth)))
|
|
|
|
|
{
|
|
|
|
|
if (res == chrec)
|
|
|
|
|
res = loop_closed_phi_def (chrec);
|
|
|
|
|
else
|
|
|
|
|
res = chrec;
|
|
|
|
|
|
|
|
|
|
if (res == NULL_TREE)
|
|
|
|
|
res = chrec_dont_know;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (res != chrec_dont_know)
|
2005-11-04 20:10:04 +01:00
|
|
|
|
res = instantiate_parameters_1 (loop, res, flags, cache, size_expr);
|
2005-09-09 12:56:41 +02:00
|
|
|
|
|
2004-07-12 21:31:16 +02:00
|
|
|
|
bitmap_clear_bit (already_instantiated, SSA_NAME_VERSION (chrec));
|
2005-01-09 09:22:10 +01:00
|
|
|
|
|
|
|
|
|
/* Store the correct value to the cache. */
|
|
|
|
|
set_instantiated_value (cache, chrec, res);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
return res;
|
|
|
|
|
|
|
|
|
|
case POLYNOMIAL_CHREC:
|
|
|
|
|
op0 = instantiate_parameters_1 (loop, CHREC_LEFT (chrec),
|
2005-11-04 20:10:04 +01:00
|
|
|
|
flags, cache, size_expr);
|
2005-03-30 14:14:49 +02:00
|
|
|
|
if (op0 == chrec_dont_know)
|
|
|
|
|
return chrec_dont_know;
|
|
|
|
|
|
2004-07-12 21:31:16 +02:00
|
|
|
|
op1 = instantiate_parameters_1 (loop, CHREC_RIGHT (chrec),
|
2005-11-04 20:10:04 +01:00
|
|
|
|
flags, cache, size_expr);
|
2005-03-30 14:14:49 +02:00
|
|
|
|
if (op1 == chrec_dont_know)
|
|
|
|
|
return chrec_dont_know;
|
|
|
|
|
|
2004-12-31 19:03:28 +01:00
|
|
|
|
if (CHREC_LEFT (chrec) != op0
|
|
|
|
|
|| CHREC_RIGHT (chrec) != op1)
|
|
|
|
|
chrec = build_polynomial_chrec (CHREC_VARIABLE (chrec), op0, op1);
|
|
|
|
|
return chrec;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
case PLUS_EXPR:
|
|
|
|
|
op0 = instantiate_parameters_1 (loop, TREE_OPERAND (chrec, 0),
|
2005-11-04 20:10:04 +01:00
|
|
|
|
flags, cache, size_expr);
|
2005-03-30 14:14:49 +02:00
|
|
|
|
if (op0 == chrec_dont_know)
|
|
|
|
|
return chrec_dont_know;
|
|
|
|
|
|
2004-07-12 21:31:16 +02:00
|
|
|
|
op1 = instantiate_parameters_1 (loop, TREE_OPERAND (chrec, 1),
|
2005-11-04 20:10:04 +01:00
|
|
|
|
flags, cache, size_expr);
|
2005-03-30 14:14:49 +02:00
|
|
|
|
if (op1 == chrec_dont_know)
|
|
|
|
|
return chrec_dont_know;
|
|
|
|
|
|
2004-12-31 19:03:28 +01:00
|
|
|
|
if (TREE_OPERAND (chrec, 0) != op0
|
|
|
|
|
|| TREE_OPERAND (chrec, 1) != op1)
|
|
|
|
|
chrec = chrec_fold_plus (TREE_TYPE (chrec), op0, op1);
|
|
|
|
|
return chrec;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
case MINUS_EXPR:
|
|
|
|
|
op0 = instantiate_parameters_1 (loop, TREE_OPERAND (chrec, 0),
|
2005-11-04 20:10:04 +01:00
|
|
|
|
flags, cache, size_expr);
|
2005-03-30 14:14:49 +02:00
|
|
|
|
if (op0 == chrec_dont_know)
|
|
|
|
|
return chrec_dont_know;
|
|
|
|
|
|
2004-07-12 21:31:16 +02:00
|
|
|
|
op1 = instantiate_parameters_1 (loop, TREE_OPERAND (chrec, 1),
|
2005-11-04 20:10:04 +01:00
|
|
|
|
flags, cache, size_expr);
|
2005-03-30 14:14:49 +02:00
|
|
|
|
if (op1 == chrec_dont_know)
|
|
|
|
|
return chrec_dont_know;
|
|
|
|
|
|
2004-12-31 19:03:28 +01:00
|
|
|
|
if (TREE_OPERAND (chrec, 0) != op0
|
|
|
|
|
|| TREE_OPERAND (chrec, 1) != op1)
|
|
|
|
|
chrec = chrec_fold_minus (TREE_TYPE (chrec), op0, op1);
|
|
|
|
|
return chrec;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
case MULT_EXPR:
|
|
|
|
|
op0 = instantiate_parameters_1 (loop, TREE_OPERAND (chrec, 0),
|
2005-11-04 20:10:04 +01:00
|
|
|
|
flags, cache, size_expr);
|
2005-03-30 14:14:49 +02:00
|
|
|
|
if (op0 == chrec_dont_know)
|
|
|
|
|
return chrec_dont_know;
|
|
|
|
|
|
2004-07-12 21:31:16 +02:00
|
|
|
|
op1 = instantiate_parameters_1 (loop, TREE_OPERAND (chrec, 1),
|
2005-11-04 20:10:04 +01:00
|
|
|
|
flags, cache, size_expr);
|
2005-03-30 14:14:49 +02:00
|
|
|
|
if (op1 == chrec_dont_know)
|
|
|
|
|
return chrec_dont_know;
|
|
|
|
|
|
2004-12-31 19:03:28 +01:00
|
|
|
|
if (TREE_OPERAND (chrec, 0) != op0
|
|
|
|
|
|| TREE_OPERAND (chrec, 1) != op1)
|
|
|
|
|
chrec = chrec_fold_multiply (TREE_TYPE (chrec), op0, op1);
|
|
|
|
|
return chrec;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
case NOP_EXPR:
|
|
|
|
|
case CONVERT_EXPR:
|
|
|
|
|
case NON_LVALUE_EXPR:
|
|
|
|
|
op0 = instantiate_parameters_1 (loop, TREE_OPERAND (chrec, 0),
|
2005-11-04 20:10:04 +01:00
|
|
|
|
flags, cache, size_expr);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
if (op0 == chrec_dont_know)
|
|
|
|
|
return chrec_dont_know;
|
|
|
|
|
|
2005-09-20 09:09:20 +02:00
|
|
|
|
if (flags & FOLD_CONVERSIONS)
|
|
|
|
|
{
|
|
|
|
|
tree tmp = chrec_convert_aggressive (TREE_TYPE (chrec), op0);
|
|
|
|
|
if (tmp)
|
|
|
|
|
return tmp;
|
|
|
|
|
}
|
|
|
|
|
|
2004-12-31 19:03:28 +01:00
|
|
|
|
if (op0 == TREE_OPERAND (chrec, 0))
|
|
|
|
|
return chrec;
|
|
|
|
|
|
2005-06-07 21:51:25 +02:00
|
|
|
|
return chrec_convert (TREE_TYPE (chrec), op0, NULL_TREE);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
case SCEV_NOT_KNOWN:
|
|
|
|
|
return chrec_dont_know;
|
|
|
|
|
|
|
|
|
|
case SCEV_KNOWN:
|
|
|
|
|
return chrec_known;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (TREE_CODE_LENGTH (TREE_CODE (chrec)))
|
|
|
|
|
{
|
|
|
|
|
case 3:
|
|
|
|
|
op0 = instantiate_parameters_1 (loop, TREE_OPERAND (chrec, 0),
|
2005-11-04 20:10:04 +01:00
|
|
|
|
flags, cache, size_expr);
|
2005-03-30 14:14:49 +02:00
|
|
|
|
if (op0 == chrec_dont_know)
|
|
|
|
|
return chrec_dont_know;
|
|
|
|
|
|
2004-07-12 21:31:16 +02:00
|
|
|
|
op1 = instantiate_parameters_1 (loop, TREE_OPERAND (chrec, 1),
|
2005-11-04 20:10:04 +01:00
|
|
|
|
flags, cache, size_expr);
|
2005-03-30 14:14:49 +02:00
|
|
|
|
if (op1 == chrec_dont_know)
|
|
|
|
|
return chrec_dont_know;
|
|
|
|
|
|
2004-07-12 21:31:16 +02:00
|
|
|
|
op2 = instantiate_parameters_1 (loop, TREE_OPERAND (chrec, 2),
|
2005-11-04 20:10:04 +01:00
|
|
|
|
flags, cache, size_expr);
|
2005-03-30 14:14:49 +02:00
|
|
|
|
if (op2 == chrec_dont_know)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
return chrec_dont_know;
|
2004-12-31 19:03:28 +01:00
|
|
|
|
|
|
|
|
|
if (op0 == TREE_OPERAND (chrec, 0)
|
|
|
|
|
&& op1 == TREE_OPERAND (chrec, 1)
|
|
|
|
|
&& op2 == TREE_OPERAND (chrec, 2))
|
|
|
|
|
return chrec;
|
|
|
|
|
|
builtins.c, [...]: Use fold_buildN instead of fold (buildN (...)).
* builtins.c, c-common.c, c-convert.c, c-decl.c, c-typeck.c,
convert.c, lambda-code.c, predict.c, tree-cfg.c,
tree-complex.c, tree-data-ref.c, tree-if-conv.c,
tree-mudflap.c, tree-scalar-evolution.c, tree-ssa-ccp.c,
tree-ssa-loop-ivcanon.c, tree-ssa-loop-ivopts.c,
tree-ssa-loop-manip.c, tree-ssa-phiopt.c, tree-ssa-pre.c,
tree-vect-analyze.c, tree-vect-transform.c, tree-vectorizer.c,
tree.c: Use fold_buildN instead of fold (buildN (...)).
From-SVN: r101338
2005-06-26 23:21:34 +02:00
|
|
|
|
return fold_build3 (TREE_CODE (chrec),
|
|
|
|
|
TREE_TYPE (chrec), op0, op1, op2);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
op0 = instantiate_parameters_1 (loop, TREE_OPERAND (chrec, 0),
|
2005-11-04 20:10:04 +01:00
|
|
|
|
flags, cache, size_expr);
|
2005-03-30 14:14:49 +02:00
|
|
|
|
if (op0 == chrec_dont_know)
|
|
|
|
|
return chrec_dont_know;
|
|
|
|
|
|
2004-07-12 21:31:16 +02:00
|
|
|
|
op1 = instantiate_parameters_1 (loop, TREE_OPERAND (chrec, 1),
|
2005-11-04 20:10:04 +01:00
|
|
|
|
flags, cache, size_expr);
|
2005-03-30 14:14:49 +02:00
|
|
|
|
if (op1 == chrec_dont_know)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
return chrec_dont_know;
|
2004-12-31 19:03:28 +01:00
|
|
|
|
|
|
|
|
|
if (op0 == TREE_OPERAND (chrec, 0)
|
|
|
|
|
&& op1 == TREE_OPERAND (chrec, 1))
|
|
|
|
|
return chrec;
|
builtins.c, [...]: Use fold_buildN instead of fold (buildN (...)).
* builtins.c, c-common.c, c-convert.c, c-decl.c, c-typeck.c,
convert.c, lambda-code.c, predict.c, tree-cfg.c,
tree-complex.c, tree-data-ref.c, tree-if-conv.c,
tree-mudflap.c, tree-scalar-evolution.c, tree-ssa-ccp.c,
tree-ssa-loop-ivcanon.c, tree-ssa-loop-ivopts.c,
tree-ssa-loop-manip.c, tree-ssa-phiopt.c, tree-ssa-pre.c,
tree-vect-analyze.c, tree-vect-transform.c, tree-vectorizer.c,
tree.c: Use fold_buildN instead of fold (buildN (...)).
From-SVN: r101338
2005-06-26 23:21:34 +02:00
|
|
|
|
return fold_build2 (TREE_CODE (chrec), TREE_TYPE (chrec), op0, op1);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
op0 = instantiate_parameters_1 (loop, TREE_OPERAND (chrec, 0),
|
2005-11-04 20:10:04 +01:00
|
|
|
|
flags, cache, size_expr);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
if (op0 == chrec_dont_know)
|
|
|
|
|
return chrec_dont_know;
|
2004-12-31 19:03:28 +01:00
|
|
|
|
if (op0 == TREE_OPERAND (chrec, 0))
|
|
|
|
|
return chrec;
|
builtins.c, [...]: Use fold_buildN instead of fold (buildN (...)).
* builtins.c, c-common.c, c-convert.c, c-decl.c, c-typeck.c,
convert.c, lambda-code.c, predict.c, tree-cfg.c,
tree-complex.c, tree-data-ref.c, tree-if-conv.c,
tree-mudflap.c, tree-scalar-evolution.c, tree-ssa-ccp.c,
tree-ssa-loop-ivcanon.c, tree-ssa-loop-ivopts.c,
tree-ssa-loop-manip.c, tree-ssa-phiopt.c, tree-ssa-pre.c,
tree-vect-analyze.c, tree-vect-transform.c, tree-vectorizer.c,
tree.c: Use fold_buildN instead of fold (buildN (...)).
From-SVN: r101338
2005-06-26 23:21:34 +02:00
|
|
|
|
return fold_build1 (TREE_CODE (chrec), TREE_TYPE (chrec), op0);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
|
return chrec;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Too complicated to handle. */
|
|
|
|
|
return chrec_dont_know;
|
|
|
|
|
}
|
2004-07-09 05:19:14 +02:00
|
|
|
|
|
|
|
|
|
/* 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
|
2004-07-12 21:31:16 +02:00
|
|
|
|
instantiate_parameters (struct loop *loop,
|
2004-07-09 05:19:14 +02:00
|
|
|
|
tree chrec)
|
|
|
|
|
{
|
2004-07-12 21:31:16 +02:00
|
|
|
|
tree res;
|
2005-01-09 09:22:10 +01:00
|
|
|
|
htab_t cache = htab_create (10, hash_scev_info, eq_scev_info, del_scev_info);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
|
{
|
|
|
|
|
fprintf (dump_file, "(instantiate_parameters \n");
|
|
|
|
|
fprintf (dump_file, " (loop_nb = %d)\n", loop->num);
|
|
|
|
|
fprintf (dump_file, " (chrec = ");
|
|
|
|
|
print_generic_expr (dump_file, chrec, 0);
|
|
|
|
|
fprintf (dump_file, ")\n");
|
|
|
|
|
}
|
|
|
|
|
|
2005-11-04 20:10:04 +01:00
|
|
|
|
res = instantiate_parameters_1 (loop, chrec, INSERT_SUPERLOOP_CHRECS, cache,
|
|
|
|
|
0);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
|
{
|
|
|
|
|
fprintf (dump_file, " (res = ");
|
|
|
|
|
print_generic_expr (dump_file, res, 0);
|
|
|
|
|
fprintf (dump_file, "))\n");
|
|
|
|
|
}
|
2005-01-09 09:22:10 +01:00
|
|
|
|
|
|
|
|
|
htab_delete (cache);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Similar to instantiate_parameters, but does not introduce the
|
2005-09-20 09:09:20 +02:00
|
|
|
|
evolutions in outer loops for LOOP invariants in CHREC, and does not
|
|
|
|
|
care about causing overflows, as long as they do not affect value
|
|
|
|
|
of an expression. */
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
static tree
|
|
|
|
|
resolve_mixers (struct loop *loop, tree chrec)
|
|
|
|
|
{
|
2005-01-09 09:22:10 +01:00
|
|
|
|
htab_t cache = htab_create (10, hash_scev_info, eq_scev_info, del_scev_info);
|
2005-11-04 20:10:04 +01:00
|
|
|
|
tree ret = instantiate_parameters_1 (loop, chrec, FOLD_CONVERSIONS, cache, 0);
|
2005-01-09 09:22:10 +01:00
|
|
|
|
htab_delete (cache);
|
|
|
|
|
return ret;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Entry point for the analysis of the number of iterations pass.
|
|
|
|
|
This function tries to safely approximate the number of iterations
|
|
|
|
|
the loop will run. When this property is not decidable at compile
|
|
|
|
|
time, the result is chrec_dont_know. Otherwise the result is
|
|
|
|
|
a scalar or a symbolic parameter.
|
|
|
|
|
|
|
|
|
|
Example of analysis: suppose that the loop has an exit condition:
|
|
|
|
|
|
|
|
|
|
"if (b > 49) goto end_loop;"
|
|
|
|
|
|
|
|
|
|
and that in a previous analysis we have determined that the
|
|
|
|
|
variable 'b' has an evolution function:
|
|
|
|
|
|
|
|
|
|
"EF = {23, +, 5}_2".
|
|
|
|
|
|
|
|
|
|
When we evaluate the function at the point 5, i.e. the value of the
|
|
|
|
|
variable 'b' after 5 iterations in the loop, we have EF (5) = 48,
|
|
|
|
|
and EF (6) = 53. In this case the value of 'b' on exit is '53' and
|
|
|
|
|
the loop body has been executed 6 times. */
|
|
|
|
|
|
|
|
|
|
tree
|
|
|
|
|
number_of_iterations_in_loop (struct loop *loop)
|
|
|
|
|
{
|
|
|
|
|
tree res, type;
|
|
|
|
|
edge exit;
|
|
|
|
|
struct tree_niter_desc niter_desc;
|
|
|
|
|
|
|
|
|
|
/* Determine whether the number_of_iterations_in_loop has already
|
|
|
|
|
been computed. */
|
|
|
|
|
res = loop->nb_iterations;
|
|
|
|
|
if (res)
|
|
|
|
|
return res;
|
|
|
|
|
res = chrec_dont_know;
|
|
|
|
|
|
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
|
fprintf (dump_file, "(number_of_iterations_in_loop\n");
|
|
|
|
|
|
tree-ssa-loop-ivcanon.c: New file.
* tree-ssa-loop-ivcanon.c: New file.
* tree-ssa-loop-manip.c (create_iv): New function.
* Makefile.in (tree-ssa-loop-ivcanon.o): Add.
(tree-ssa-loop.o, tree-ssa-loop-manip.o): Add SCEV_H dependency.
* cfgloop.c (mark_single_exit_loops): New function.
(verify_loop_structure): Verify single-exit loops.
* cfgloop.h (struct loop): Add single_exit field.
(LOOPS_HAVE_MARKED_SINGLE_EXITS): New constant.
(mark_single_exit_loops): Declare.
(tree_num_loop_insns): Declare.
* cfgloopmanip.c (update_single_exits_after_duplication): New function.
(duplicate_loop_to_header_edge): Use it.
* common.opt (fivcanon): New flag.
* timevar.def (TV_TREE_LOOP_IVCANON, TV_COMPLETE_UNROLL): New timevars.
* tree-cfg.c (tree_find_edge_insert_loc): Return newly created block.
(bsi_commit_edge_inserts_1): Pass null to tree_find_edge_insert_loc.
(bsi_insert_on_edge_immediate): New function.
* tree-flow.h (bsi_insert_on_edge_immediate,
canonicalize_induction_variables, tree_unroll_loops_completely,
create_iv): Declare.
* tree-optimize.c (init_tree_optimization_passes): Add
pass_iv_canon and pass_complete_unroll.
* tree-pass.h (pass_iv_canon, pass_complete_unroll): Declare.
* tree-scalar-evolution.c (get_loop_exit_condition,
get_exit_conditions_rec, number_of_iterations_in_loop,
scev_initialize): Use single_exit information.
* tree-ssa-loop-niter.c (number_of_iterations_cond): Record
missing assumptions.
(loop_niter_by_eval): Return number of iterations as unsigned
int.
* tree-ssa-loop.c (tree_ssa_loop_init): Mark single exit loops.
(tree_ssa_loop_ivcanon, gate_tree_ssa_loop_ivcanon, pass_iv_canon,
tree_complete_unroll, gate_tree_complete_unroll, pass_complete_unroll):
New passes.
(tree_ssa_loop_done): Call free_numbers_of_iterations_estimates.
* tree-ssanames.c (make_ssa_name): Allow creating ssa name before
the defining statement is ready.
* tree-vectorizer.c (vect_create_iv_simple): Removed.
(vect_create_index_for_array_ref, vect_transform_loop_bound):
Use create_iv.
(vect_transform_loop_bound): Use single_exit information.
(vect_analyze_loop_form): Cleanup bogus tests.
(vectorize_loops): Do not call flow_loop_scan.
* tree.h (may_negate_without_overflow_p): Declare.
* fold-const.c (may_negate_without_overflow_p): Split out from ...
(negate_expr_p): ... this function.
(tree_expr_nonzero_p): Handle overflowed constants correctly.
* doc/invoke.texi (-fivcanon): Document.
* doc/passes.texi: Document canonical induction variable creation.
* gcc.dg/tree-ssa/loop-1.c: New test.
From-SVN: r86516
2004-08-24 22:48:23 +02:00
|
|
|
|
exit = loop->single_exit;
|
|
|
|
|
if (!exit)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
goto end;
|
|
|
|
|
|
2005-07-21 09:24:34 +02:00
|
|
|
|
if (!number_of_iterations_exit (loop, exit, &niter_desc, false))
|
2004-07-12 21:31:16 +02:00
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
|
|
type = TREE_TYPE (niter_desc.niter);
|
|
|
|
|
if (integer_nonzerop (niter_desc.may_be_zero))
|
2004-09-07 12:22:44 +02:00
|
|
|
|
res = build_int_cst (type, 0);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
else if (integer_zerop (niter_desc.may_be_zero))
|
|
|
|
|
res = niter_desc.niter;
|
|
|
|
|
else
|
|
|
|
|
res = chrec_dont_know;
|
|
|
|
|
|
|
|
|
|
end:
|
|
|
|
|
return set_nb_iterations_in_loop (loop, res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* One of the drivers for testing the scalar evolutions analysis.
|
|
|
|
|
This function computes the number of iterations for all the loops
|
|
|
|
|
from the EXIT_CONDITIONS array. */
|
|
|
|
|
|
|
|
|
|
static void
|
2005-05-02 10:56:52 +02:00
|
|
|
|
number_of_iterations_for_all_loops (VEC(tree,heap) **exit_conditions)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
{
|
|
|
|
|
unsigned int i;
|
|
|
|
|
unsigned nb_chrec_dont_know_loops = 0;
|
|
|
|
|
unsigned nb_static_loops = 0;
|
2005-05-02 10:56:52 +02:00
|
|
|
|
tree cond;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
2005-05-02 10:56:52 +02:00
|
|
|
|
for (i = 0; VEC_iterate (tree, *exit_conditions, i, cond); i++)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
{
|
2005-05-02 10:56:52 +02:00
|
|
|
|
tree res = number_of_iterations_in_loop (loop_containing_stmt (cond));
|
2004-07-12 21:31:16 +02:00
|
|
|
|
if (chrec_contains_undetermined (res))
|
|
|
|
|
nb_chrec_dont_know_loops++;
|
|
|
|
|
else
|
|
|
|
|
nb_static_loops++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dump_file)
|
|
|
|
|
{
|
|
|
|
|
fprintf (dump_file, "\n(\n");
|
|
|
|
|
fprintf (dump_file, "-----------------------------------------\n");
|
|
|
|
|
fprintf (dump_file, "%d\tnb_chrec_dont_know_loops\n", nb_chrec_dont_know_loops);
|
|
|
|
|
fprintf (dump_file, "%d\tnb_static_loops\n", nb_static_loops);
|
|
|
|
|
fprintf (dump_file, "%d\tnb_total_loops\n", current_loops->num);
|
|
|
|
|
fprintf (dump_file, "-----------------------------------------\n");
|
|
|
|
|
fprintf (dump_file, ")\n\n");
|
|
|
|
|
|
|
|
|
|
print_loop_ir (dump_file);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Counters for the stats. */
|
|
|
|
|
|
|
|
|
|
struct chrec_stats
|
|
|
|
|
{
|
|
|
|
|
unsigned nb_chrecs;
|
|
|
|
|
unsigned nb_affine;
|
|
|
|
|
unsigned nb_affine_multivar;
|
|
|
|
|
unsigned nb_higher_poly;
|
|
|
|
|
unsigned nb_chrec_dont_know;
|
|
|
|
|
unsigned nb_undetermined;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Reset the counters. */
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
reset_chrecs_counters (struct chrec_stats *stats)
|
|
|
|
|
{
|
|
|
|
|
stats->nb_chrecs = 0;
|
|
|
|
|
stats->nb_affine = 0;
|
|
|
|
|
stats->nb_affine_multivar = 0;
|
|
|
|
|
stats->nb_higher_poly = 0;
|
|
|
|
|
stats->nb_chrec_dont_know = 0;
|
|
|
|
|
stats->nb_undetermined = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Dump the contents of a CHREC_STATS structure. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
dump_chrecs_stats (FILE *file, struct chrec_stats *stats)
|
|
|
|
|
{
|
|
|
|
|
fprintf (file, "\n(\n");
|
|
|
|
|
fprintf (file, "-----------------------------------------\n");
|
|
|
|
|
fprintf (file, "%d\taffine univariate chrecs\n", stats->nb_affine);
|
|
|
|
|
fprintf (file, "%d\taffine multivariate chrecs\n", stats->nb_affine_multivar);
|
|
|
|
|
fprintf (file, "%d\tdegree greater than 2 polynomials\n",
|
|
|
|
|
stats->nb_higher_poly);
|
|
|
|
|
fprintf (file, "%d\tchrec_dont_know chrecs\n", stats->nb_chrec_dont_know);
|
|
|
|
|
fprintf (file, "-----------------------------------------\n");
|
|
|
|
|
fprintf (file, "%d\ttotal chrecs\n", stats->nb_chrecs);
|
|
|
|
|
fprintf (file, "%d\twith undetermined coefficients\n",
|
|
|
|
|
stats->nb_undetermined);
|
|
|
|
|
fprintf (file, "-----------------------------------------\n");
|
|
|
|
|
fprintf (file, "%d\tchrecs in the scev database\n",
|
|
|
|
|
(int) htab_elements (scalar_evolution_info));
|
|
|
|
|
fprintf (file, "%d\tsets in the scev database\n", nb_set_scev);
|
|
|
|
|
fprintf (file, "%d\tgets in the scev database\n", nb_get_scev);
|
|
|
|
|
fprintf (file, "-----------------------------------------\n");
|
|
|
|
|
fprintf (file, ")\n\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Gather statistics about CHREC. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gather_chrec_stats (tree chrec, struct chrec_stats *stats)
|
|
|
|
|
{
|
|
|
|
|
if (dump_file && (dump_flags & TDF_STATS))
|
|
|
|
|
{
|
|
|
|
|
fprintf (dump_file, "(classify_chrec ");
|
|
|
|
|
print_generic_expr (dump_file, chrec, 0);
|
|
|
|
|
fprintf (dump_file, "\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stats->nb_chrecs++;
|
|
|
|
|
|
|
|
|
|
if (chrec == NULL_TREE)
|
|
|
|
|
{
|
|
|
|
|
stats->nb_undetermined++;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (TREE_CODE (chrec))
|
|
|
|
|
{
|
|
|
|
|
case POLYNOMIAL_CHREC:
|
|
|
|
|
if (evolution_function_is_affine_p (chrec))
|
|
|
|
|
{
|
|
|
|
|
if (dump_file && (dump_flags & TDF_STATS))
|
|
|
|
|
fprintf (dump_file, " affine_univariate\n");
|
|
|
|
|
stats->nb_affine++;
|
|
|
|
|
}
|
|
|
|
|
else if (evolution_function_is_affine_multivariate_p (chrec))
|
|
|
|
|
{
|
|
|
|
|
if (dump_file && (dump_flags & TDF_STATS))
|
|
|
|
|
fprintf (dump_file, " affine_multivariate\n");
|
|
|
|
|
stats->nb_affine_multivar++;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (dump_file && (dump_flags & TDF_STATS))
|
|
|
|
|
fprintf (dump_file, " higher_degree_polynomial\n");
|
|
|
|
|
stats->nb_higher_poly++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (chrec_contains_undetermined (chrec))
|
|
|
|
|
{
|
|
|
|
|
if (dump_file && (dump_flags & TDF_STATS))
|
|
|
|
|
fprintf (dump_file, " undetermined\n");
|
|
|
|
|
stats->nb_undetermined++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dump_file && (dump_flags & TDF_STATS))
|
|
|
|
|
fprintf (dump_file, ")\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* One of the drivers for testing the scalar evolutions analysis.
|
|
|
|
|
This function analyzes the scalar evolution of all the scalars
|
|
|
|
|
defined as loop phi nodes in one of the loops from the
|
|
|
|
|
EXIT_CONDITIONS array.
|
|
|
|
|
|
|
|
|
|
TODO Optimization: A loop is in canonical form if it contains only
|
|
|
|
|
a single scalar loop phi node. All the other scalars that have an
|
|
|
|
|
evolution in the loop are rewritten in function of this single
|
|
|
|
|
index. This allows the parallelization of the loop. */
|
|
|
|
|
|
|
|
|
|
static void
|
2005-05-02 10:56:52 +02:00
|
|
|
|
analyze_scalar_evolution_for_all_loop_phi_nodes (VEC(tree,heap) **exit_conditions)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
{
|
|
|
|
|
unsigned int i;
|
|
|
|
|
struct chrec_stats stats;
|
2005-05-02 10:56:52 +02:00
|
|
|
|
tree cond;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
reset_chrecs_counters (&stats);
|
|
|
|
|
|
2005-05-02 10:56:52 +02:00
|
|
|
|
for (i = 0; VEC_iterate (tree, *exit_conditions, i, cond); i++)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
{
|
|
|
|
|
struct loop *loop;
|
|
|
|
|
basic_block bb;
|
|
|
|
|
tree phi, chrec;
|
|
|
|
|
|
2005-05-02 10:56:52 +02:00
|
|
|
|
loop = loop_containing_stmt (cond);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
bb = loop->header;
|
|
|
|
|
|
2004-11-08 14:54:41 +01:00
|
|
|
|
for (phi = phi_nodes (bb); phi; phi = PHI_CHAIN (phi))
|
2004-07-12 21:31:16 +02:00
|
|
|
|
if (is_gimple_reg (PHI_RESULT (phi)))
|
|
|
|
|
{
|
|
|
|
|
chrec = instantiate_parameters
|
|
|
|
|
(loop,
|
|
|
|
|
analyze_scalar_evolution (loop, PHI_RESULT (phi)));
|
|
|
|
|
|
|
|
|
|
if (dump_file && (dump_flags & TDF_STATS))
|
|
|
|
|
gather_chrec_stats (chrec, &stats);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dump_file && (dump_flags & TDF_STATS))
|
|
|
|
|
dump_chrecs_stats (dump_file, &stats);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Callback for htab_traverse, gathers information on chrecs in the
|
|
|
|
|
hashtable. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
gather_stats_on_scev_database_1 (void **slot, void *stats)
|
|
|
|
|
{
|
|
|
|
|
struct scev_info_str *entry = *slot;
|
|
|
|
|
|
|
|
|
|
gather_chrec_stats (entry->chrec, stats);
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Classify the chrecs of the whole database. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gather_stats_on_scev_database (void)
|
|
|
|
|
{
|
|
|
|
|
struct chrec_stats stats;
|
|
|
|
|
|
|
|
|
|
if (!dump_file)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
reset_chrecs_counters (&stats);
|
|
|
|
|
|
|
|
|
|
htab_traverse (scalar_evolution_info, gather_stats_on_scev_database_1,
|
|
|
|
|
&stats);
|
|
|
|
|
|
|
|
|
|
dump_chrecs_stats (dump_file, &stats);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Initializer. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
initialize_scalar_evolutions_analyzer (void)
|
|
|
|
|
{
|
|
|
|
|
/* The elements below are unique. */
|
|
|
|
|
if (chrec_dont_know == NULL_TREE)
|
|
|
|
|
{
|
|
|
|
|
chrec_not_analyzed_yet = NULL_TREE;
|
|
|
|
|
chrec_dont_know = make_node (SCEV_NOT_KNOWN);
|
|
|
|
|
chrec_known = make_node (SCEV_KNOWN);
|
2005-06-05 20:07:43 +02:00
|
|
|
|
TREE_TYPE (chrec_dont_know) = void_type_node;
|
|
|
|
|
TREE_TYPE (chrec_known) = void_type_node;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Initialize the analysis of scalar evolutions for LOOPS. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
scev_initialize (struct loops *loops)
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
current_loops = loops;
|
|
|
|
|
|
|
|
|
|
scalar_evolution_info = htab_create (100, hash_scev_info,
|
|
|
|
|
eq_scev_info, del_scev_info);
|
bitmap.h (BITMAP_XMALLOC, [...]): Remove.
* bitmap.h (BITMAP_XMALLOC, BITMAP_XFREE): Remove.
* bb-reorder.c (duplicate_computed_gotos): Use BITMAP_ALLOC and
BITMAP_FREE.
* bt-load.c (btr_def_live_range, combine_btr_defs,
migrate_btr_def, migrate_btr_defs): Likewise.
* cfgcleanup.c (thread_jump): Likewise.
* cfgloop.c (get_loop_body_in_bfs_order): Likewise.
* df.c (df_insn_table_realloc, df_bitmaps_alloc, df_bitmaps_free,
df_alloc, df_free, df_du_chain_create, df_bb_rd_local_compute,
df_rd_local_compute, df_reg_info_compute): Likewise.
* dominance.c (init_dom_info, free_dom_info): Likewise.
* flow.c (init_propagate_block_info,
free_propagate_block_info): Likewise.
* gcse.c (alloc_gcse_mem, free_gcse_mem): Likewise.
* global.c (allocate_bb_info, free_bb_info, calculate_reg_pav,
modify_reg_pav): Likewise.
* loop-invariant.c (find_defs, find_invariant_insn,
find_invariants, free_inv_motion_data): Likewise.
* predict.c (tree_predict_by_opcode,
estimate_bb_frequencies): Likewise.
* stmt.c (expand_case): Likewise.
* tree-cfg.c (tree_duplicate_sese_region): Likewise.
* tree-dfa.c (mark_new_vars_to_rename): Likewise.
* tree-if-conv.c (get_loop_body_in_if_conv_order): Likewise.
* tree-into-ssa.c (insert_phi_nodes_for, def_blocks_free,
get_def_blocks_for, mark_def_site_blocks, rewrite_into_ssa,
rewrite_ssa_into_ssa): Likewise.
* tree-optimize.c (tree_rest_of_compilation): Likewise.
* tree-outof-ssa.c (new_temp_expr_table, free_temp_expr_table,
analyze_edges_for_bb, perform_edge_inserts): Likewise.
* tree-scalar-evolution.c (scev_initialize, scev_finalize): Likewise.
* tree-sra.c (tree_sra): Likewise.
* tree-ssa-alias.c (init_alias_info, delete_alias_info): Likewise.
* tree-ssa-ccp.c (ccp_fold_builtin): Likewise.
* tree-ssa-dce.c (tree_dce_init, tree_dce_done): Likewise.
* tree-ssa-dom.c (tree_ssa_dominator_optimize): Likewise.
* tree-ssa-dse.c (tree_ssa_dse): Likewise.
* tree-ssa-forwprop.c (tree_ssa_forward_propagate_single_use_var):
Likewise.
* tree-ssa-live.c (new_tree_live_info, delete_tree_live_info,
calculate_live_on_entry, calculate_live_on_exit,
build_tree_conflict_graph): Likewise.
* tree-ssa-loop-ivopts.c (tree_ssa_iv_optimize_init, record_use,
record_important_candidates, set_use_iv_cost, find_depends,
determine_use_iv_costs, iv_ca_new, iv_ca_free, free_loop_data,
tree_ssa_iv_optimize_finalize): Likewise.
* tree-ssa-loop-manip.c (add_exit_phis_var, get_loops_exit,
find_uses_to_rename_use, rewrite_into_loop_closed_ssa,
tree_duplicate_loop_to_header_edge): Likewise.
* tree-ssa-pre.c (init_pre, fini_pre): Likewise.
* tree-ssa.c (verify_flow_insensitive_alias_info,
verify_name_tags, verify_ssa, init_tree_ssa,
delete_tree_ssa): Likewise.
* tree-ssanames.c (marked_ssa_names, init_ssanames,
fini_ssanames): Likewise.
* tree-vectorizer.c (slpeel_tree_peel_loop_to_edge): Likewise.
From-SVN: r95172
2005-02-17 17:19:49 +01:00
|
|
|
|
already_instantiated = BITMAP_ALLOC (NULL);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
initialize_scalar_evolutions_analyzer ();
|
|
|
|
|
|
|
|
|
|
for (i = 1; i < loops->num; i++)
|
|
|
|
|
if (loops->parray[i])
|
tree-ssa-loop-ivcanon.c: New file.
* tree-ssa-loop-ivcanon.c: New file.
* tree-ssa-loop-manip.c (create_iv): New function.
* Makefile.in (tree-ssa-loop-ivcanon.o): Add.
(tree-ssa-loop.o, tree-ssa-loop-manip.o): Add SCEV_H dependency.
* cfgloop.c (mark_single_exit_loops): New function.
(verify_loop_structure): Verify single-exit loops.
* cfgloop.h (struct loop): Add single_exit field.
(LOOPS_HAVE_MARKED_SINGLE_EXITS): New constant.
(mark_single_exit_loops): Declare.
(tree_num_loop_insns): Declare.
* cfgloopmanip.c (update_single_exits_after_duplication): New function.
(duplicate_loop_to_header_edge): Use it.
* common.opt (fivcanon): New flag.
* timevar.def (TV_TREE_LOOP_IVCANON, TV_COMPLETE_UNROLL): New timevars.
* tree-cfg.c (tree_find_edge_insert_loc): Return newly created block.
(bsi_commit_edge_inserts_1): Pass null to tree_find_edge_insert_loc.
(bsi_insert_on_edge_immediate): New function.
* tree-flow.h (bsi_insert_on_edge_immediate,
canonicalize_induction_variables, tree_unroll_loops_completely,
create_iv): Declare.
* tree-optimize.c (init_tree_optimization_passes): Add
pass_iv_canon and pass_complete_unroll.
* tree-pass.h (pass_iv_canon, pass_complete_unroll): Declare.
* tree-scalar-evolution.c (get_loop_exit_condition,
get_exit_conditions_rec, number_of_iterations_in_loop,
scev_initialize): Use single_exit information.
* tree-ssa-loop-niter.c (number_of_iterations_cond): Record
missing assumptions.
(loop_niter_by_eval): Return number of iterations as unsigned
int.
* tree-ssa-loop.c (tree_ssa_loop_init): Mark single exit loops.
(tree_ssa_loop_ivcanon, gate_tree_ssa_loop_ivcanon, pass_iv_canon,
tree_complete_unroll, gate_tree_complete_unroll, pass_complete_unroll):
New passes.
(tree_ssa_loop_done): Call free_numbers_of_iterations_estimates.
* tree-ssanames.c (make_ssa_name): Allow creating ssa name before
the defining statement is ready.
* tree-vectorizer.c (vect_create_iv_simple): Removed.
(vect_create_index_for_array_ref, vect_transform_loop_bound):
Use create_iv.
(vect_transform_loop_bound): Use single_exit information.
(vect_analyze_loop_form): Cleanup bogus tests.
(vectorize_loops): Do not call flow_loop_scan.
* tree.h (may_negate_without_overflow_p): Declare.
* fold-const.c (may_negate_without_overflow_p): Split out from ...
(negate_expr_p): ... this function.
(tree_expr_nonzero_p): Handle overflowed constants correctly.
* doc/invoke.texi (-fivcanon): Document.
* doc/passes.texi: Document canonical induction variable creation.
* gcc.dg/tree-ssa/loop-1.c: New test.
From-SVN: r86516
2004-08-24 22:48:23 +02:00
|
|
|
|
loops->parray[i]->nb_iterations = NULL_TREE;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Cleans up the information cached by the scalar evolutions analysis. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
scev_reset (void)
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
struct loop *loop;
|
|
|
|
|
|
|
|
|
|
if (!scalar_evolution_info || !current_loops)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
htab_empty (scalar_evolution_info);
|
|
|
|
|
for (i = 1; i < current_loops->num; i++)
|
|
|
|
|
{
|
|
|
|
|
loop = current_loops->parray[i];
|
|
|
|
|
if (loop)
|
|
|
|
|
loop->nb_iterations = NULL_TREE;
|
|
|
|
|
}
|
2004-07-09 05:19:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Checks whether OP behaves as a simple affine iv of LOOP in STMT and returns
|
re PR tree-optimization/18316 (Missed IV optimization)
PR tree-optimization/18316
PR tree-optimization/19126
* tree.c (build_int_cst_type): Avoid shift by size of type.
* tree-scalar-evolution.c (simple_iv): Add allow_nonconstant_step
argument.
* tree-scalar-evolution.h (simple_iv): Declaration changed.
* tree-ssa-loop-ivopts.c (struct iv_cand): Add depends_on
field.
(dump_cand): Dump depends_on information.
(determine_biv_step): Add argument to simple_iv call.
(contains_abnormal_ssa_name_p): Handle case expr == NULL.
(find_bivs, find_givs_in_stmt_scev): Do not require step to be a
constant.
(add_candidate_1): Record depends_on for candidates.
(tree_int_cst_sign_bit, constant_multiple_of): New functions.
(get_computation_at, get_computation_cost_at, may_eliminate_iv):
Handle ivs with nonconstant step.
(iv_ca_set_remove_invariants, iv_ca_set_add_invariants): New functions.
(iv_ca_set_no_cp, iv_ca_set_cp): Handle cand->depends_on.
(create_new_iv): Unshare the step before passing it to create_iv.
(free_loop_data): Free cand->depends_on.
(build_addr_strip_iref): New function.
(find_interesting_uses_address): Use build_addr_strip_iref.
(strip_offset_1): Split the recursive part from strip_offset.
Strip constant offset component_refs and array_refs.
(strip_offset): Split the recursive part to strip_offset_1.
(add_address_candidates): Removed.
(add_derived_ivs_candidates): Do not use add_address_candidates.
(add_iv_value_candidates): Add candidates with stripped constant
offset. Consider all candidates with initial value 0 important.
(struct affine_tree_combination): New.
(aff_combination_const, aff_combination_elt, aff_combination_scale,
aff_combination_add_elt, aff_combination_add,
tree_to_aff_combination, add_elt_to_tree, aff_combination_to_tree,
fold_affine_sum): New functions.
(get_computation_at): Use fold_affine_sum.
* tree-ssa-loop-manip.c (create_iv): Handle ivs with nonconstant step.
* tree-ssa-loop-niter.c (number_of_iterations_exit): Add argument
to simple_iv call.
* gcc.dg/tree-ssa/loop-8.c: New test.
From-SVN: r99059
2005-05-01 10:08:14 +02:00
|
|
|
|
its BASE and STEP if possible. If ALLOW_NONCONSTANT_STEP is true, we
|
|
|
|
|
want STEP to be invariant in LOOP. Otherwise we require it to be an
|
|
|
|
|
integer constant. */
|
2004-07-09 05:19:14 +02:00
|
|
|
|
|
|
|
|
|
bool
|
re PR tree-optimization/18316 (Missed IV optimization)
PR tree-optimization/18316
PR tree-optimization/19126
* tree.c (build_int_cst_type): Avoid shift by size of type.
* tree-scalar-evolution.c (simple_iv): Add allow_nonconstant_step
argument.
* tree-scalar-evolution.h (simple_iv): Declaration changed.
* tree-ssa-loop-ivopts.c (struct iv_cand): Add depends_on
field.
(dump_cand): Dump depends_on information.
(determine_biv_step): Add argument to simple_iv call.
(contains_abnormal_ssa_name_p): Handle case expr == NULL.
(find_bivs, find_givs_in_stmt_scev): Do not require step to be a
constant.
(add_candidate_1): Record depends_on for candidates.
(tree_int_cst_sign_bit, constant_multiple_of): New functions.
(get_computation_at, get_computation_cost_at, may_eliminate_iv):
Handle ivs with nonconstant step.
(iv_ca_set_remove_invariants, iv_ca_set_add_invariants): New functions.
(iv_ca_set_no_cp, iv_ca_set_cp): Handle cand->depends_on.
(create_new_iv): Unshare the step before passing it to create_iv.
(free_loop_data): Free cand->depends_on.
(build_addr_strip_iref): New function.
(find_interesting_uses_address): Use build_addr_strip_iref.
(strip_offset_1): Split the recursive part from strip_offset.
Strip constant offset component_refs and array_refs.
(strip_offset): Split the recursive part to strip_offset_1.
(add_address_candidates): Removed.
(add_derived_ivs_candidates): Do not use add_address_candidates.
(add_iv_value_candidates): Add candidates with stripped constant
offset. Consider all candidates with initial value 0 important.
(struct affine_tree_combination): New.
(aff_combination_const, aff_combination_elt, aff_combination_scale,
aff_combination_add_elt, aff_combination_add,
tree_to_aff_combination, add_elt_to_tree, aff_combination_to_tree,
fold_affine_sum): New functions.
(get_computation_at): Use fold_affine_sum.
* tree-ssa-loop-manip.c (create_iv): Handle ivs with nonconstant step.
* tree-ssa-loop-niter.c (number_of_iterations_exit): Add argument
to simple_iv call.
* gcc.dg/tree-ssa/loop-8.c: New test.
From-SVN: r99059
2005-05-01 10:08:14 +02:00
|
|
|
|
simple_iv (struct loop *loop, tree stmt, tree op, tree *base, tree *step,
|
|
|
|
|
bool allow_nonconstant_step)
|
2004-07-09 05:19:14 +02:00
|
|
|
|
{
|
2004-07-12 21:31:16 +02:00
|
|
|
|
basic_block bb = bb_for_stmt (stmt);
|
|
|
|
|
tree type, ev;
|
|
|
|
|
|
|
|
|
|
*base = NULL_TREE;
|
|
|
|
|
*step = NULL_TREE;
|
|
|
|
|
|
|
|
|
|
type = TREE_TYPE (op);
|
|
|
|
|
if (TREE_CODE (type) != INTEGER_TYPE
|
|
|
|
|
&& TREE_CODE (type) != POINTER_TYPE)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
ev = analyze_scalar_evolution_in_loop (loop, bb->loop_father, op);
|
|
|
|
|
if (chrec_contains_undetermined (ev))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (tree_does_not_contain_chrecs (ev)
|
|
|
|
|
&& !chrec_contains_symbols_defined_in_loop (ev, loop->num))
|
|
|
|
|
{
|
|
|
|
|
*base = ev;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (ev) != POLYNOMIAL_CHREC
|
|
|
|
|
|| CHREC_VARIABLE (ev) != (unsigned) loop->num)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
*step = CHREC_RIGHT (ev);
|
re PR tree-optimization/18316 (Missed IV optimization)
PR tree-optimization/18316
PR tree-optimization/19126
* tree.c (build_int_cst_type): Avoid shift by size of type.
* tree-scalar-evolution.c (simple_iv): Add allow_nonconstant_step
argument.
* tree-scalar-evolution.h (simple_iv): Declaration changed.
* tree-ssa-loop-ivopts.c (struct iv_cand): Add depends_on
field.
(dump_cand): Dump depends_on information.
(determine_biv_step): Add argument to simple_iv call.
(contains_abnormal_ssa_name_p): Handle case expr == NULL.
(find_bivs, find_givs_in_stmt_scev): Do not require step to be a
constant.
(add_candidate_1): Record depends_on for candidates.
(tree_int_cst_sign_bit, constant_multiple_of): New functions.
(get_computation_at, get_computation_cost_at, may_eliminate_iv):
Handle ivs with nonconstant step.
(iv_ca_set_remove_invariants, iv_ca_set_add_invariants): New functions.
(iv_ca_set_no_cp, iv_ca_set_cp): Handle cand->depends_on.
(create_new_iv): Unshare the step before passing it to create_iv.
(free_loop_data): Free cand->depends_on.
(build_addr_strip_iref): New function.
(find_interesting_uses_address): Use build_addr_strip_iref.
(strip_offset_1): Split the recursive part from strip_offset.
Strip constant offset component_refs and array_refs.
(strip_offset): Split the recursive part to strip_offset_1.
(add_address_candidates): Removed.
(add_derived_ivs_candidates): Do not use add_address_candidates.
(add_iv_value_candidates): Add candidates with stripped constant
offset. Consider all candidates with initial value 0 important.
(struct affine_tree_combination): New.
(aff_combination_const, aff_combination_elt, aff_combination_scale,
aff_combination_add_elt, aff_combination_add,
tree_to_aff_combination, add_elt_to_tree, aff_combination_to_tree,
fold_affine_sum): New functions.
(get_computation_at): Use fold_affine_sum.
* tree-ssa-loop-manip.c (create_iv): Handle ivs with nonconstant step.
* tree-ssa-loop-niter.c (number_of_iterations_exit): Add argument
to simple_iv call.
* gcc.dg/tree-ssa/loop-8.c: New test.
From-SVN: r99059
2005-05-01 10:08:14 +02:00
|
|
|
|
if (allow_nonconstant_step)
|
|
|
|
|
{
|
|
|
|
|
if (tree_contains_chrecs (*step, NULL)
|
|
|
|
|
|| chrec_contains_symbols_defined_in_loop (*step, loop->num))
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else if (TREE_CODE (*step) != INTEGER_CST)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
return false;
|
re PR tree-optimization/18316 (Missed IV optimization)
PR tree-optimization/18316
PR tree-optimization/19126
* tree.c (build_int_cst_type): Avoid shift by size of type.
* tree-scalar-evolution.c (simple_iv): Add allow_nonconstant_step
argument.
* tree-scalar-evolution.h (simple_iv): Declaration changed.
* tree-ssa-loop-ivopts.c (struct iv_cand): Add depends_on
field.
(dump_cand): Dump depends_on information.
(determine_biv_step): Add argument to simple_iv call.
(contains_abnormal_ssa_name_p): Handle case expr == NULL.
(find_bivs, find_givs_in_stmt_scev): Do not require step to be a
constant.
(add_candidate_1): Record depends_on for candidates.
(tree_int_cst_sign_bit, constant_multiple_of): New functions.
(get_computation_at, get_computation_cost_at, may_eliminate_iv):
Handle ivs with nonconstant step.
(iv_ca_set_remove_invariants, iv_ca_set_add_invariants): New functions.
(iv_ca_set_no_cp, iv_ca_set_cp): Handle cand->depends_on.
(create_new_iv): Unshare the step before passing it to create_iv.
(free_loop_data): Free cand->depends_on.
(build_addr_strip_iref): New function.
(find_interesting_uses_address): Use build_addr_strip_iref.
(strip_offset_1): Split the recursive part from strip_offset.
Strip constant offset component_refs and array_refs.
(strip_offset): Split the recursive part to strip_offset_1.
(add_address_candidates): Removed.
(add_derived_ivs_candidates): Do not use add_address_candidates.
(add_iv_value_candidates): Add candidates with stripped constant
offset. Consider all candidates with initial value 0 important.
(struct affine_tree_combination): New.
(aff_combination_const, aff_combination_elt, aff_combination_scale,
aff_combination_add_elt, aff_combination_add,
tree_to_aff_combination, add_elt_to_tree, aff_combination_to_tree,
fold_affine_sum): New functions.
(get_computation_at): Use fold_affine_sum.
* tree-ssa-loop-manip.c (create_iv): Handle ivs with nonconstant step.
* tree-ssa-loop-niter.c (number_of_iterations_exit): Add argument
to simple_iv call.
* gcc.dg/tree-ssa/loop-8.c: New test.
From-SVN: r99059
2005-05-01 10:08:14 +02:00
|
|
|
|
|
2004-07-12 21:31:16 +02:00
|
|
|
|
*base = CHREC_LEFT (ev);
|
2005-04-21 10:48:55 +02:00
|
|
|
|
if (tree_contains_chrecs (*base, NULL)
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|| chrec_contains_symbols_defined_in_loop (*base, loop->num))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Runs the analysis of scalar evolutions. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
scev_analysis (void)
|
|
|
|
|
{
|
2005-05-02 10:56:52 +02:00
|
|
|
|
VEC(tree,heap) *exit_conditions;
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
2005-05-02 10:56:52 +02:00
|
|
|
|
exit_conditions = VEC_alloc (tree, heap, 37);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
select_loops_exit_conditions (current_loops, &exit_conditions);
|
|
|
|
|
|
|
|
|
|
if (dump_file && (dump_flags & TDF_STATS))
|
2005-05-02 10:56:52 +02:00
|
|
|
|
analyze_scalar_evolution_for_all_loop_phi_nodes (&exit_conditions);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
2005-05-02 10:56:52 +02:00
|
|
|
|
number_of_iterations_for_all_loops (&exit_conditions);
|
|
|
|
|
VEC_free (tree, heap, exit_conditions);
|
2004-07-09 05:19:14 +02:00
|
|
|
|
}
|
2004-07-12 21:31:16 +02:00
|
|
|
|
|
|
|
|
|
/* Finalize the scalar evolution analysis. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
scev_finalize (void)
|
|
|
|
|
{
|
|
|
|
|
htab_delete (scalar_evolution_info);
|
bitmap.h (BITMAP_XMALLOC, [...]): Remove.
* bitmap.h (BITMAP_XMALLOC, BITMAP_XFREE): Remove.
* bb-reorder.c (duplicate_computed_gotos): Use BITMAP_ALLOC and
BITMAP_FREE.
* bt-load.c (btr_def_live_range, combine_btr_defs,
migrate_btr_def, migrate_btr_defs): Likewise.
* cfgcleanup.c (thread_jump): Likewise.
* cfgloop.c (get_loop_body_in_bfs_order): Likewise.
* df.c (df_insn_table_realloc, df_bitmaps_alloc, df_bitmaps_free,
df_alloc, df_free, df_du_chain_create, df_bb_rd_local_compute,
df_rd_local_compute, df_reg_info_compute): Likewise.
* dominance.c (init_dom_info, free_dom_info): Likewise.
* flow.c (init_propagate_block_info,
free_propagate_block_info): Likewise.
* gcse.c (alloc_gcse_mem, free_gcse_mem): Likewise.
* global.c (allocate_bb_info, free_bb_info, calculate_reg_pav,
modify_reg_pav): Likewise.
* loop-invariant.c (find_defs, find_invariant_insn,
find_invariants, free_inv_motion_data): Likewise.
* predict.c (tree_predict_by_opcode,
estimate_bb_frequencies): Likewise.
* stmt.c (expand_case): Likewise.
* tree-cfg.c (tree_duplicate_sese_region): Likewise.
* tree-dfa.c (mark_new_vars_to_rename): Likewise.
* tree-if-conv.c (get_loop_body_in_if_conv_order): Likewise.
* tree-into-ssa.c (insert_phi_nodes_for, def_blocks_free,
get_def_blocks_for, mark_def_site_blocks, rewrite_into_ssa,
rewrite_ssa_into_ssa): Likewise.
* tree-optimize.c (tree_rest_of_compilation): Likewise.
* tree-outof-ssa.c (new_temp_expr_table, free_temp_expr_table,
analyze_edges_for_bb, perform_edge_inserts): Likewise.
* tree-scalar-evolution.c (scev_initialize, scev_finalize): Likewise.
* tree-sra.c (tree_sra): Likewise.
* tree-ssa-alias.c (init_alias_info, delete_alias_info): Likewise.
* tree-ssa-ccp.c (ccp_fold_builtin): Likewise.
* tree-ssa-dce.c (tree_dce_init, tree_dce_done): Likewise.
* tree-ssa-dom.c (tree_ssa_dominator_optimize): Likewise.
* tree-ssa-dse.c (tree_ssa_dse): Likewise.
* tree-ssa-forwprop.c (tree_ssa_forward_propagate_single_use_var):
Likewise.
* tree-ssa-live.c (new_tree_live_info, delete_tree_live_info,
calculate_live_on_entry, calculate_live_on_exit,
build_tree_conflict_graph): Likewise.
* tree-ssa-loop-ivopts.c (tree_ssa_iv_optimize_init, record_use,
record_important_candidates, set_use_iv_cost, find_depends,
determine_use_iv_costs, iv_ca_new, iv_ca_free, free_loop_data,
tree_ssa_iv_optimize_finalize): Likewise.
* tree-ssa-loop-manip.c (add_exit_phis_var, get_loops_exit,
find_uses_to_rename_use, rewrite_into_loop_closed_ssa,
tree_duplicate_loop_to_header_edge): Likewise.
* tree-ssa-pre.c (init_pre, fini_pre): Likewise.
* tree-ssa.c (verify_flow_insensitive_alias_info,
verify_name_tags, verify_ssa, init_tree_ssa,
delete_tree_ssa): Likewise.
* tree-ssanames.c (marked_ssa_names, init_ssanames,
fini_ssanames): Likewise.
* tree-vectorizer.c (slpeel_tree_peel_loop_to_edge): Likewise.
From-SVN: r95172
2005-02-17 17:19:49 +01:00
|
|
|
|
BITMAP_FREE (already_instantiated);
|
2004-07-12 21:31:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
2005-05-17 22:28:30 +02:00
|
|
|
|
/* Replace ssa names for that scev can prove they are constant by the
|
2005-07-27 15:26:55 +02:00
|
|
|
|
appropriate constants. Also perform final value replacement in loops,
|
|
|
|
|
in case the replacement expressions are cheap.
|
2005-05-17 22:28:30 +02:00
|
|
|
|
|
|
|
|
|
We only consider SSA names defined by phi nodes; rest is left to the
|
|
|
|
|
ordinary constant propagation pass. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
scev_const_prop (void)
|
|
|
|
|
{
|
|
|
|
|
basic_block bb;
|
2005-07-27 15:26:55 +02:00
|
|
|
|
tree name, phi, next_phi, type, ev;
|
|
|
|
|
struct loop *loop, *ex_loop;
|
2005-05-17 22:28:30 +02:00
|
|
|
|
bitmap ssa_names_to_remove = NULL;
|
2005-07-27 15:26:55 +02:00
|
|
|
|
unsigned i;
|
2005-05-17 22:28:30 +02:00
|
|
|
|
|
|
|
|
|
if (!current_loops)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
FOR_EACH_BB (bb)
|
|
|
|
|
{
|
|
|
|
|
loop = bb->loop_father;
|
|
|
|
|
|
|
|
|
|
for (phi = phi_nodes (bb); phi; phi = PHI_CHAIN (phi))
|
|
|
|
|
{
|
|
|
|
|
name = PHI_RESULT (phi);
|
|
|
|
|
|
|
|
|
|
if (!is_gimple_reg (name))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
type = TREE_TYPE (name);
|
|
|
|
|
|
|
|
|
|
if (!POINTER_TYPE_P (type)
|
|
|
|
|
&& !INTEGRAL_TYPE_P (type))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
ev = resolve_mixers (loop, analyze_scalar_evolution (loop, name));
|
|
|
|
|
if (!is_gimple_min_invariant (ev)
|
|
|
|
|
|| !may_propagate_copy (name, ev))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/* Replace the uses of the name. */
|
2005-09-09 12:56:41 +02:00
|
|
|
|
if (name != ev)
|
|
|
|
|
replace_uses_by (name, ev);
|
2005-05-17 22:28:30 +02:00
|
|
|
|
|
|
|
|
|
if (!ssa_names_to_remove)
|
|
|
|
|
ssa_names_to_remove = BITMAP_ALLOC (NULL);
|
|
|
|
|
bitmap_set_bit (ssa_names_to_remove, SSA_NAME_VERSION (name));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Remove the ssa names that were replaced by constants. We do not remove them
|
|
|
|
|
directly in the previous cycle, since this invalidates scev cache. */
|
|
|
|
|
if (ssa_names_to_remove)
|
|
|
|
|
{
|
|
|
|
|
bitmap_iterator bi;
|
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
|
|
EXECUTE_IF_SET_IN_BITMAP (ssa_names_to_remove, 0, i, bi)
|
|
|
|
|
{
|
|
|
|
|
name = ssa_name (i);
|
|
|
|
|
phi = SSA_NAME_DEF_STMT (name);
|
|
|
|
|
|
|
|
|
|
gcc_assert (TREE_CODE (phi) == PHI_NODE);
|
|
|
|
|
remove_phi_node (phi, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BITMAP_FREE (ssa_names_to_remove);
|
|
|
|
|
scev_reset ();
|
|
|
|
|
}
|
2005-07-27 15:26:55 +02:00
|
|
|
|
|
|
|
|
|
/* Now the regular final value replacement. */
|
|
|
|
|
for (i = current_loops->num - 1; i > 0; i--)
|
|
|
|
|
{
|
|
|
|
|
edge exit;
|
|
|
|
|
tree def, stmts;
|
|
|
|
|
|
|
|
|
|
loop = current_loops->parray[i];
|
|
|
|
|
if (!loop)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/* If we do not know exact number of iterations of the loop, we cannot
|
|
|
|
|
replace the final value. */
|
|
|
|
|
exit = loop->single_exit;
|
|
|
|
|
if (!exit
|
|
|
|
|
|| number_of_iterations_in_loop (loop) == chrec_dont_know)
|
|
|
|
|
continue;
|
|
|
|
|
ex_loop = exit->dest->loop_father;
|
|
|
|
|
|
|
|
|
|
for (phi = phi_nodes (exit->dest); phi; phi = next_phi)
|
|
|
|
|
{
|
|
|
|
|
next_phi = PHI_CHAIN (phi);
|
|
|
|
|
def = PHI_ARG_DEF_FROM_EDGE (phi, exit);
|
|
|
|
|
if (!is_gimple_reg (def)
|
|
|
|
|
|| expr_invariant_in_loop_p (loop, def))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (!POINTER_TYPE_P (TREE_TYPE (def))
|
|
|
|
|
&& !INTEGRAL_TYPE_P (TREE_TYPE (def)))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
def = analyze_scalar_evolution_in_loop (ex_loop, ex_loop, def);
|
|
|
|
|
if (!tree_does_not_contain_chrecs (def)
|
2005-09-09 12:56:41 +02:00
|
|
|
|
|| chrec_contains_symbols_defined_in_loop (def, loop->num)
|
|
|
|
|
|| def == PHI_RESULT (phi)
|
|
|
|
|
|| (TREE_CODE (def) == SSA_NAME
|
|
|
|
|
&& loop_containing_stmt (SSA_NAME_DEF_STMT (def))
|
|
|
|
|
&& loop_containing_stmt (phi)
|
|
|
|
|
&& loop_containing_stmt (SSA_NAME_DEF_STMT (def))
|
|
|
|
|
== loop_containing_stmt (phi)))
|
2005-07-27 15:26:55 +02:00
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/* If computing the expression is expensive, let it remain in
|
|
|
|
|
loop. TODO -- we should take the cost of computing the expression
|
|
|
|
|
in loop into account. */
|
|
|
|
|
if (force_expr_to_var_cost (def) >= target_spill_cost)
|
|
|
|
|
continue;
|
2005-08-03 20:39:10 +02:00
|
|
|
|
def = unshare_expr (def);
|
2005-07-27 15:26:55 +02:00
|
|
|
|
|
|
|
|
|
if (is_gimple_val (def))
|
|
|
|
|
stmts = NULL_TREE;
|
|
|
|
|
else
|
|
|
|
|
def = force_gimple_operand (def, &stmts, true,
|
|
|
|
|
SSA_NAME_VAR (PHI_RESULT (phi)));
|
|
|
|
|
SET_USE (PHI_ARG_DEF_PTR_FROM_EDGE (phi, exit), def);
|
|
|
|
|
if (stmts)
|
|
|
|
|
compute_phi_arg_on_exit (exit, stmts, def);
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-05-17 22:28:30 +02:00
|
|
|
|
}
|