2006-02-14 14:51:51 +01:00
|
|
|
/* Array prefetching.
|
|
|
|
Copyright (C) 2005 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
This file is part of GCC.
|
|
|
|
|
|
|
|
GCC is free software; you can redistribute it and/or modify it
|
|
|
|
under the terms of the GNU General Public License as published by the
|
|
|
|
Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
later version.
|
|
|
|
|
|
|
|
GCC is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with GCC; see the file COPYING. If not, write to the Free
|
|
|
|
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
02111-1307, USA. */
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "coretypes.h"
|
|
|
|
#include "tm.h"
|
|
|
|
#include "tree.h"
|
|
|
|
#include "rtl.h"
|
|
|
|
#include "tm_p.h"
|
|
|
|
#include "hard-reg-set.h"
|
|
|
|
#include "basic-block.h"
|
|
|
|
#include "output.h"
|
|
|
|
#include "diagnostic.h"
|
|
|
|
#include "tree-flow.h"
|
|
|
|
#include "tree-dump.h"
|
|
|
|
#include "timevar.h"
|
|
|
|
#include "cfgloop.h"
|
|
|
|
#include "varray.h"
|
|
|
|
#include "expr.h"
|
|
|
|
#include "tree-pass.h"
|
|
|
|
#include "ggc.h"
|
|
|
|
#include "insn-config.h"
|
|
|
|
#include "recog.h"
|
|
|
|
#include "hashtab.h"
|
|
|
|
#include "tree-chrec.h"
|
|
|
|
#include "tree-scalar-evolution.h"
|
|
|
|
#include "toplev.h"
|
|
|
|
#include "params.h"
|
|
|
|
#include "langhooks.h"
|
2007-01-28 18:40:38 +01:00
|
|
|
#include "tree-inline.h"
|
2006-02-14 14:51:51 +01:00
|
|
|
|
|
|
|
/* This pass inserts prefetch instructions to optimize cache usage during
|
|
|
|
accesses to arrays in loops. It processes loops sequentially and:
|
|
|
|
|
|
|
|
1) Gathers all memory references in the single loop.
|
|
|
|
2) For each of the references it decides when it is profitable to prefetch
|
|
|
|
it. To do it, we evaluate the reuse among the accesses, and determines
|
|
|
|
two values: PREFETCH_BEFORE (meaning that it only makes sense to do
|
|
|
|
prefetching in the first PREFETCH_BEFORE iterations of the loop) and
|
|
|
|
PREFETCH_MOD (meaning that it only makes sense to prefetch in the
|
|
|
|
iterations of the loop that are zero modulo PREFETCH_MOD). For example
|
|
|
|
(assuming cache line size is 64 bytes, char has size 1 byte and there
|
|
|
|
is no hardware sequential prefetch):
|
|
|
|
|
|
|
|
char *a;
|
|
|
|
for (i = 0; i < max; i++)
|
|
|
|
{
|
|
|
|
a[255] = ...; (0)
|
|
|
|
a[i] = ...; (1)
|
|
|
|
a[i + 64] = ...; (2)
|
|
|
|
a[16*i] = ...; (3)
|
|
|
|
a[187*i] = ...; (4)
|
|
|
|
a[187*i + 50] = ...; (5)
|
|
|
|
}
|
|
|
|
|
|
|
|
(0) obviously has PREFETCH_BEFORE 1
|
|
|
|
(1) has PREFETCH_BEFORE 64, since (2) accesses the same memory
|
|
|
|
location 64 iterations before it, and PREFETCH_MOD 64 (since
|
|
|
|
it hits the same cache line otherwise).
|
|
|
|
(2) has PREFETCH_MOD 64
|
|
|
|
(3) has PREFETCH_MOD 4
|
|
|
|
(4) has PREFETCH_MOD 1. We do not set PREFETCH_BEFORE here, since
|
|
|
|
the cache line accessed by (4) is the same with probability only
|
|
|
|
7/32.
|
|
|
|
(5) has PREFETCH_MOD 1 as well.
|
|
|
|
|
|
|
|
3) We determine how much ahead we need to prefetch. The number of
|
|
|
|
iterations needed is time to fetch / time spent in one iteration of
|
|
|
|
the loop. The problem is that we do not know either of these values,
|
|
|
|
so we just make a heuristic guess based on a magic (possibly)
|
|
|
|
target-specific constant and size of the loop.
|
|
|
|
|
|
|
|
4) Determine which of the references we prefetch. We take into account
|
|
|
|
that there is a maximum number of simultaneous prefetches (provided
|
|
|
|
by machine description). We prefetch as many prefetches as possible
|
|
|
|
while still within this bound (starting with those with lowest
|
|
|
|
prefetch_mod, since they are responsible for most of the cache
|
|
|
|
misses).
|
|
|
|
|
|
|
|
5) We unroll and peel loops so that we are able to satisfy PREFETCH_MOD
|
|
|
|
and PREFETCH_BEFORE requirements (within some bounds), and to avoid
|
|
|
|
prefetching nonaccessed memory.
|
|
|
|
TODO -- actually implement peeling.
|
|
|
|
|
|
|
|
6) We actually emit the prefetch instructions. ??? Perhaps emit the
|
|
|
|
prefetch instructions with guards in cases where 5) was not sufficient
|
|
|
|
to satisfy the constraints?
|
|
|
|
|
|
|
|
Some other TODO:
|
|
|
|
-- write and use more general reuse analysis (that could be also used
|
|
|
|
in other cache aimed loop optimizations)
|
|
|
|
-- make it behave sanely together with the prefetches given by user
|
|
|
|
(now we just ignore them; at the very least we should avoid
|
|
|
|
optimizing loops in that user put his own prefetches)
|
|
|
|
-- we assume cache line size alignment of arrays; this could be
|
|
|
|
improved. */
|
|
|
|
|
|
|
|
/* Magic constants follow. These should be replaced by machine specific
|
|
|
|
numbers. */
|
|
|
|
|
|
|
|
/* True if write can be prefetched by a read prefetch. */
|
|
|
|
|
|
|
|
#ifndef WRITE_CAN_USE_READ_PREFETCH
|
|
|
|
#define WRITE_CAN_USE_READ_PREFETCH 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* True if read can be prefetched by a write prefetch. */
|
|
|
|
|
|
|
|
#ifndef READ_CAN_USE_WRITE_PREFETCH
|
|
|
|
#define READ_CAN_USE_WRITE_PREFETCH 0
|
|
|
|
#endif
|
|
|
|
|
params.c (set_param_value): Initialize the "set" field.
* params.c (set_param_value): Initialize the "set" field.
* params.h (struct param_info): Add "set" field.
(PARAM_SET_P): New macro.
(PREFETCH_LATENCY, SIMULTANEOUS_PREFETCHES, L1_CACHE_SIZE,
L1_CACHE_LINE_SIZE): New macros.
* toplev.c (DEFPARAM): Initialize the "set" field.
* tree-ssa-loop-prefetch.c (PREFETCH_LATENCY,
SIMULTANEOUS_PREFETCHES): Removed.
(PREFETCH_BLOCK): Use L1_CACHE_LINE_SIZE.
(tree_ssa_prefetch_arrays): Dump the values of the parameters.
* config/sparc/sparc.c: Include params.h.
(sparc_override_options): Set SIMULTANEOUS_PREFETCHES and
L1_CACHE_LINE_SIZE parameters.
* config/sparc/sparc.h (PREFETCH_BLOCK, SIMULTANEOUS_PREFETCHES):
Removed.
* config/i386/i386.h (PREFETCH_BLOCK, SIMULTANEOUS_PREFETCHES):
Removed.
* config/i386/i386.c: Include params.h.
(k8_cost): Change default value for SIMULTANEOUS_PREFETCHES.
(override_options): Set SIMULTANEOUS_PREFETCHES and
L1_CACHE_LINE_SIZE parameters.
* config/sh/sh.h (SIMULTANEOUS_PREFETCHES): Removed.
(OPTIMIZATION_OPTIONS): Set SIMULTANEOUS_PREFETCHES and
L1_CACHE_LINE_SIZE parameters.
* config/ia64/ia64.c (ia64_optimization_options): Set
SIMULTANEOUS_PREFETCHES and L1_CACHE_LINE_SIZE parameters.
* config/ia64/ia64.h (SIMULTANEOUS_PREFETCHES, PREFETCH_BLOCK):
Removed.
* params.def (PARAM_PREFETCH_LATENCY, PARAM_SIMULTANEOUS_PREFETCHES,
PARAM_L1_CACHE_SIZE, PARAM_L1_CACHE_LINE_SIZE): New params.
* doc/invoke.texi: Document new params.
From-SVN: r118728
2006-11-12 20:17:02 +01:00
|
|
|
/* The size of the block loaded by a single prefetch. Usually, this is
|
|
|
|
the same as cache line size (at the moment, we only consider one level
|
|
|
|
of cache hierarchy). */
|
2006-02-14 14:51:51 +01:00
|
|
|
|
|
|
|
#ifndef PREFETCH_BLOCK
|
params.c (set_param_value): Initialize the "set" field.
* params.c (set_param_value): Initialize the "set" field.
* params.h (struct param_info): Add "set" field.
(PARAM_SET_P): New macro.
(PREFETCH_LATENCY, SIMULTANEOUS_PREFETCHES, L1_CACHE_SIZE,
L1_CACHE_LINE_SIZE): New macros.
* toplev.c (DEFPARAM): Initialize the "set" field.
* tree-ssa-loop-prefetch.c (PREFETCH_LATENCY,
SIMULTANEOUS_PREFETCHES): Removed.
(PREFETCH_BLOCK): Use L1_CACHE_LINE_SIZE.
(tree_ssa_prefetch_arrays): Dump the values of the parameters.
* config/sparc/sparc.c: Include params.h.
(sparc_override_options): Set SIMULTANEOUS_PREFETCHES and
L1_CACHE_LINE_SIZE parameters.
* config/sparc/sparc.h (PREFETCH_BLOCK, SIMULTANEOUS_PREFETCHES):
Removed.
* config/i386/i386.h (PREFETCH_BLOCK, SIMULTANEOUS_PREFETCHES):
Removed.
* config/i386/i386.c: Include params.h.
(k8_cost): Change default value for SIMULTANEOUS_PREFETCHES.
(override_options): Set SIMULTANEOUS_PREFETCHES and
L1_CACHE_LINE_SIZE parameters.
* config/sh/sh.h (SIMULTANEOUS_PREFETCHES): Removed.
(OPTIMIZATION_OPTIONS): Set SIMULTANEOUS_PREFETCHES and
L1_CACHE_LINE_SIZE parameters.
* config/ia64/ia64.c (ia64_optimization_options): Set
SIMULTANEOUS_PREFETCHES and L1_CACHE_LINE_SIZE parameters.
* config/ia64/ia64.h (SIMULTANEOUS_PREFETCHES, PREFETCH_BLOCK):
Removed.
* params.def (PARAM_PREFETCH_LATENCY, PARAM_SIMULTANEOUS_PREFETCHES,
PARAM_L1_CACHE_SIZE, PARAM_L1_CACHE_LINE_SIZE): New params.
* doc/invoke.texi: Document new params.
From-SVN: r118728
2006-11-12 20:17:02 +01:00
|
|
|
#define PREFETCH_BLOCK L1_CACHE_LINE_SIZE
|
2006-02-14 14:51:51 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Do we have a forward hardware sequential prefetching? */
|
|
|
|
|
|
|
|
#ifndef HAVE_FORWARD_PREFETCH
|
|
|
|
#define HAVE_FORWARD_PREFETCH 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Do we have a backward hardware sequential prefetching? */
|
|
|
|
|
|
|
|
#ifndef HAVE_BACKWARD_PREFETCH
|
|
|
|
#define HAVE_BACKWARD_PREFETCH 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* In some cases we are only able to determine that there is a certain
|
|
|
|
probability that the two accesses hit the same cache line. In this
|
|
|
|
case, we issue the prefetches for both of them if this probability
|
|
|
|
is less then (1000 - ACCEPTABLE_MISS_RATE) promile. */
|
|
|
|
|
|
|
|
#ifndef ACCEPTABLE_MISS_RATE
|
|
|
|
#define ACCEPTABLE_MISS_RATE 50
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_prefetch
|
|
|
|
#define HAVE_prefetch 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* The group of references between that reuse may occur. */
|
|
|
|
|
|
|
|
struct mem_ref_group
|
|
|
|
{
|
|
|
|
tree base; /* Base of the reference. */
|
|
|
|
HOST_WIDE_INT step; /* Step of the reference. */
|
|
|
|
struct mem_ref *refs; /* References in the group. */
|
|
|
|
struct mem_ref_group *next; /* Next group of references. */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Assigned to PREFETCH_BEFORE when all iterations are to be prefetched. */
|
|
|
|
|
|
|
|
#define PREFETCH_ALL (~(unsigned HOST_WIDE_INT) 0)
|
|
|
|
|
|
|
|
/* The memory reference. */
|
|
|
|
|
|
|
|
struct mem_ref
|
|
|
|
{
|
|
|
|
tree stmt; /* Statement in that the reference appears. */
|
|
|
|
tree mem; /* The reference. */
|
|
|
|
HOST_WIDE_INT delta; /* Constant offset of the reference. */
|
|
|
|
bool write_p; /* Is it a write? */
|
|
|
|
struct mem_ref_group *group; /* The group of references it belongs to. */
|
|
|
|
unsigned HOST_WIDE_INT prefetch_mod;
|
|
|
|
/* Prefetch only each PREFETCH_MOD-th
|
|
|
|
iteration. */
|
|
|
|
unsigned HOST_WIDE_INT prefetch_before;
|
|
|
|
/* Prefetch only first PREFETCH_BEFORE
|
|
|
|
iterations. */
|
|
|
|
bool issue_prefetch_p; /* Should we really issue the prefetch? */
|
|
|
|
struct mem_ref *next; /* The next reference in the group. */
|
|
|
|
};
|
|
|
|
|
cfgcleanup.c, [...]: Fix comment typos.
* cfgcleanup.c, config/dfp-bit.c, expr.c, fold-const.c,
jump.c, mips-tfile.c, omp-low.c, sched-int.h,
tree-ssa-loop-prefetch.c, tree-vrp.c: Fix comment typos.
From-SVN: r112971
2006-04-15 23:45:06 +02:00
|
|
|
/* Dumps information about reference REF to FILE. */
|
2006-02-14 14:51:51 +01:00
|
|
|
|
|
|
|
static void
|
|
|
|
dump_mem_ref (FILE *file, struct mem_ref *ref)
|
|
|
|
{
|
|
|
|
fprintf (file, "Reference %p:\n", (void *) ref);
|
|
|
|
|
|
|
|
fprintf (file, " group %p (base ", (void *) ref->group);
|
|
|
|
print_generic_expr (file, ref->group->base, TDF_SLIM);
|
|
|
|
fprintf (file, ", step ");
|
|
|
|
fprintf (file, HOST_WIDE_INT_PRINT_DEC, ref->group->step);
|
|
|
|
fprintf (file, ")\n");
|
|
|
|
|
2006-11-11 11:15:18 +01:00
|
|
|
fprintf (file, " delta ");
|
2006-02-14 14:51:51 +01:00
|
|
|
fprintf (file, HOST_WIDE_INT_PRINT_DEC, ref->delta);
|
|
|
|
fprintf (file, "\n");
|
|
|
|
|
|
|
|
fprintf (file, " %s\n", ref->write_p ? "write" : "read");
|
|
|
|
|
|
|
|
fprintf (file, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Finds a group with BASE and STEP in GROUPS, or creates one if it does not
|
|
|
|
exist. */
|
|
|
|
|
|
|
|
static struct mem_ref_group *
|
|
|
|
find_or_create_group (struct mem_ref_group **groups, tree base,
|
|
|
|
HOST_WIDE_INT step)
|
|
|
|
{
|
|
|
|
struct mem_ref_group *group;
|
|
|
|
|
|
|
|
for (; *groups; groups = &(*groups)->next)
|
|
|
|
{
|
|
|
|
if ((*groups)->step == step
|
|
|
|
&& operand_equal_p ((*groups)->base, base, 0))
|
|
|
|
return *groups;
|
|
|
|
|
|
|
|
/* Keep the list of groups sorted by decreasing step. */
|
|
|
|
if ((*groups)->step < step)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
group = xcalloc (1, sizeof (struct mem_ref_group));
|
|
|
|
group->base = base;
|
|
|
|
group->step = step;
|
|
|
|
group->refs = NULL;
|
|
|
|
group->next = *groups;
|
|
|
|
*groups = group;
|
|
|
|
|
|
|
|
return group;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Records a memory reference MEM in GROUP with offset DELTA and write status
|
|
|
|
WRITE_P. The reference occurs in statement STMT. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
record_ref (struct mem_ref_group *group, tree stmt, tree mem,
|
|
|
|
HOST_WIDE_INT delta, bool write_p)
|
|
|
|
{
|
|
|
|
struct mem_ref **aref;
|
|
|
|
|
|
|
|
/* Do not record the same address twice. */
|
|
|
|
for (aref = &group->refs; *aref; aref = &(*aref)->next)
|
|
|
|
{
|
|
|
|
/* It does not have to be possible for write reference to reuse the read
|
|
|
|
prefetch, or vice versa. */
|
|
|
|
if (!WRITE_CAN_USE_READ_PREFETCH
|
|
|
|
&& write_p
|
|
|
|
&& !(*aref)->write_p)
|
|
|
|
continue;
|
|
|
|
if (!READ_CAN_USE_WRITE_PREFETCH
|
|
|
|
&& !write_p
|
|
|
|
&& (*aref)->write_p)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((*aref)->delta == delta)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
(*aref) = xcalloc (1, sizeof (struct mem_ref));
|
|
|
|
(*aref)->stmt = stmt;
|
|
|
|
(*aref)->mem = mem;
|
|
|
|
(*aref)->delta = delta;
|
|
|
|
(*aref)->write_p = write_p;
|
|
|
|
(*aref)->prefetch_before = PREFETCH_ALL;
|
|
|
|
(*aref)->prefetch_mod = 1;
|
|
|
|
(*aref)->issue_prefetch_p = false;
|
|
|
|
(*aref)->group = group;
|
|
|
|
(*aref)->next = NULL;
|
|
|
|
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
dump_mem_ref (dump_file, *aref);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Release memory references in GROUPS. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
release_mem_refs (struct mem_ref_group *groups)
|
|
|
|
{
|
|
|
|
struct mem_ref_group *next_g;
|
|
|
|
struct mem_ref *ref, *next_r;
|
|
|
|
|
|
|
|
for (; groups; groups = next_g)
|
|
|
|
{
|
|
|
|
next_g = groups->next;
|
|
|
|
for (ref = groups->refs; ref; ref = next_r)
|
|
|
|
{
|
|
|
|
next_r = ref->next;
|
|
|
|
free (ref);
|
|
|
|
}
|
|
|
|
free (groups);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* A structure used to pass arguments to idx_analyze_ref. */
|
|
|
|
|
|
|
|
struct ar_data
|
|
|
|
{
|
|
|
|
struct loop *loop; /* Loop of the reference. */
|
|
|
|
tree stmt; /* Statement of the reference. */
|
|
|
|
HOST_WIDE_INT *step; /* Step of the memory reference. */
|
|
|
|
HOST_WIDE_INT *delta; /* Offset of the memory reference. */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Analyzes a single INDEX of a memory reference to obtain information
|
|
|
|
described at analyze_ref. Callback for for_each_index. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
idx_analyze_ref (tree base, tree *index, void *data)
|
|
|
|
{
|
|
|
|
struct ar_data *ar_data = data;
|
|
|
|
tree ibase, step, stepsize;
|
|
|
|
HOST_WIDE_INT istep, idelta = 0, imult = 1;
|
|
|
|
affine_iv iv;
|
|
|
|
|
|
|
|
if (TREE_CODE (base) == MISALIGNED_INDIRECT_REF
|
|
|
|
|| TREE_CODE (base) == ALIGN_INDIRECT_REF)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!simple_iv (ar_data->loop, ar_data->stmt, *index, &iv, false))
|
|
|
|
return false;
|
|
|
|
ibase = iv.base;
|
|
|
|
step = iv.step;
|
|
|
|
|
tree-ssa-loop-niter.c (number_of_iterations_lt_to_ne, [...]): Use integer_zerop/integer_nonzerop instead of...
* tree-ssa-loop-niter.c (number_of_iterations_lt_to_ne,
assert_no_overflow_lt, assert_loop_rolls_lt,
number_of_iterations_lt, number_of_iterations_le,
number_of_iterations_cond, number_of_iterations_exit):
Use integer_zerop/integer_nonzerop instead of
null_or_integer_zerop/nonnull_and_integer_nonzerop.
* tree.h (null_or_integer_zerop, nonnull_and_integer_nonzerop):
Removed.
* tree-scalar-evolution.c (simple_iv): Return zero for step of
an invariant.
* tree-ssa-loop-ivopts.c (alloc_iv): Do not set step of invariants
to zero.
(get_iv): Return NULL for non-scalar types. Use zero as a step
of an invariant.
(determine_biv_step, find_interesting_uses_op,
find_interesting_uses_cond, find_interesting_uses_stmt,
add_old_ivs_candidates, determine_use_iv_cost_condition,
rewrite_use_compare, remove_unused_ivs):
Use integer_zerop instead of null_or_integer_zerop.
(struct ifs_ivopts_data): Replace step_p field with step field.
(idx_find_step): Use zero as a step of an invariant. Modify
step instead of *step_p.
(find_interesting_uses_address): Use zero as a step of an invariant.
Use integer_zerop instead of null_or_integer_zerop.
(find_interesting_uses_outside): Call find_interesting_uses_op only
for phi nodes for real operands.
(add_candidate_1): Expect step to be non-NULL.
* tree-ssa-loop-prefetch.c (idx_analyze_ref): Expect step to be
non-NULL.
From-SVN: r120179
2006-12-24 00:05:52 +01:00
|
|
|
if (!cst_and_fits_in_hwi (step))
|
|
|
|
return false;
|
|
|
|
istep = int_cst_value (step);
|
2006-02-14 14:51:51 +01:00
|
|
|
|
|
|
|
if (TREE_CODE (ibase) == PLUS_EXPR
|
|
|
|
&& cst_and_fits_in_hwi (TREE_OPERAND (ibase, 1)))
|
|
|
|
{
|
|
|
|
idelta = int_cst_value (TREE_OPERAND (ibase, 1));
|
|
|
|
ibase = TREE_OPERAND (ibase, 0);
|
|
|
|
}
|
|
|
|
if (cst_and_fits_in_hwi (ibase))
|
|
|
|
{
|
|
|
|
idelta += int_cst_value (ibase);
|
tree-ssa-loop-niter.c (inverse, [...]): Use build_int_cst instead of build_int_cst_type.
* tree-ssa-loop-niter.c (inverse, number_of_iterations_ne,
assert_no_overflow_lt, assert_loop_rolls_lt, number_of_iterations_lt,
number_of_iterations_le, number_of_iterations_cond, find_loop_niter,
estimate_numbers_of_iterations_loop): Use build_int_cst instead of
build_int_cst_type.
* tree-chrec.c (chrec_fold_multiply_poly_poly,
chrec_fold_multiply): Same.
* tree-ssa-loop-ivopts.c (strip_offset_1, force_expr_to_var_cost,
force_expr_to_var_cost): Same.
* tree-mudflap.c (mf_xform_derefs_1): Same.
* tree-ssa-loop-prefetch.c (idx_analyze_ref): Same.
From-SVN: r112755
2006-04-07 17:44:59 +02:00
|
|
|
ibase = build_int_cst (TREE_TYPE (ibase), 0);
|
2006-02-14 14:51:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (TREE_CODE (base) == ARRAY_REF)
|
|
|
|
{
|
|
|
|
stepsize = array_ref_element_size (base);
|
|
|
|
if (!cst_and_fits_in_hwi (stepsize))
|
|
|
|
return false;
|
|
|
|
imult = int_cst_value (stepsize);
|
|
|
|
|
|
|
|
istep *= imult;
|
|
|
|
idelta *= imult;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ar_data->step += istep;
|
|
|
|
*ar_data->delta += idelta;
|
|
|
|
*index = ibase;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2006-09-18 03:54:33 +02:00
|
|
|
/* Tries to express REF_P in shape &BASE + STEP * iter + DELTA, where DELTA and
|
2006-02-14 14:51:51 +01:00
|
|
|
STEP are integer constants and iter is number of iterations of LOOP. The
|
2006-09-18 03:54:33 +02:00
|
|
|
reference occurs in statement STMT. Strips nonaddressable component
|
|
|
|
references from REF_P. */
|
2006-02-14 14:51:51 +01:00
|
|
|
|
|
|
|
static bool
|
2006-09-18 03:54:33 +02:00
|
|
|
analyze_ref (struct loop *loop, tree *ref_p, tree *base,
|
2006-02-14 14:51:51 +01:00
|
|
|
HOST_WIDE_INT *step, HOST_WIDE_INT *delta,
|
|
|
|
tree stmt)
|
|
|
|
{
|
|
|
|
struct ar_data ar_data;
|
|
|
|
tree off;
|
|
|
|
HOST_WIDE_INT bit_offset;
|
2006-09-18 03:54:33 +02:00
|
|
|
tree ref = *ref_p;
|
2006-02-14 14:51:51 +01:00
|
|
|
|
|
|
|
*step = 0;
|
|
|
|
*delta = 0;
|
|
|
|
|
|
|
|
/* First strip off the component references. Ignore bitfields. */
|
|
|
|
if (TREE_CODE (ref) == COMPONENT_REF
|
|
|
|
&& DECL_NONADDRESSABLE_P (TREE_OPERAND (ref, 1)))
|
|
|
|
ref = TREE_OPERAND (ref, 0);
|
|
|
|
|
2006-09-18 03:54:33 +02:00
|
|
|
*ref_p = ref;
|
|
|
|
|
2006-02-14 14:51:51 +01:00
|
|
|
for (; TREE_CODE (ref) == COMPONENT_REF; ref = TREE_OPERAND (ref, 0))
|
|
|
|
{
|
|
|
|
off = DECL_FIELD_BIT_OFFSET (TREE_OPERAND (ref, 1));
|
|
|
|
bit_offset = TREE_INT_CST_LOW (off);
|
|
|
|
gcc_assert (bit_offset % BITS_PER_UNIT == 0);
|
|
|
|
|
|
|
|
*delta += bit_offset / BITS_PER_UNIT;
|
|
|
|
}
|
|
|
|
|
|
|
|
*base = unshare_expr (ref);
|
|
|
|
ar_data.loop = loop;
|
|
|
|
ar_data.stmt = stmt;
|
|
|
|
ar_data.step = step;
|
|
|
|
ar_data.delta = delta;
|
|
|
|
return for_each_index (base, idx_analyze_ref, &ar_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Record a memory reference REF to the list REFS. The reference occurs in
|
|
|
|
LOOP in statement STMT and it is write if WRITE_P. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
gather_memory_references_ref (struct loop *loop, struct mem_ref_group **refs,
|
|
|
|
tree ref, bool write_p, tree stmt)
|
|
|
|
{
|
|
|
|
tree base;
|
|
|
|
HOST_WIDE_INT step, delta;
|
|
|
|
struct mem_ref_group *agrp;
|
|
|
|
|
2006-09-18 03:54:33 +02:00
|
|
|
if (!analyze_ref (loop, &ref, &base, &step, &delta, stmt))
|
2006-02-14 14:51:51 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* Now we know that REF = &BASE + STEP * iter + DELTA, where DELTA and STEP
|
|
|
|
are integer constants. */
|
|
|
|
agrp = find_or_create_group (refs, base, step);
|
|
|
|
record_ref (agrp, stmt, ref, delta, write_p);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Record the suitable memory references in LOOP. */
|
|
|
|
|
|
|
|
static struct mem_ref_group *
|
|
|
|
gather_memory_references (struct loop *loop)
|
|
|
|
{
|
|
|
|
basic_block *body = get_loop_body_in_dom_order (loop);
|
|
|
|
basic_block bb;
|
|
|
|
unsigned i;
|
|
|
|
block_stmt_iterator bsi;
|
|
|
|
tree stmt, lhs, rhs;
|
|
|
|
struct mem_ref_group *refs = NULL;
|
|
|
|
|
|
|
|
/* Scan the loop body in order, so that the former references precede the
|
|
|
|
later ones. */
|
|
|
|
for (i = 0; i < loop->num_nodes; i++)
|
|
|
|
{
|
|
|
|
bb = body[i];
|
|
|
|
if (bb->loop_father != loop)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
|
|
|
|
{
|
|
|
|
stmt = bsi_stmt (bsi);
|
2006-12-05 18:26:05 +01:00
|
|
|
if (TREE_CODE (stmt) != GIMPLE_MODIFY_STMT)
|
2006-02-14 14:51:51 +01:00
|
|
|
continue;
|
|
|
|
|
2006-12-05 18:26:05 +01:00
|
|
|
lhs = GIMPLE_STMT_OPERAND (stmt, 0);
|
|
|
|
rhs = GIMPLE_STMT_OPERAND (stmt, 1);
|
2006-02-14 14:51:51 +01:00
|
|
|
|
|
|
|
if (REFERENCE_CLASS_P (rhs))
|
|
|
|
gather_memory_references_ref (loop, &refs, rhs, false, stmt);
|
|
|
|
if (REFERENCE_CLASS_P (lhs))
|
|
|
|
gather_memory_references_ref (loop, &refs, lhs, true, stmt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free (body);
|
|
|
|
|
|
|
|
return refs;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Prune the prefetch candidate REF using the self-reuse. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
prune_ref_by_self_reuse (struct mem_ref *ref)
|
|
|
|
{
|
|
|
|
HOST_WIDE_INT step = ref->group->step;
|
|
|
|
bool backward = step < 0;
|
|
|
|
|
|
|
|
if (step == 0)
|
|
|
|
{
|
|
|
|
/* Prefetch references to invariant address just once. */
|
|
|
|
ref->prefetch_before = 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (backward)
|
|
|
|
step = -step;
|
|
|
|
|
|
|
|
if (step > PREFETCH_BLOCK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ((backward && HAVE_BACKWARD_PREFETCH)
|
|
|
|
|| (!backward && HAVE_FORWARD_PREFETCH))
|
|
|
|
{
|
|
|
|
ref->prefetch_before = 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ref->prefetch_mod = PREFETCH_BLOCK / step;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Divides X by BY, rounding down. */
|
|
|
|
|
|
|
|
static HOST_WIDE_INT
|
|
|
|
ddown (HOST_WIDE_INT x, unsigned HOST_WIDE_INT by)
|
|
|
|
{
|
|
|
|
gcc_assert (by > 0);
|
|
|
|
|
|
|
|
if (x >= 0)
|
|
|
|
return x / by;
|
|
|
|
else
|
|
|
|
return (x + by - 1) / by;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Prune the prefetch candidate REF using the reuse with BY.
|
|
|
|
If BY_IS_BEFORE is true, BY is before REF in the loop. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
prune_ref_by_group_reuse (struct mem_ref *ref, struct mem_ref *by,
|
|
|
|
bool by_is_before)
|
|
|
|
{
|
|
|
|
HOST_WIDE_INT step = ref->group->step;
|
|
|
|
bool backward = step < 0;
|
|
|
|
HOST_WIDE_INT delta_r = ref->delta, delta_b = by->delta;
|
|
|
|
HOST_WIDE_INT delta = delta_b - delta_r;
|
|
|
|
HOST_WIDE_INT hit_from;
|
|
|
|
unsigned HOST_WIDE_INT prefetch_before, prefetch_block;
|
|
|
|
|
|
|
|
if (delta == 0)
|
|
|
|
{
|
|
|
|
/* If the references has the same address, only prefetch the
|
|
|
|
former. */
|
|
|
|
if (by_is_before)
|
|
|
|
ref->prefetch_before = 0;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!step)
|
|
|
|
{
|
|
|
|
/* If the reference addresses are invariant and fall into the
|
|
|
|
same cache line, prefetch just the first one. */
|
|
|
|
if (!by_is_before)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (ddown (ref->delta, PREFETCH_BLOCK)
|
|
|
|
!= ddown (by->delta, PREFETCH_BLOCK))
|
|
|
|
return;
|
|
|
|
|
|
|
|
ref->prefetch_before = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Only prune the reference that is behind in the array. */
|
|
|
|
if (backward)
|
|
|
|
{
|
|
|
|
if (delta > 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Transform the data so that we may assume that the accesses
|
|
|
|
are forward. */
|
|
|
|
delta = - delta;
|
|
|
|
step = -step;
|
|
|
|
delta_r = PREFETCH_BLOCK - 1 - delta_r;
|
|
|
|
delta_b = PREFETCH_BLOCK - 1 - delta_b;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (delta < 0)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check whether the two references are likely to hit the same cache
|
|
|
|
line, and how distant the iterations in that it occurs are from
|
|
|
|
each other. */
|
|
|
|
|
|
|
|
if (step <= PREFETCH_BLOCK)
|
|
|
|
{
|
|
|
|
/* The accesses are sure to meet. Let us check when. */
|
|
|
|
hit_from = ddown (delta_b, PREFETCH_BLOCK) * PREFETCH_BLOCK;
|
|
|
|
prefetch_before = (hit_from - delta_r + step - 1) / step;
|
|
|
|
|
|
|
|
if (prefetch_before < ref->prefetch_before)
|
|
|
|
ref->prefetch_before = prefetch_before;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* A more complicated case. First let us ensure that size of cache line
|
|
|
|
and step are coprime (here we assume that PREFETCH_BLOCK is a power
|
|
|
|
of two. */
|
|
|
|
prefetch_block = PREFETCH_BLOCK;
|
|
|
|
while ((step & 1) == 0
|
|
|
|
&& prefetch_block > 1)
|
|
|
|
{
|
|
|
|
step >>= 1;
|
|
|
|
prefetch_block >>= 1;
|
|
|
|
delta >>= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now step > prefetch_block, and step and prefetch_block are coprime.
|
|
|
|
Determine the probability that the accesses hit the same cache line. */
|
|
|
|
|
|
|
|
prefetch_before = delta / step;
|
|
|
|
delta %= step;
|
|
|
|
if ((unsigned HOST_WIDE_INT) delta
|
|
|
|
<= (prefetch_block * ACCEPTABLE_MISS_RATE / 1000))
|
|
|
|
{
|
|
|
|
if (prefetch_before < ref->prefetch_before)
|
|
|
|
ref->prefetch_before = prefetch_before;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Try also the following iteration. */
|
|
|
|
prefetch_before++;
|
|
|
|
delta = step - delta;
|
|
|
|
if ((unsigned HOST_WIDE_INT) delta
|
|
|
|
<= (prefetch_block * ACCEPTABLE_MISS_RATE / 1000))
|
|
|
|
{
|
|
|
|
if (prefetch_before < ref->prefetch_before)
|
|
|
|
ref->prefetch_before = prefetch_before;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The ref probably does not reuse by. */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Prune the prefetch candidate REF using the reuses with other references
|
|
|
|
in REFS. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
prune_ref_by_reuse (struct mem_ref *ref, struct mem_ref *refs)
|
|
|
|
{
|
|
|
|
struct mem_ref *prune_by;
|
|
|
|
bool before = true;
|
|
|
|
|
|
|
|
prune_ref_by_self_reuse (ref);
|
|
|
|
|
|
|
|
for (prune_by = refs; prune_by; prune_by = prune_by->next)
|
|
|
|
{
|
|
|
|
if (prune_by == ref)
|
|
|
|
{
|
|
|
|
before = false;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!WRITE_CAN_USE_READ_PREFETCH
|
|
|
|
&& ref->write_p
|
|
|
|
&& !prune_by->write_p)
|
|
|
|
continue;
|
|
|
|
if (!READ_CAN_USE_WRITE_PREFETCH
|
|
|
|
&& !ref->write_p
|
|
|
|
&& prune_by->write_p)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
prune_ref_by_group_reuse (ref, prune_by, before);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Prune the prefetch candidates in GROUP using the reuse analysis. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
prune_group_by_reuse (struct mem_ref_group *group)
|
|
|
|
{
|
|
|
|
struct mem_ref *ref_pruned;
|
|
|
|
|
|
|
|
for (ref_pruned = group->refs; ref_pruned; ref_pruned = ref_pruned->next)
|
|
|
|
{
|
|
|
|
prune_ref_by_reuse (ref_pruned, group->refs);
|
|
|
|
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
{
|
|
|
|
fprintf (dump_file, "Reference %p:", (void *) ref_pruned);
|
|
|
|
|
|
|
|
if (ref_pruned->prefetch_before == PREFETCH_ALL
|
|
|
|
&& ref_pruned->prefetch_mod == 1)
|
|
|
|
fprintf (dump_file, " no restrictions");
|
|
|
|
else if (ref_pruned->prefetch_before == 0)
|
|
|
|
fprintf (dump_file, " do not prefetch");
|
|
|
|
else if (ref_pruned->prefetch_before <= ref_pruned->prefetch_mod)
|
|
|
|
fprintf (dump_file, " prefetch once");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ref_pruned->prefetch_before != PREFETCH_ALL)
|
|
|
|
{
|
|
|
|
fprintf (dump_file, " prefetch before ");
|
|
|
|
fprintf (dump_file, HOST_WIDE_INT_PRINT_DEC,
|
|
|
|
ref_pruned->prefetch_before);
|
|
|
|
}
|
|
|
|
if (ref_pruned->prefetch_mod != 1)
|
|
|
|
{
|
|
|
|
fprintf (dump_file, " prefetch mod ");
|
|
|
|
fprintf (dump_file, HOST_WIDE_INT_PRINT_DEC,
|
|
|
|
ref_pruned->prefetch_mod);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fprintf (dump_file, "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Prune the list of prefetch candidates GROUPS using the reuse analysis. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
prune_by_reuse (struct mem_ref_group *groups)
|
|
|
|
{
|
|
|
|
for (; groups; groups = groups->next)
|
|
|
|
prune_group_by_reuse (groups);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns true if we should issue prefetch for REF. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
should_issue_prefetch_p (struct mem_ref *ref)
|
|
|
|
{
|
|
|
|
/* For now do not issue prefetches for only first few of the
|
|
|
|
iterations. */
|
|
|
|
if (ref->prefetch_before != PREFETCH_ALL)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Decide which of the prefetch candidates in GROUPS to prefetch.
|
|
|
|
AHEAD is the number of iterations to prefetch ahead (which corresponds
|
|
|
|
to the number of simultaneous instances of one prefetch running at a
|
|
|
|
time). UNROLL_FACTOR is the factor by that the loop is going to be
|
|
|
|
unrolled. Returns true if there is anything to prefetch. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
schedule_prefetches (struct mem_ref_group *groups, unsigned unroll_factor,
|
|
|
|
unsigned ahead)
|
|
|
|
{
|
2006-11-12 21:05:49 +01:00
|
|
|
unsigned remaining_prefetch_slots, n_prefetches, prefetch_slots;
|
|
|
|
unsigned slots_per_prefetch;
|
2006-02-14 14:51:51 +01:00
|
|
|
struct mem_ref *ref;
|
|
|
|
bool any = false;
|
|
|
|
|
2006-11-12 21:05:49 +01:00
|
|
|
/* At most SIMULTANEOUS_PREFETCHES should be running at the same time. */
|
|
|
|
remaining_prefetch_slots = SIMULTANEOUS_PREFETCHES;
|
2006-02-14 14:51:51 +01:00
|
|
|
|
2006-11-12 21:05:49 +01:00
|
|
|
/* The prefetch will run for AHEAD iterations of the original loop, i.e.,
|
|
|
|
AHEAD / UNROLL_FACTOR iterations of the unrolled loop. In each iteration,
|
|
|
|
it will need a prefetch slot. */
|
|
|
|
slots_per_prefetch = (ahead + unroll_factor / 2) / unroll_factor;
|
2006-02-14 14:51:51 +01:00
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
2006-11-12 21:05:49 +01:00
|
|
|
fprintf (dump_file, "Each prefetch instruction takes %u prefetch slots.\n",
|
|
|
|
slots_per_prefetch);
|
2006-02-14 14:51:51 +01:00
|
|
|
|
|
|
|
/* For now we just take memory references one by one and issue
|
|
|
|
prefetches for as many as possible. The groups are sorted
|
|
|
|
starting with the largest step, since the references with
|
builtins.c, [...]: Fix comment typos.
* builtins.c, c-pragma.h, c-typeck.c, cgraph.c, cgraphunit.c,
combine.c, common.opt, config/dfp-bit.c, config/i386/i386.c,
config/m68k/m68k.c, config/m68k/m68k.md, config/mt/mt.c,
config/mt/mt.h, config/s390/s390.md, df-core.c, df-problems.c,
df-scan.c, df.h, diagnostic.c, expr.c, function.h, gimplify.c,
loop-invariant.c, omp-low.c, opts.c, passes.c,
rtl-factoring.c, rtlanal.c, struct-equiv.c, tree-cfgcleanup.c,
tree-ssa-loop-niter.c, tree-ssa-loop-prefetch.c,
tree-ssa-structalias.c, tree-ssa-threadedge.c,
tree-ssa-threadupdate.c, tree-vect-patterns.c,
tree-vect-transform.c, tree-vectorizer.h, tree-vrp.c,
unwind-dw2.c: Fix comment typos. Follow spelling conventions.
From-SVN: r111721
2006-03-05 00:05:24 +01:00
|
|
|
large step are more likely to cause many cache misses. */
|
2006-02-14 14:51:51 +01:00
|
|
|
|
|
|
|
for (; groups; groups = groups->next)
|
|
|
|
for (ref = groups->refs; ref; ref = ref->next)
|
|
|
|
{
|
|
|
|
if (!should_issue_prefetch_p (ref))
|
|
|
|
continue;
|
|
|
|
|
2006-11-12 21:05:49 +01:00
|
|
|
/* If we need to prefetch the reference each PREFETCH_MOD iterations,
|
|
|
|
and we unroll the loop UNROLL_FACTOR times, we need to insert
|
|
|
|
ceil (UNROLL_FACTOR / PREFETCH_MOD) instructions in each
|
|
|
|
iteration. */
|
2006-02-14 14:51:51 +01:00
|
|
|
n_prefetches = ((unroll_factor + ref->prefetch_mod - 1)
|
|
|
|
/ ref->prefetch_mod);
|
2006-11-12 21:05:49 +01:00
|
|
|
prefetch_slots = n_prefetches * slots_per_prefetch;
|
|
|
|
|
|
|
|
/* If more than half of the prefetches would be lost anyway, do not
|
|
|
|
issue the prefetch. */
|
|
|
|
if (2 * remaining_prefetch_slots < prefetch_slots)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
ref->issue_prefetch_p = true;
|
2006-02-14 14:51:51 +01:00
|
|
|
|
2006-11-12 21:05:49 +01:00
|
|
|
if (remaining_prefetch_slots <= prefetch_slots)
|
|
|
|
return true;
|
|
|
|
remaining_prefetch_slots -= prefetch_slots;
|
2006-02-14 14:51:51 +01:00
|
|
|
any = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return any;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Determine whether there is any reference suitable for prefetching
|
|
|
|
in GROUPS. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
anything_to_prefetch_p (struct mem_ref_group *groups)
|
|
|
|
{
|
|
|
|
struct mem_ref *ref;
|
|
|
|
|
|
|
|
for (; groups; groups = groups->next)
|
|
|
|
for (ref = groups->refs; ref; ref = ref->next)
|
|
|
|
if (should_issue_prefetch_p (ref))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Issue prefetches for the reference REF into loop as decided before.
|
|
|
|
HEAD is the number of iterations to prefetch ahead. UNROLL_FACTOR
|
builtins.c, [...]: Fix comment typos.
* builtins.c, config/arm/arm.c, config/i386/cygwin.h,
config/i386/i386.c, config/ia64/ia64.c, config/s390/fixdfdi.h,
config/sh/sh.c, config/sh/sh.h, df-scan.c, except.c,
haifa-sched.c, optabs.c, rtl.h, sched-deps.c, sched-int.h,
sched-rgn.c, tree-inline.h, tree-ssa-dom.c,
tree-ssa-loop-prefetch.c, tree-ssa-operands.c,
tree-vect-patterns.c, tree-vrp.c: Fix comment typos. Follow
spelling convensions.
* config/ia64/ia64.opt, doc/contrib.texi, doc/invoke.texi,
doc/passes.texi, doc/tm.texi, doc/tree-ssa.texi: Fix comment
typos. Follow spelling conventions.
From-SVN: r112782
2006-04-08 19:01:17 +02:00
|
|
|
is the factor by which LOOP was unrolled. */
|
2006-02-14 14:51:51 +01:00
|
|
|
|
|
|
|
static void
|
|
|
|
issue_prefetch_ref (struct mem_ref *ref, unsigned unroll_factor, unsigned ahead)
|
|
|
|
{
|
|
|
|
HOST_WIDE_INT delta;
|
tree.h (enum tree_code_class): Add tcc_vl_exp.
2007-02-15 Sandra Loosemore <sandra@codesourcery.com>
Brooks Moses <brooks.moses@codesourcery.com>
Lee Millward <lee.millward@codesourcery.com>
* tree.h (enum tree_code_class): Add tcc_vl_exp.
(VL_EXP_CLASS_P): New.
(TREE_OPERAND_CHECK): Use TREE_OPERAND_LENGTH instead of
TREE_CODE_LENGTH.
(TREE_OPERAND_CHECK_CODE): Likewise.
(GIMPLE_STMT_OPERAND_CHECK): Likewise.
(TREE_RTL_OPERAND_CHECK): Likewise.
(tree_operand_check_failed): Make second parameter the whole tree
instead of its code. Fixed callers.
(VL_EXP_CHECK): New.
(TREE_OPERAND_LENGTH): New.
(VL_EXP_OPERAND_LENGTH): New.
(CALL_EXPR_FN): New.
(CALL_EXPR_STATIC_CHAIN): New.
(CALL_EXPR_ARGS): New.
(CALL_EXPR_ARG): New.
(call_expr_nargs): New.
(CALL_EXPR_ARGP): New.
(build_nt_call_list): Declare.
(build_vl_exp_stat): Declare.
(build_vl_exp): New.
(build_call_list): Declare.
(build_call_nary): Declare.
(build_call_valist): Declare.
(build_call_array): Declare.
(call_expr_arg): Declare.
(call_expr_argp): Declare.
(call_expr_arglist): Declare.
(fold_build_call_list): Declare.
(fold_build_call_list_initializer): Declare.
(fold_call_expr): Declare to replace fold_builtin.
(fold_builtin_fputs): Update to agree with modified definition.
(fold_builtin_strcpy): Likewise.
(fold_builtin_strncpy): Likewise.
(fold_builtin_memory_chk): Likewise.
(fold_builtin_stxcpy_chk): Likewise.
(fold_builtin_strncpy_chk): Likewise.
(fold_builtin_next_arg): Likewise.
(fold_build_call_expr): Declare.
(fold_builtin_call_list): Declare.
(fold_builtin_call_valist): Declare.
(build_call_expr): Declare.
(validate_arglist): Update to agree with modified definition.
(tree_operand_length): New.
(call_expr_arg_iterator): New.
(init_call_expr_arg_iterator): New.
(next_call_expr_arg): New.
(first_call_expr_arg): New.
(more_call_expr_args_p): New.
(FOR_EACH_CALL_EXPR_ARG): New.
* tree.c (tree_code_class_string): Add entries for tcc_vl_exp
and tcc_gimple_stmt.
(tree_code_size): Update documentation. Use sizeof (tree) rather
than sizeof (char *).
(tree_size): Likewise. Add case for tcc_vl_exp.
(tree_node_structure): Add case for tcc_vl_exp.
(contains_placeholder_p): Likewise.
(substitute_in_expr): Likewise.
(substitute_placeholder_in_expr): Likewise.
(stabilize_reference_1): Likewise.
(build3_stat): Remove logic for CALL_EXPRs. Replace with assertion
to diagnose breakage of this interface for constructing CALL_EXPRs.
(build_nt): Add similar assertion here.
(build_nt_call_list): New.
(simple_cst_equal) <CALL_EXPR>: Rewrite to use new accessors.
(iterative_hash_expr): Use TREE_OPERAND_LENGTH instead of
TREE_CODE_LENGTH.
(get_callee_fndecl): Use new CALL_EXPR accessors.
(tree_operand_check_failed): Change parameters to pass entire node
instead of its code, so that we can call TREE_OPERAND_LENGTH on it.
(process_call_operands): New.
(build_vl_exp_stat): New.
(build_call_list): New.
(build_call_nary): New.
(build_call_valist): New.
(build_call_array): New.
(walk_tree): Use TREE_OPERAND_LENGTH instead of TREE_CODE_LENGTH.
(call_expr_arglist): New.
* tree.def (CALL_EXPR): Change representation of CALL_EXPRs to use
tcc_vl_exp instead of a fixed-size tcc_expression.
* doc/c-tree.texi (CALL_EXPR): Document new representation and
accessors for CALL_EXPRs.
(AGGR_INIT_EXPR): Likewise.
2007-02-15 Sandra Loosemore <sandra@codesourcery.com>
Brooks Moses <brooks.moses@codesourcery.com>
Lee Millward <lee.millward@codesourcery.com>
* builtins.c (c_strlen): Return NULL_TREE instead of 0.
(expand_builtin_nonlocal_goto): Change parameter to be entire
CALL_EXPR instead of an arglist. Use new CALL_EXPR accessors.
(expand_builtin_prefetch): Likewise.
(expand_builtin_classify_type): Likewise.
(mathfn_built_in): Return NULL_TREE instead of 0.
(expand_errno_check): Use new CALL_EXPR accessors.
(expand_builtin_mathfn): Use new CALL_EXPR accessors and constructors.
Return NULL_RTX instead of 0.
(expand_builtin_mathfn_2): Likewise.
(expand_builtin_mathfn_3): Likewise.
(expand_builtin_interclass_mathfn): Likewise.
(expand_builtin_sincos): Likewise.
(expand_builtin_cexpi): Likewise.
(expand_builtin_int_roundingfn): Likewise.
(expand_builtin_int_roundingfn_2): Likewise.
(expand_builtin_pow): Likewise.
(expand_builtin_powi): Likewise.
(expand_builtin_strlen): Pass entire CALL_EXPR as parameter instead
of arglist, fixing callers appropriately. Use new CALL_EXPR
accessors and constructors. Return NULL_RTX instead of 0.
(expand_builtin_strstr): Likewise.
(expand_builtin_strchr): Likewise.
(expand_builtin_strrchr): Likewise.
(expand_builtin_strpbrk): Likewise.
(expand_builtin_memcpy): Likewise.
(expand_builtin_mempcpy): Likewise.
(expand_builtin_mempcpy_args): New.
(expand_builtin_memmove): Similarly to expand_builtin_mempcpy.
(expand_builtin_memmove_args): New.
(expand_builtin_bcopy): Similarly to expand_builtin_mempcpy.
(expand_movstr): Likewise.
(expand_builtin_strcpy): Likewise.
(expand_builtin_strcpy_args): New.
(expand_builtin_stpcpy): Similarly to expand_builtin_strcpy.
(expand_builtin_strncpy): Likewise.
(expand_builtin_memset): Likewise.
(expand_builtin_memset_args): New.
(expand_builtin_bzero): Similarly to expand_builtin_memset.
(expand_builtin_memcmp): Likewise.
(expand_builtin_strcmp): Likewise.
(expand_builtin_strncmp): Likewise.
(expand_builtin_strcat): Likewise.
(expand_builtin_strncat): Likewise.
(expand_builtin_strspn): Likewise.
(expand_builtin_strcspn): Likewise.
(expand_builtin_args_info): Likewise.
(expand_builtin_va_start): Likewise.
(gimplify_va_arg_expr): Likewise.
(expand_builtin_va_end): Likewise.
(expand_builtin_va_copy): Likewise.
(expand_builtin_frame_address): Likewise.
(expand_builtin_alloca): Likewise.
(expand_builtin_bswap): Likewise.
(expand_builtin_unop): Likewise.
(expand_builtin_fputs): Likewise.
(expand_builtin_expect): Likewise.
(expand_builtin_fabs): Likewise.
(expand_builtin_copysign): Likewise.
(expand_builtin_printf): Likewise.
(expand_builtin_fprintf): Likewise.
(expand_builtin_sprintf): Likewise.
(expand_builtin_init_trampoline): Likewise.
(expand_builtin_signbit): Likewise.
(expand_builtin_fork_or_exec): Likewise.
(expand_builtin_sync_operation): Likewise.
(expand_builtin_compare_and_swap): Likewise.
(expand_builtin_lock_test_and_set): Likewise.
(expand_builtin_lock_release): Likewise.
(expand_builtin): Likewise.
(builtin_mathfn_code): Likewise.
(fold_builtin_constant_p): Pass call arguments individually instead
of as an arglist, fixing callers appropriately. Use new CALL_EXPR
accessors and constructors. Return NULL_TREE instead of 0.
(fold_builtin_expect): Likewise.
(fold_builtin_classify_type): Likewise.
(fold_builtin_strlen): Likewise.
(fold_builtin_nan): Likewise.
(integer_valued_real_p): Likewise.
(fold_trunc_transparent_mathfn): Likewise.
(fold_fixed_mathfn): Likewise.
(fold_builtin_cabs): Likewise.
(fold_builtin_sqrt): Likewise.
(fold_builtin_cbrt): Likewise.
(fold_builtin_cos): Likewise.
(fold_builtin_cosh): Likewise.
(fold_builtin_tan): Likewise.
(fold_builtin_sincos): Likewise.
(fold_builtin_cexp): Likewise.
(fold_builtin_trunc): Likewise.
(fold_builtin_floor): Likewise.
(fold_builtin_ceil): Likewise.
(fold_builtin_round): Likewise.
(fold_builtin_int_roundingfn): Likewise.
(fold_builtin_bitop): Likewise.
(fold_builtin_bswap): Likewise.
(fold_builtin_logarithm): Likewise.
(fold_builtin_hypot): Likewise.
(fold_builtin_pow): Likewise.
(fold_builtin_powi): Likewise.
(fold_builtin_exponent): Likewise.
(fold_builtin_memset): Likewise.
(fold_builtin_bzero): Likewise.
(fold_builtin_memory_op): Likewise.
(fold_builtin_bcopy): Deleted; call site changed to invoke
fold_builtin_memory_op directly.
(fold_builtin_strcpy): Similarly as for fold_builtin_memory_op.
(fold_builtin_strncpy): Likewise.
(fold_builtin_memcmp): Likewise.
(fold_builtin_strcmp): Likewise.
(fold_builtin_strncmp): Likewise.
(fold_builtin_signbit): Likewise.
(fold_builtin_copysign): Likewise.
(fold_builtin_isascii): Likewise.
(fold_builtin_toascii): Likewise.
(fold_builtin_isdigit): Likewise.
(fold_builtin_fabs): Likewise.
(fold_builtin_abs): Likewise.
(fold_builtin_fmin_fmax): Likewise.
(fold_builtin_carg): Likewise.
(fold_builtin_classify): Likewise.
(fold_builtin_unordered_cmp): Likewise.
(fold_builtin_0, fold_builtin_2, fold_builtin_3, fold_builtin_4):
New functions split out from fold_builtin_1.
(fold_builtin_n): New.
(fold_builtin_varargs): New.
(fold_builtin): Deleted. Most callers changed to use fold_call_expr
instead.
(fold_call_expr): New.
(build_function_call_expr): Rewrite to use new helper function.
(fold_builtin_call_list): New.
(build_call_expr): New.
(fold_builtin_call_valist): New.
(rewrite_call_expr): New.
(validate_arg): New.
(validate_arglist): Change parameter to be entire CALL_EXPR instead
of an arglist. Change return type to bool. Use new CALL_EXPR
accessors.
(fold_builtin_strstr): Pass call arguments individually instead
of as an arglist, fixing callers appropriately. Use new CALL_EXPR
accessors and constructors. Return NULL_TREE instead of 0.
(fold_builtin_strchr): Likewise.
(fold_builtin_strrchr): Likewise.
(fold_builtin_strpbrk): Likewise.
(fold_builtin_strcat): Likewise.
(fold_builtin_strncat): Likewise.
(fold_builtin_strspn): Likewise.
(fold_builtin_strcspn): Likewise.
(fold_builtin_fputs): Likewise.
(fold_builtin_next_arg): Likewise.
(fold_builtin_sprintf): Likewise.
(expand_builtin_object_size): Use new CALL_EXPR accessors. Use
NULL_RTX instead of 0.
(expand_builtin_memory_chk): Likewise.
(maybe_emit_chk_warning): Likewise.
(maybe_emit_sprintf_chk_warning): Likewise.
(fold_builtin_object_size): Pass call arguments individually instead
of as an arglist, fixing callers appropriately. Use new CALL_EXPR
accessors and constructors. Return NULL_TREE instead of 0.
(fold_builtin_memory_chk): Likewise.
(fold_builtin_stxcpy_chk): Likewise.
(fold_builtin_strncpy_chk): Likewise.
(fold_builtin_strcat_chk): Likewise.
(fold_builtin_strcat_chk): Likewise.
(fold_builtin_strncat_chk): Likewise.
(fold_builtin_sprintf_chk): Likewise.
(fold_builtin_snprintf_chk): Likewise.
(fold_builtin_printf): Likewise.
(fold_builtin_vprintf): Likewise.
* fold-const.c (negate_expr_p): Use new CALL_EXPR accessors and
constructors.
(operand_equal_p): Add separate tcc_vl_exp/CALL_EXPR case.
(make_range): Use TREE_OPERAND_LENGTH instead of TREE_CODE_LENGTH.
(extract_muldiv_1): Add VL_EXP_CLASS_P case.
(fold_mathfn_compare): Use new CALL_EXPR accessors and constructors.
(fold_unary): Likewise.
(fold_binary): Likewise.
(fold_ternary): Remove CALL_EXPR case, since they are no longer
ternary expressions.
(fold): Add logic for tcc_vl_exp.
(fold_checksum_tree): Make it know about tcc_vl_exp. Use
TREE_OPERAND_LENGTH instead of TREE_CODE_LENGTH.
(fold_build3_stat): Add assertion to flag broken interface for
constructing CALL_EXPRs.
(fold_build_call_list): New.
(fold_build_call_list_initializer): New.
(tree_expr_nonnegative_p): Use new CALL_EXPR accessors and
constructors.
(fold_strip_sign_ops): Likewise.
2007-02-15 Sandra Loosemore <sandra@codesourcery.com>
Brooks Moses <brooks.moses@codesourcery.com>
Lee Millward <lee.millward@codesourcery.com>
* tree-dump.c (dequeue_and_dump) <CALL_EXPR>: Use new CALL_EXPR
accessors and dump arguments explicitly.
* tree-pretty-print.c (do_niy): Use TREE_OPERAND_LENGTH instead of
TREE_CODE_LENGTH.
(dump_generic_node): Use new CALL_EXPR accessors and walk arguments
explicitly.
(print_call_name): Use new CALL_EXPR accessors.
* print-tree.c (print_node): Add case tcc_vl_exp. Print
CALL_EXPR arguments explicitly instead of as a list. Use
TREE_OPERAND_LENGTH instead of TREE_CODE_LENGTH.
* tree-vrp.c (stmt_interesting_for_vrp): Use new CALL_EXPR accessors.
(vrp_visit_stmt): Likewise.
* tree-ssa-loop-im.c (outermost_invariant_loop_expr): Make it
know about tcc_vl_exp. Use TREE_OPERAND_LENGTH instead of
TREE_CODE_LENGTH.
(force_move_till_expr): Likewise.
* targhooks.c (default_external_stack_protect_fail): Use
build_call_expr instead of build_function_call_expr.
(default_hidden_stack_protect_fail): Likewise.
* tree-complex.c (expand_complex_libcall): Use build_call_expr to
build the call.
* cgraphbuild.c (build_cgraph_edges): Use new CALL_EXPR accessors
and walk arguments explicitly.
* tree-ssa-loop-niter.c (simplify_replace_tree): Use
TREE_OPERAND_LENGTH instead of TREE_CODE_LENGTH.
(expand_simple_operations): Likewise.
(infer_loop_bounds_from_array): Use new CALL_EXPR accessors.
* gengtype.c (adjust_field_tree_exp): Use TREE_OPERAND_LENGTH instead
of TREE_CODE_LENGTH.
(walk_type): Tweak walking of arrays not to blow up on CALL_EXPRs.
* optabs.c (expand_widen_pattern-expr): Use TREE_OPERAND_LENGTH
instead of TREE_CODE_LENGTH.
* value_prof.c (tree_ic): Use new CALL_EXPR accessors.
(tree_ic_transform): Likewise.
(interesting_stringop_to_profile_p): Pass entire CALL_EXPR as
parameter instead of arglist. Fix callers.
(tree_stringop_fixed_value): Use new CALL_EXPR accessors.
(tree_stringops_transform): Likewise.
(tree_indirect_call_to_profile): Likewise.
(tree_stringops_values_to_profile): Likewise.
* tree-tailcall.c (find_tail_calls): Use new CALL_EXPR iterator.
(eliminate_tail_call): Likewise.
* ipa-cp.c (ipcp_update_callgraph): Use new CALL_EXPR accessors.
* tree-scalar-evolution.c (chrec_contains_symbols_defined_in_loop):
Use TREE_OPERAND_LENGTH and generalize to handle any number of
operands.
(instantiate_parameters_1): Can't handle tcc_vl_exp here.
* omp-low.c (build_omp_barrier): Use build_call_expr.
(lower_rec_input_clauses): Likewise.
(lower_reduction_clauses): Likewise.
(expand_parallel_call): Likewise.
(maybe_catch_exception): Likewise.
(expand_omp_for_generic): Likewise.
(expand_omp_for_static_nochunk): Likewise.
(expand_omp_sections): Likewise.
(lower_omp_single_simple): Likewise.
(lower_omp_single_copy): Likewise.
(lower_omp_master): Likewise.
(lower_omp_ordered): Likewise.
(lower_omp_critical): Likewise.
* ipa-reference.c (check-call): Use new CALL_EXPR iterator.
(scan_for_static_refs): Create tcc_vl_exp case for CALL_EXPR.
* tree-gimple.c (is_gimple_call_addr): Fix doc.
(recalculate_side_effects): Use TREE_OPERAND_LENGTH instead of
TREE_CODE_LENGTH. Add tcc_vl_exp case.
* tree-chrec.c (chrec_contains_symbols): Use TREE_OPERAND_LENGTH
and generalize to handle any number of operands.
(chrec_contains_undetermined): Likewise.
(tree_contains_chrecs): Likewise.
(evolution_function_is_invariant_rec_p): Use TREE_OPERAND_LENGTH.
* cgraphunit.c (update_call_expr): Use new CALL_EXPR accessors.
* tree-ssa-ccp.c (ccp_fold): Use new CALL_EXPR accessors. Use
fold_call_expr instead of fold_builtin.
(ccp_fold_builtin): Likewise. Update calls into builtins.c to
match declarations there.
(fold_stmt): Use new CALL_EXPR constructor and accessors. Doc
updates.
* tree-ssa-loop-ivopts.c (expr_invariant_in_loop_p): Use
TREE_OPERAND_LENGTH instead of TREE_CODE_LENGTH.
* ipa-pure-const.c (check_call): Use new CALL_EXPR accessors.
(scan_function): Add case tcc_vl_exp for CALL_EXPR.
* tree-stdarg.c (execute_optimize_stdarg): Use new CALL_EXPR
accessors.
* tree-ssa-math-opts.c (execute_cse_sincos_1): Use build_call_expr.
(execute_cse_sincos): Use new CALL_EXPR accessors.
* tree-ssa-alias.c (find_used_portions): Use new CALL_EXPR iterator.
* gimple-low.c (lower_function_body): Use build_call_expr.
(lower_builtin_setjmp): Likewise.
* expr.c (emit_block_move_via_libcall): Use build_call_expr.
(set_storage_via_libcall): Likewise.
(safe_from_p): Add tcc_vl_exp case. Use TREE_OPERAND_LENGTH
instead of TREE_CODE_LENGTH.
(expand_expr_real_1): Use new CALL_EXPR accessors.
* tree-browser.c (store_child_info): Use TREE_OPERAND_LENGTH and
generalize to handle any number of operands.
(TB_parent_eq): Likewise.
* predict.c (expr_expected_value): Use new CALL_EXPR accessors.
(strip_builtin_expect): Likewise.
* function.c (gimplify_parameters): Use build_call_expr.
* tree-vectorizer.c (vect_is_simple_reduction): Use TREE_OPERAND_LENGTH
instead of TREE_CODE_LENGTH.
* ipa-type-escape.c (check_call): Use new CALL_EXPR iterators.
(scan_for_refs): Add case tcc_vl_exp for CALL_EXPR.
* tree-data-ref.c (get_references_in_stmt): Use new CALL_EXPR
iterators.
* gimplify.c (build_stack_save_restore): Use build_call_expr.
(gimplify_decl_expr): Likewise.
(gimplify_call_expr): Use fold_call_expr instead of fold_builtin.
Use new CALL_EXPR iterators.
(gimplify_modify_expr_to_memcpy): Use build_call_expr.
(gimplify_modify_expr_to_memset): Likewise.
(gimplify_variable_sized_compare): Likewise.
(gimplify_omp_atomic_fetch_op): Likewise.
(gimplify_omp_atomic_pipeline): Likewise.
(gimplify_omp_atomic_mutex): Likewise.
(gimplify_function_tree): Likewise.
* calls.c (alloca_call_p): Use new CALL_EXPR accessors.
(call_expr_flags): Likewise.
(expand_call): Likewise.
* except.c (expand_builtin_eh_return_data_regno): Pass entire
CALL_EXPR as parameter instead of arglist. Use new CALL_EXPR
accessors.
* coverage.c (create_coverage): Use build_call_expr.
* tree-ssa-pre.c (expression_node_pool, list_node_pool): Delete.
(temp_call_expr_obstack): New.
(pool_copy_list): Delete.
(temp_copy_call_expr): New.
(phi_translate): Add case tcc_vl_exp for CALL_EXPR. Use new
CALL_EXPR accessors. Get rid of special goo for copying argument
lists and use temp_copy_call_expr instead.
(valid_in_sets): Add case tcc_vl_exp for CALL_EXPR. Use new
CALL_EXPR accessors.
(create_expression_by_pieces): Likewise. Use build_call_array
to construct the result instead of fold_build3.
(create_value_expr_from): Add tcc_vl_exp. Delete special goo for
dealing with argument lists.
(init_pre): Remove references to expression_node_pool and
list_node_pool. Init temp_call_expr_obstack instead.
(fini_pre): Remove references to expression_node_pool and
list_node_pool.
* tree-sra.c (sra_walk_call_expr): Use new CALL_EXPR accessors
and walk arguments explicitly instead of as a list.
* tree-mudflap.c (mf_build_check_statement_for): Use build_call_expr.
(mx_register_decls): Likewise.
(mudflap_register_call): Likewise.
(mudflap_finish_file): Likewise.
* ipa-prop.c (ipa_callsite_compute_count): Use new CALL_EXPR accessors.
(ipa_callsite_compute_param): Likewise.
* tree-vect-patterns.c (vect_recog_pow_pattern): Use new CALL_EXPR
accessors and constructor.
* tree-nested.c (convert_nl_goto_reference): Use new CALL_EXPR
accessors and constructor.
(convert_tramp_reference): Likewise.
(convert_call_expr): Likewise.
(finalize_nesting_tree_1): Likewise.
* tree-ssa.c (tree_ssa_useless_type_conversion): Use new CALL_EXPR
accessors.
* tree-ssa-loop-prefetch.c (issue_prefetch_ref): Use build_call_expr.
* tree-inline.c (initialize_inlined_parameters): Pass entire
CALL_EXPR as parameter instead of arglist. Use new CALL_EXPR
accessors.
(estimate_num_insns_1): Use new CALL_EXPR accessors.
(expand_call_inline): Tidy up call to initialize_inlined_parameters.
* tree-vect-transform.c (vect_create_epilog_for_reduction): Use
TREE_OPERAND_LENGTH instead of TREE_CODE_LENGTH.
(vectorizable_reduction): Likewise.
(vectorizable_call): Use new CALL_EXPR iterators.
(vectorizable_conversion): Use build_call_expr.
(vectorizable_operation): Use TREE_OPERAND_LENGTH.
(vect_gen_widened_results_half): Use build_call_expr.
(vect_setup_realignment): Likewise.
(vectorizable_live_operation): Use TREE_OPERAND_LENGTH.
* tree-object-size.c (alloc_object_size): Use new CALL_EXPR accessors.
(pass_through_call): Likewise.
(compute_object_sizes): Likewise. Use fold_call_expr instead of
fold_builtin.
* tree-profile.c (tree_gen_interval_profiler): Use build_call_expr.
(tree_gen_pow2_profiler): Likewise.
(tree_gen_one_value_profiler): Likewise.
(tree_gen_ic_func_profiler): Likewise.
(tree_gen_average_profiler): Likewise.
(tree_gen_ior_profiler): Likewise.
* tree-ssa-structalias.c (get_constraint_for): Add case tcc_vl_exp.
(find_func_aliases): Use new CALL_EXPR accessors. Add case
tcc_vl_exp. Use TREE_OPERAND_LENGTH instead of TREE_CODE_LENGTH.
* tree-ssa-reassoc.c (get_rank): Use TREE_OPERAND_LENGTH instead
of TREE_CODE_LENGTH.
* stmt.c (warn_if_unused_value): Use TREE_OPERAND_LENGTH instead
of TREE_CODE_LENGTH.
* convert.c (convert_to_real): Use new CALL_EXPR accessors and
constructor.
(convert_to_integer): Likewise.
* tree-ssa-operands.c (get_call_expr_operands): Use new CALL_EXPR
accessors.
2007-02-15 Sandra Loosemore <sandra@codesourcery.com>
Brooks Moses <brooks.moses@codesourcery.com>
Lee Millward <lee.millward@codesourcery.com>
* config/alpha/alpha.c (alpha_expand_builtin): Use new CALL_EXPR
accessors.
* config/frv/frv.c (frv_expand_builtin): Likewise.
* config/s390/s390.c (s390_expand_builtin): Likewise.
* config/sparc/sparc.c (sparc_gimplify_va_arg): Use build_call_expr.
(sparc_expand_builtin): Use new CALL_EXPR accessors.
* config/i386/i386.c (ix86_function_ok_for_sibcall): Likewise.
(ix86_expand_binop_builtin): Pass entire CALL_EXPR as parameter
instead of arglist. Use new CALL_EXPR accessors on it. Fix callers.
(ix86_expand_store_builtin): Likewise.
(ix86_expand_unop_builtin): Likewise.
(ix86_expand_unop1_builtin): Likewise.
(ix86_expand_sse_compare): Likewise.
(ix86_expand_sse_comi): Likewise.
(ix86_expand_vec_init_builtin): Likewise.
(ix86_expand_vec_ext_builtin): Likewise.
(ix86_expand_vec_set_builtin): Likewise.
(ix86_expand_builtin): Use new CALL_EXPR accessors.
* config/sh/sh.c (sh_expand_builtin): Use new CALL_EXPR accessors.
* config/c4x/c4x.c (c4x_expand_builtin): Likewise.
* config/iq2000/iq2000.c (expand_one_builtin): Pass entire CALL_EXPR
instead of arglist. Use new CALL_EXPR accessors. Fix callers.
(iq2000_expand_builtin): Use new CALL_EXPR accessors.
* config/rs6000/rs6000-c.c (altivec_build_resolved_builtin): Use
build_call_expr.
* config/rs6000/rs6000.c (rs6000_gimplify_va_arg): Likewise.
(rs6000_expand_unop_builtin): Pass entire CALL_EXPR instead of
arglist. Use new CALL_EXPR accessors. Fix callers.
(altivec_expand_abs_builtin): Likewise.
(rs6000_expand_binop_builtin): Likewise.
(altivec_expand_predicate_builtin): Likewise.
(altivec_expand_lv_builtin): Likewise.
(spe_expand_stv_builtin): Likewise.
(altivec_expand_stv_builtin): Likewise.
(rs6000_expand_ternop_builtin): Likewise.
(altivec_expand_ld_builtin): Use new CALL_EXPR accessors.
(altivec_expand_st_builtin): Likewise.
(altivec_expand_dst_builtin): Likewise.
(altivec_expand_vec_init_builtin): Pass entire CALL_EXPR instead of
arglist. Use new CALL_EXPR accessors. Fix callers.
(altivec_expand_vec_set_builtin): Likewise.
(altivec_expand_vec_ext_builtin): Likewise.
(altivec_expand_builtin): Use new CALL_EXPR accessors.
(spe_expand_builtin): Likewise.
(spe_expand_predicate_builtin): Pass entire CALL_EXPR instead of
arglist. Use new CALL_EXPR accessors. Fix callers.
(spe_expand_evsel_builtin): Likewise.
(rs6000_expand_builtin): Use new CALL_EXPR accessors. VCFUX and
FCFSX cases must construct whole new CALL_EXPR, not just arglist.
* config/arm/arm.c (arm_expand_binop_builtin): Pass entire CALL_EXPR
instead of arglist. Use new CALL_EXPR accessors. Fix callers.
(arm_expand_unop_builtin): Likewise.
(arm_expand_builtin): Use new CALL_EXPR accessors.
* config/mips/mips.c (mips_expand_builtin): Use new CALL_EXPR
accessors.
* config/bfin/bfin.c (bfin_expand_binop_builtin): Pass entire CALL_EXPR
instead of arglist. Use new CALL_EXPR accessors. Fix callers.
(bfin_expand_unop_builtin): Likewise.
(bfin_expand_builtin): Use new CALL_EXPR accessors.
2007-02-15 Sandra Loosemore <sandra@codesourcery.com>
Brooks Moses <brooks.moses@codesourcery.com>
Lee Millward <lee.millward@codesourcery.com>
* c-semantics.c (build_stmt): Add internal diagnostic check.
* c-pretty-print.c (pp_c_postfix_expression): Use new CALL_EXPR
accessors. Print arguments explicitly instead of as a list.
* c-typeck.c (build_function_call): Use new CALL_EXPR constructors.
* c-omp.c (c_finish_omp_barrier): Use build_call_expr.
(c_finish_omp_flish): Likewise.
* c-common.c (verify_tree): Use new CALL_EXPR accessors. Traverse
arguments explicitly instead of as a list. Use TREE_OPERAND_LENGTH
instead of TREE_CODE_LENGTH.
(check_function_arguments_recurse): Use new CALL_EXPR accessors.
(c_warn_unused_result): Likewise.
2007-02-15 Sandra Loosemore <sandra@codesourcery.com>
Brooks Moses <brooks.moses@codesourcery.com>
Lee Millward <lee.millward@codesourcery.com>
* cp-tree.def (AGGR_INIT_EXPR): Adjust documentation.
Change class to tcc_vl_exp.
* call.c (build_call): Use build_call_list instead
of build3.
(build_over_call): Likewise.
(build_new_method_call): Use build_min_non_dep_call_list
instead of build_min_non_dep.
* error.c (dump_call_expr_args): New function.
(dump_aggr_init_expr_args): New function.
(dump_expr) <AGGR_INIT_EXPR, CALL_EXPR, INDIRECT_REF>: Use them.
Update to use new CALL_EXPR and AGGR_INIT_EXPR accessor macros.
* cvt.c (convert_to_void): Use build_call_array instead
of build3; use new AGGR_INIT_EXPR accessor macros.
* mangle.c (write_expression): Use TREE_OPERAND_LENGTH
instead of TREE_CODE_LENGTH.
* dump.c (cp_dump_tree) <AGGR_INIT_EXPR>: Update to use new
AGGR_INIT_EXPR accessor macros.
* cp-gimplify.c (cp_gimplify_init_expr): Use
AGGR_INIT_EXPR_SLOT to set the slot operand.
* cp-tree.h (AGGR_INIT_EXPR_FN): New macro.
(AGGR_INIT_EXPR_SLOT): New macro.
(AGGR_INIT_EXPR_ARG): New macro.
(aggr_init_expr_nargs): New macro.
(AGGR_INIT_EXPR_ARGP): New macro.
(aggr_init_expr_arg_iterator): New.
(init_aggr_init_expr_arg_iterator): New.
(next_aggr_init_expr_arg): New.
(first_aggr_init_expr_arg): New.
(more_aggr_init_expr_args_p): New.
(FOR_EACH_AGGR_INIT_EXPR_ARG): New.
(stabilize_aggr_init): New declaration.
(build_min_non_dep_call_list): Likewise.
* tree.c (process_aggr_init_operands): New function.
(build_aggr_init_array) New function.
(build_cplus_new): Update to use new CALL_EXPR and
AGGR_INIT_EXPR accessor macros. Replace use of build3 with
build_aggr_init_array.
(build_min_non_dep_call_list) New function.
(build_min_nt): Assert input code parameter is not a variable
length expression class.
(build_min, build_min_non_dep): Likewise.
(cp_tree_equal) <CALL_EXPR>: Iterate through the arguments
to check for equality instead of recursing. Handle tcc_vl_exp
tree code classes.
(stabilize_call): Update to only handle CALL_EXPRs, not
AGGR_INIT_EXPRs; use new CALL_EXPR accessor macros.
(stabilize_aggr_init): New function.
(stabilize_init): Use it.
* cxx-pretty-print.c (pp_cxx_postfix_expression)
<AGGR_INIT_EXPR, CALL_EXPR>: Update to use new CALL_EXPR and
AGGR_INIT_EXPR accessor macros and argument iterators.
* pt.c (tsubst_copy) <CALL_EXPR>: Replace build_nt with
build_vl_exp. Iterate through the operands, recursively
processing each one.
(tsubst_copy_and_build) <CALL_EXPR>: Update to use new
CALL_EXPR accessor macros.
(value_dependent_expression_p) <default>: Handle tcc_vl_exp
tree code classes. Use TREE_OPERAND_LENGTH instead of
TREE_CODE_LENGTH.
* semantics.c (finish_call_expr): Use build_nt_call_list
instead of build_nt.
(simplify_aggr_init_expr): Update to use new AGGR_INIT_EXPR
accessor macros. Use build_call_array to construct the
CALL_EXPR node instead of build3
* decl2.c (build_offset_ref_call_from_tree): Use
build_nt_call_list and build_min_non_dep_call_list instead
of build_min_nt and build_min_non_dep.
* parser.c (cp_parser_postfix_expression) <CPP_OPEN_PAREN>:
Use build_nt_call_list instead of build_min_nt.
2007-02-15 Sandra Loosemore <sandra@codesourcery.com>
Brooks Moses <brooks.moses@codesourcery.com>
Lee Millward <lee.millward@codesourcery.com>
* java-tree.h (BUILD_MONITOR_ENTER): Use build_call_nary instead
of build3.
(BUILD_MONITOR_EXIT): Likewise.
* java-gimplify.c (java_gimplify_component_ref): Use build_call_expr.
(java_gimplify_modify_expr): Likewise.
* class.c (cache_this_class_ref): Use build_call_expr.
(build_static_field_ref): Likewise.
(emit_indirect_register_classes): Likewise.
(emit_register_classes): Likewise.
* resource.c (write_resource_constructor): Use build_call_expr.
* builtins.c (builtin_creator_function): Change interpretation of
the second parameter to be the whole CALL_EXPR instead of the arglist.
(max_builtin): Tweak parameter list. Use new CALL_EXPR accessors.
(min_builtin): Likewise.
(abs_builtin): Likewise.
(java_build_function_call_expr): Likewise.
(convert_real): Likewise.
(UNMARSHAL3): Likewise.
(UNMARSHAL4): Likewise.
(UNMARSHAL5): Likewise.
(build_arglist_for_builtin): Delete. Fix callers to use
build_call_expr instead.
(putObject_builtin): Tweak parameter list. Use new CALL_EXPR
accessors.
(compareAndSwapInt_builtin): Likewise.
(compareAndSwapLong_builtin): Likewise.
(compareAndSwapObject_builtin): Likewise.
(putVolatile_builtin): Likewise.
(getVolatile_builtin): Likewise.
(VMSupportsCS8_builtin): Likewise.
(check_for_builtin): Pass entire CALL_EXPR to builtin expander
instead of arglist.
* expr.c (build_java_athrow): Use build_call_nary instead of build3.
(build_java_throw_out_of_bounds_exception): Likewise.
(java_check_reference): Likewise.
(build_java_arraystore_check): Likewise.
(build_newarray): Likewise.
(build_anewarray): Likewise.
(expand_java_multinewarray): Use build_call_list instead of build3.
(build_java_monitor): Use build_call_nary instead of build3.
(java_create_object): Likewise.
(expand_java_NEW): Likewise.
(build_instanceof): Likewise.
(expand_java_CHECKCAST): Likewise.
(build_java_soft_divmod): Likewise.
(build_java_binop): Likewise.
(build_field_ref): Likewise.
(build_class_init): Likewise.
(rewrite_arglist_getcaller): Use build_call_expr.
(build_invokeinterface): Use build_call_nary instead of build3.
(expand_invoke): Use build_call_list instead of build3.
(build_jni_stub): Use build_call_nary, build_call_list, or
build_call_expr instead of build3.
(expand_java_field_op): Use build_call_expr instead of build3.
(force_evaluation_order): Use new CALL_EXPR accessors.
* lang.c (java_get_callee_fndecl): Use new CALL_EXPR accessors.
2007-02-15 Sandra Loosemore <sandra@codesourcery.com>
Brooks Moses <brooks.moses@codesourcery.com>
Lee Millward <lee.millward@codesourcery.com>
* objc-act.c (receiver_is_class_object): Use new CALL_EXPR accessors.
(objc_get_callee_fndecl): Likewise.
2007-02-15 Sandra Loosemore <sandra@codesourcery.com>
Brooks Moses <brooks.moses@codesourcery.com>
Lee Millward <lee.millward@codesourcery.com>
* trans-expr.c (gfc_conv_power_op): Use build_call_expr.
(gfc_conv_string_tmp): Likewise.
(gfc_conv_concat_op): Likewise.
(gfc_build_compare_string): Likewise.
(gfc_conv_function_call): Use build_call_list instead of build3.
* trans-array.c (gfc_trans_allocate_array_storage): Use
build_call_expr.
(gfc_grow_array): Likewise.
(gfc_trans_array_ctor_element): Likewise.
(gfc_trans_array_constructor_value): Likewise.
(gfc_array_allocate): Likewise.
(gfc_array_deallocate): Likewise.
(gfc_trans_auto_array_allocation): Likewise.
(gfc_trans_dummy_array_bias): Likewise.
(gfc_conv_array_parameter): Likewise.
(gfc_trans_dealloc_allocated): Likewise.
(gfc_duplicate_allocatable): Likewise.
* trans-openmp.c (gfc_trans_omp_barrier): Use build_call_expr.
(gfc_trans_omp_flush): Likewise.
* trans-stmt.c (gfc_conv_elementel_dependencies): Use build_call_expr.
(gfc_trans_pause): Likewise.
(gfc_trans_stop): Likewise.
(gfc_trans_character_select): Likewise.
(gfc_do_allocate): Likewise.
(gfc_trans_assign_need_temp): Likewise.
(gfc_trans_pointer_assign_need_temp): Likewise.
(gfc_trans_forall_1): Likewise.
(gfc_trans_where_2): Likewise.
(gfc_trans_allocate): Likewise.
(gfc_trans_deallocate): Likewise.
* trans.c (gfc_trans_runtime_check): Use build_call_expr.
* trans-io.c (gfc_trans_open): Use build_call_expr.
(gfc_trans_close): Likewise.
(build_filepos): Likewise.
(gfc_trans_inquire): Likewise.
(NML_FIRST_ARG): Delete.
(NML_ADD_ARG): Delete.
(transfer_namelist_element): Use build_call_expr.
(build_dt): Likewise.
(gfc_trans_dt_end): Likewise.
(transfer_expr): Likewise.
(transfer_array-desc): Likewise.
* trans-decl.c (gfc_generate_function_code): Use build_call_expr.
(gfc_generate_constructors): Likewise.
* trans-intrinsic.c (gfc_conv_intrinsic_ctime): Use build_call_expr.
(gfc_conv_intrinsic_fdate): Likewise.
(gfc_conv_intrinsic_ttynam): Likewise.
(gfc_conv_intrinsic_array_transfer): Likewise.
(gfc_conv_associated): Likewise.
(gfc_conv_intrinsic_si_kind): Likewise.
(gfc_conv_intrinsic_trim): Likewise.
(gfc_conv_intrinsic_repeat: Likewise.
(gfc_conv_intrinsic_iargc): Likewise.
Co-Authored-By: Brooks Moses <brooks.moses@codesourcery.com>
Co-Authored-By: Lee Millward <lee.millward@codesourcery.com>
From-SVN: r122018
2007-02-16 00:50:49 +01:00
|
|
|
tree addr, addr_base, prefetch, write_p;
|
2006-02-14 14:51:51 +01:00
|
|
|
block_stmt_iterator bsi;
|
|
|
|
unsigned n_prefetches, ap;
|
|
|
|
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
fprintf (dump_file, "Issued prefetch for %p.\n", (void *) ref);
|
|
|
|
|
|
|
|
bsi = bsi_for_stmt (ref->stmt);
|
|
|
|
|
|
|
|
n_prefetches = ((unroll_factor + ref->prefetch_mod - 1)
|
|
|
|
/ ref->prefetch_mod);
|
|
|
|
addr_base = build_fold_addr_expr_with_type (ref->mem, ptr_type_node);
|
|
|
|
addr_base = force_gimple_operand_bsi (&bsi, unshare_expr (addr_base), true, NULL);
|
2006-11-12 21:05:49 +01:00
|
|
|
write_p = ref->write_p ? integer_one_node : integer_zero_node;
|
2006-02-14 14:51:51 +01:00
|
|
|
|
|
|
|
for (ap = 0; ap < n_prefetches; ap++)
|
|
|
|
{
|
|
|
|
/* Determine the address to prefetch. */
|
|
|
|
delta = (ahead + ap * ref->prefetch_mod) * ref->group->step;
|
|
|
|
addr = fold_build2 (PLUS_EXPR, ptr_type_node,
|
|
|
|
addr_base, build_int_cst (ptr_type_node, delta));
|
|
|
|
addr = force_gimple_operand_bsi (&bsi, unshare_expr (addr), true, NULL);
|
|
|
|
|
|
|
|
/* Create the prefetch instruction. */
|
tree.h (enum tree_code_class): Add tcc_vl_exp.
2007-02-15 Sandra Loosemore <sandra@codesourcery.com>
Brooks Moses <brooks.moses@codesourcery.com>
Lee Millward <lee.millward@codesourcery.com>
* tree.h (enum tree_code_class): Add tcc_vl_exp.
(VL_EXP_CLASS_P): New.
(TREE_OPERAND_CHECK): Use TREE_OPERAND_LENGTH instead of
TREE_CODE_LENGTH.
(TREE_OPERAND_CHECK_CODE): Likewise.
(GIMPLE_STMT_OPERAND_CHECK): Likewise.
(TREE_RTL_OPERAND_CHECK): Likewise.
(tree_operand_check_failed): Make second parameter the whole tree
instead of its code. Fixed callers.
(VL_EXP_CHECK): New.
(TREE_OPERAND_LENGTH): New.
(VL_EXP_OPERAND_LENGTH): New.
(CALL_EXPR_FN): New.
(CALL_EXPR_STATIC_CHAIN): New.
(CALL_EXPR_ARGS): New.
(CALL_EXPR_ARG): New.
(call_expr_nargs): New.
(CALL_EXPR_ARGP): New.
(build_nt_call_list): Declare.
(build_vl_exp_stat): Declare.
(build_vl_exp): New.
(build_call_list): Declare.
(build_call_nary): Declare.
(build_call_valist): Declare.
(build_call_array): Declare.
(call_expr_arg): Declare.
(call_expr_argp): Declare.
(call_expr_arglist): Declare.
(fold_build_call_list): Declare.
(fold_build_call_list_initializer): Declare.
(fold_call_expr): Declare to replace fold_builtin.
(fold_builtin_fputs): Update to agree with modified definition.
(fold_builtin_strcpy): Likewise.
(fold_builtin_strncpy): Likewise.
(fold_builtin_memory_chk): Likewise.
(fold_builtin_stxcpy_chk): Likewise.
(fold_builtin_strncpy_chk): Likewise.
(fold_builtin_next_arg): Likewise.
(fold_build_call_expr): Declare.
(fold_builtin_call_list): Declare.
(fold_builtin_call_valist): Declare.
(build_call_expr): Declare.
(validate_arglist): Update to agree with modified definition.
(tree_operand_length): New.
(call_expr_arg_iterator): New.
(init_call_expr_arg_iterator): New.
(next_call_expr_arg): New.
(first_call_expr_arg): New.
(more_call_expr_args_p): New.
(FOR_EACH_CALL_EXPR_ARG): New.
* tree.c (tree_code_class_string): Add entries for tcc_vl_exp
and tcc_gimple_stmt.
(tree_code_size): Update documentation. Use sizeof (tree) rather
than sizeof (char *).
(tree_size): Likewise. Add case for tcc_vl_exp.
(tree_node_structure): Add case for tcc_vl_exp.
(contains_placeholder_p): Likewise.
(substitute_in_expr): Likewise.
(substitute_placeholder_in_expr): Likewise.
(stabilize_reference_1): Likewise.
(build3_stat): Remove logic for CALL_EXPRs. Replace with assertion
to diagnose breakage of this interface for constructing CALL_EXPRs.
(build_nt): Add similar assertion here.
(build_nt_call_list): New.
(simple_cst_equal) <CALL_EXPR>: Rewrite to use new accessors.
(iterative_hash_expr): Use TREE_OPERAND_LENGTH instead of
TREE_CODE_LENGTH.
(get_callee_fndecl): Use new CALL_EXPR accessors.
(tree_operand_check_failed): Change parameters to pass entire node
instead of its code, so that we can call TREE_OPERAND_LENGTH on it.
(process_call_operands): New.
(build_vl_exp_stat): New.
(build_call_list): New.
(build_call_nary): New.
(build_call_valist): New.
(build_call_array): New.
(walk_tree): Use TREE_OPERAND_LENGTH instead of TREE_CODE_LENGTH.
(call_expr_arglist): New.
* tree.def (CALL_EXPR): Change representation of CALL_EXPRs to use
tcc_vl_exp instead of a fixed-size tcc_expression.
* doc/c-tree.texi (CALL_EXPR): Document new representation and
accessors for CALL_EXPRs.
(AGGR_INIT_EXPR): Likewise.
2007-02-15 Sandra Loosemore <sandra@codesourcery.com>
Brooks Moses <brooks.moses@codesourcery.com>
Lee Millward <lee.millward@codesourcery.com>
* builtins.c (c_strlen): Return NULL_TREE instead of 0.
(expand_builtin_nonlocal_goto): Change parameter to be entire
CALL_EXPR instead of an arglist. Use new CALL_EXPR accessors.
(expand_builtin_prefetch): Likewise.
(expand_builtin_classify_type): Likewise.
(mathfn_built_in): Return NULL_TREE instead of 0.
(expand_errno_check): Use new CALL_EXPR accessors.
(expand_builtin_mathfn): Use new CALL_EXPR accessors and constructors.
Return NULL_RTX instead of 0.
(expand_builtin_mathfn_2): Likewise.
(expand_builtin_mathfn_3): Likewise.
(expand_builtin_interclass_mathfn): Likewise.
(expand_builtin_sincos): Likewise.
(expand_builtin_cexpi): Likewise.
(expand_builtin_int_roundingfn): Likewise.
(expand_builtin_int_roundingfn_2): Likewise.
(expand_builtin_pow): Likewise.
(expand_builtin_powi): Likewise.
(expand_builtin_strlen): Pass entire CALL_EXPR as parameter instead
of arglist, fixing callers appropriately. Use new CALL_EXPR
accessors and constructors. Return NULL_RTX instead of 0.
(expand_builtin_strstr): Likewise.
(expand_builtin_strchr): Likewise.
(expand_builtin_strrchr): Likewise.
(expand_builtin_strpbrk): Likewise.
(expand_builtin_memcpy): Likewise.
(expand_builtin_mempcpy): Likewise.
(expand_builtin_mempcpy_args): New.
(expand_builtin_memmove): Similarly to expand_builtin_mempcpy.
(expand_builtin_memmove_args): New.
(expand_builtin_bcopy): Similarly to expand_builtin_mempcpy.
(expand_movstr): Likewise.
(expand_builtin_strcpy): Likewise.
(expand_builtin_strcpy_args): New.
(expand_builtin_stpcpy): Similarly to expand_builtin_strcpy.
(expand_builtin_strncpy): Likewise.
(expand_builtin_memset): Likewise.
(expand_builtin_memset_args): New.
(expand_builtin_bzero): Similarly to expand_builtin_memset.
(expand_builtin_memcmp): Likewise.
(expand_builtin_strcmp): Likewise.
(expand_builtin_strncmp): Likewise.
(expand_builtin_strcat): Likewise.
(expand_builtin_strncat): Likewise.
(expand_builtin_strspn): Likewise.
(expand_builtin_strcspn): Likewise.
(expand_builtin_args_info): Likewise.
(expand_builtin_va_start): Likewise.
(gimplify_va_arg_expr): Likewise.
(expand_builtin_va_end): Likewise.
(expand_builtin_va_copy): Likewise.
(expand_builtin_frame_address): Likewise.
(expand_builtin_alloca): Likewise.
(expand_builtin_bswap): Likewise.
(expand_builtin_unop): Likewise.
(expand_builtin_fputs): Likewise.
(expand_builtin_expect): Likewise.
(expand_builtin_fabs): Likewise.
(expand_builtin_copysign): Likewise.
(expand_builtin_printf): Likewise.
(expand_builtin_fprintf): Likewise.
(expand_builtin_sprintf): Likewise.
(expand_builtin_init_trampoline): Likewise.
(expand_builtin_signbit): Likewise.
(expand_builtin_fork_or_exec): Likewise.
(expand_builtin_sync_operation): Likewise.
(expand_builtin_compare_and_swap): Likewise.
(expand_builtin_lock_test_and_set): Likewise.
(expand_builtin_lock_release): Likewise.
(expand_builtin): Likewise.
(builtin_mathfn_code): Likewise.
(fold_builtin_constant_p): Pass call arguments individually instead
of as an arglist, fixing callers appropriately. Use new CALL_EXPR
accessors and constructors. Return NULL_TREE instead of 0.
(fold_builtin_expect): Likewise.
(fold_builtin_classify_type): Likewise.
(fold_builtin_strlen): Likewise.
(fold_builtin_nan): Likewise.
(integer_valued_real_p): Likewise.
(fold_trunc_transparent_mathfn): Likewise.
(fold_fixed_mathfn): Likewise.
(fold_builtin_cabs): Likewise.
(fold_builtin_sqrt): Likewise.
(fold_builtin_cbrt): Likewise.
(fold_builtin_cos): Likewise.
(fold_builtin_cosh): Likewise.
(fold_builtin_tan): Likewise.
(fold_builtin_sincos): Likewise.
(fold_builtin_cexp): Likewise.
(fold_builtin_trunc): Likewise.
(fold_builtin_floor): Likewise.
(fold_builtin_ceil): Likewise.
(fold_builtin_round): Likewise.
(fold_builtin_int_roundingfn): Likewise.
(fold_builtin_bitop): Likewise.
(fold_builtin_bswap): Likewise.
(fold_builtin_logarithm): Likewise.
(fold_builtin_hypot): Likewise.
(fold_builtin_pow): Likewise.
(fold_builtin_powi): Likewise.
(fold_builtin_exponent): Likewise.
(fold_builtin_memset): Likewise.
(fold_builtin_bzero): Likewise.
(fold_builtin_memory_op): Likewise.
(fold_builtin_bcopy): Deleted; call site changed to invoke
fold_builtin_memory_op directly.
(fold_builtin_strcpy): Similarly as for fold_builtin_memory_op.
(fold_builtin_strncpy): Likewise.
(fold_builtin_memcmp): Likewise.
(fold_builtin_strcmp): Likewise.
(fold_builtin_strncmp): Likewise.
(fold_builtin_signbit): Likewise.
(fold_builtin_copysign): Likewise.
(fold_builtin_isascii): Likewise.
(fold_builtin_toascii): Likewise.
(fold_builtin_isdigit): Likewise.
(fold_builtin_fabs): Likewise.
(fold_builtin_abs): Likewise.
(fold_builtin_fmin_fmax): Likewise.
(fold_builtin_carg): Likewise.
(fold_builtin_classify): Likewise.
(fold_builtin_unordered_cmp): Likewise.
(fold_builtin_0, fold_builtin_2, fold_builtin_3, fold_builtin_4):
New functions split out from fold_builtin_1.
(fold_builtin_n): New.
(fold_builtin_varargs): New.
(fold_builtin): Deleted. Most callers changed to use fold_call_expr
instead.
(fold_call_expr): New.
(build_function_call_expr): Rewrite to use new helper function.
(fold_builtin_call_list): New.
(build_call_expr): New.
(fold_builtin_call_valist): New.
(rewrite_call_expr): New.
(validate_arg): New.
(validate_arglist): Change parameter to be entire CALL_EXPR instead
of an arglist. Change return type to bool. Use new CALL_EXPR
accessors.
(fold_builtin_strstr): Pass call arguments individually instead
of as an arglist, fixing callers appropriately. Use new CALL_EXPR
accessors and constructors. Return NULL_TREE instead of 0.
(fold_builtin_strchr): Likewise.
(fold_builtin_strrchr): Likewise.
(fold_builtin_strpbrk): Likewise.
(fold_builtin_strcat): Likewise.
(fold_builtin_strncat): Likewise.
(fold_builtin_strspn): Likewise.
(fold_builtin_strcspn): Likewise.
(fold_builtin_fputs): Likewise.
(fold_builtin_next_arg): Likewise.
(fold_builtin_sprintf): Likewise.
(expand_builtin_object_size): Use new CALL_EXPR accessors. Use
NULL_RTX instead of 0.
(expand_builtin_memory_chk): Likewise.
(maybe_emit_chk_warning): Likewise.
(maybe_emit_sprintf_chk_warning): Likewise.
(fold_builtin_object_size): Pass call arguments individually instead
of as an arglist, fixing callers appropriately. Use new CALL_EXPR
accessors and constructors. Return NULL_TREE instead of 0.
(fold_builtin_memory_chk): Likewise.
(fold_builtin_stxcpy_chk): Likewise.
(fold_builtin_strncpy_chk): Likewise.
(fold_builtin_strcat_chk): Likewise.
(fold_builtin_strcat_chk): Likewise.
(fold_builtin_strncat_chk): Likewise.
(fold_builtin_sprintf_chk): Likewise.
(fold_builtin_snprintf_chk): Likewise.
(fold_builtin_printf): Likewise.
(fold_builtin_vprintf): Likewise.
* fold-const.c (negate_expr_p): Use new CALL_EXPR accessors and
constructors.
(operand_equal_p): Add separate tcc_vl_exp/CALL_EXPR case.
(make_range): Use TREE_OPERAND_LENGTH instead of TREE_CODE_LENGTH.
(extract_muldiv_1): Add VL_EXP_CLASS_P case.
(fold_mathfn_compare): Use new CALL_EXPR accessors and constructors.
(fold_unary): Likewise.
(fold_binary): Likewise.
(fold_ternary): Remove CALL_EXPR case, since they are no longer
ternary expressions.
(fold): Add logic for tcc_vl_exp.
(fold_checksum_tree): Make it know about tcc_vl_exp. Use
TREE_OPERAND_LENGTH instead of TREE_CODE_LENGTH.
(fold_build3_stat): Add assertion to flag broken interface for
constructing CALL_EXPRs.
(fold_build_call_list): New.
(fold_build_call_list_initializer): New.
(tree_expr_nonnegative_p): Use new CALL_EXPR accessors and
constructors.
(fold_strip_sign_ops): Likewise.
2007-02-15 Sandra Loosemore <sandra@codesourcery.com>
Brooks Moses <brooks.moses@codesourcery.com>
Lee Millward <lee.millward@codesourcery.com>
* tree-dump.c (dequeue_and_dump) <CALL_EXPR>: Use new CALL_EXPR
accessors and dump arguments explicitly.
* tree-pretty-print.c (do_niy): Use TREE_OPERAND_LENGTH instead of
TREE_CODE_LENGTH.
(dump_generic_node): Use new CALL_EXPR accessors and walk arguments
explicitly.
(print_call_name): Use new CALL_EXPR accessors.
* print-tree.c (print_node): Add case tcc_vl_exp. Print
CALL_EXPR arguments explicitly instead of as a list. Use
TREE_OPERAND_LENGTH instead of TREE_CODE_LENGTH.
* tree-vrp.c (stmt_interesting_for_vrp): Use new CALL_EXPR accessors.
(vrp_visit_stmt): Likewise.
* tree-ssa-loop-im.c (outermost_invariant_loop_expr): Make it
know about tcc_vl_exp. Use TREE_OPERAND_LENGTH instead of
TREE_CODE_LENGTH.
(force_move_till_expr): Likewise.
* targhooks.c (default_external_stack_protect_fail): Use
build_call_expr instead of build_function_call_expr.
(default_hidden_stack_protect_fail): Likewise.
* tree-complex.c (expand_complex_libcall): Use build_call_expr to
build the call.
* cgraphbuild.c (build_cgraph_edges): Use new CALL_EXPR accessors
and walk arguments explicitly.
* tree-ssa-loop-niter.c (simplify_replace_tree): Use
TREE_OPERAND_LENGTH instead of TREE_CODE_LENGTH.
(expand_simple_operations): Likewise.
(infer_loop_bounds_from_array): Use new CALL_EXPR accessors.
* gengtype.c (adjust_field_tree_exp): Use TREE_OPERAND_LENGTH instead
of TREE_CODE_LENGTH.
(walk_type): Tweak walking of arrays not to blow up on CALL_EXPRs.
* optabs.c (expand_widen_pattern-expr): Use TREE_OPERAND_LENGTH
instead of TREE_CODE_LENGTH.
* value_prof.c (tree_ic): Use new CALL_EXPR accessors.
(tree_ic_transform): Likewise.
(interesting_stringop_to_profile_p): Pass entire CALL_EXPR as
parameter instead of arglist. Fix callers.
(tree_stringop_fixed_value): Use new CALL_EXPR accessors.
(tree_stringops_transform): Likewise.
(tree_indirect_call_to_profile): Likewise.
(tree_stringops_values_to_profile): Likewise.
* tree-tailcall.c (find_tail_calls): Use new CALL_EXPR iterator.
(eliminate_tail_call): Likewise.
* ipa-cp.c (ipcp_update_callgraph): Use new CALL_EXPR accessors.
* tree-scalar-evolution.c (chrec_contains_symbols_defined_in_loop):
Use TREE_OPERAND_LENGTH and generalize to handle any number of
operands.
(instantiate_parameters_1): Can't handle tcc_vl_exp here.
* omp-low.c (build_omp_barrier): Use build_call_expr.
(lower_rec_input_clauses): Likewise.
(lower_reduction_clauses): Likewise.
(expand_parallel_call): Likewise.
(maybe_catch_exception): Likewise.
(expand_omp_for_generic): Likewise.
(expand_omp_for_static_nochunk): Likewise.
(expand_omp_sections): Likewise.
(lower_omp_single_simple): Likewise.
(lower_omp_single_copy): Likewise.
(lower_omp_master): Likewise.
(lower_omp_ordered): Likewise.
(lower_omp_critical): Likewise.
* ipa-reference.c (check-call): Use new CALL_EXPR iterator.
(scan_for_static_refs): Create tcc_vl_exp case for CALL_EXPR.
* tree-gimple.c (is_gimple_call_addr): Fix doc.
(recalculate_side_effects): Use TREE_OPERAND_LENGTH instead of
TREE_CODE_LENGTH. Add tcc_vl_exp case.
* tree-chrec.c (chrec_contains_symbols): Use TREE_OPERAND_LENGTH
and generalize to handle any number of operands.
(chrec_contains_undetermined): Likewise.
(tree_contains_chrecs): Likewise.
(evolution_function_is_invariant_rec_p): Use TREE_OPERAND_LENGTH.
* cgraphunit.c (update_call_expr): Use new CALL_EXPR accessors.
* tree-ssa-ccp.c (ccp_fold): Use new CALL_EXPR accessors. Use
fold_call_expr instead of fold_builtin.
(ccp_fold_builtin): Likewise. Update calls into builtins.c to
match declarations there.
(fold_stmt): Use new CALL_EXPR constructor and accessors. Doc
updates.
* tree-ssa-loop-ivopts.c (expr_invariant_in_loop_p): Use
TREE_OPERAND_LENGTH instead of TREE_CODE_LENGTH.
* ipa-pure-const.c (check_call): Use new CALL_EXPR accessors.
(scan_function): Add case tcc_vl_exp for CALL_EXPR.
* tree-stdarg.c (execute_optimize_stdarg): Use new CALL_EXPR
accessors.
* tree-ssa-math-opts.c (execute_cse_sincos_1): Use build_call_expr.
(execute_cse_sincos): Use new CALL_EXPR accessors.
* tree-ssa-alias.c (find_used_portions): Use new CALL_EXPR iterator.
* gimple-low.c (lower_function_body): Use build_call_expr.
(lower_builtin_setjmp): Likewise.
* expr.c (emit_block_move_via_libcall): Use build_call_expr.
(set_storage_via_libcall): Likewise.
(safe_from_p): Add tcc_vl_exp case. Use TREE_OPERAND_LENGTH
instead of TREE_CODE_LENGTH.
(expand_expr_real_1): Use new CALL_EXPR accessors.
* tree-browser.c (store_child_info): Use TREE_OPERAND_LENGTH and
generalize to handle any number of operands.
(TB_parent_eq): Likewise.
* predict.c (expr_expected_value): Use new CALL_EXPR accessors.
(strip_builtin_expect): Likewise.
* function.c (gimplify_parameters): Use build_call_expr.
* tree-vectorizer.c (vect_is_simple_reduction): Use TREE_OPERAND_LENGTH
instead of TREE_CODE_LENGTH.
* ipa-type-escape.c (check_call): Use new CALL_EXPR iterators.
(scan_for_refs): Add case tcc_vl_exp for CALL_EXPR.
* tree-data-ref.c (get_references_in_stmt): Use new CALL_EXPR
iterators.
* gimplify.c (build_stack_save_restore): Use build_call_expr.
(gimplify_decl_expr): Likewise.
(gimplify_call_expr): Use fold_call_expr instead of fold_builtin.
Use new CALL_EXPR iterators.
(gimplify_modify_expr_to_memcpy): Use build_call_expr.
(gimplify_modify_expr_to_memset): Likewise.
(gimplify_variable_sized_compare): Likewise.
(gimplify_omp_atomic_fetch_op): Likewise.
(gimplify_omp_atomic_pipeline): Likewise.
(gimplify_omp_atomic_mutex): Likewise.
(gimplify_function_tree): Likewise.
* calls.c (alloca_call_p): Use new CALL_EXPR accessors.
(call_expr_flags): Likewise.
(expand_call): Likewise.
* except.c (expand_builtin_eh_return_data_regno): Pass entire
CALL_EXPR as parameter instead of arglist. Use new CALL_EXPR
accessors.
* coverage.c (create_coverage): Use build_call_expr.
* tree-ssa-pre.c (expression_node_pool, list_node_pool): Delete.
(temp_call_expr_obstack): New.
(pool_copy_list): Delete.
(temp_copy_call_expr): New.
(phi_translate): Add case tcc_vl_exp for CALL_EXPR. Use new
CALL_EXPR accessors. Get rid of special goo for copying argument
lists and use temp_copy_call_expr instead.
(valid_in_sets): Add case tcc_vl_exp for CALL_EXPR. Use new
CALL_EXPR accessors.
(create_expression_by_pieces): Likewise. Use build_call_array
to construct the result instead of fold_build3.
(create_value_expr_from): Add tcc_vl_exp. Delete special goo for
dealing with argument lists.
(init_pre): Remove references to expression_node_pool and
list_node_pool. Init temp_call_expr_obstack instead.
(fini_pre): Remove references to expression_node_pool and
list_node_pool.
* tree-sra.c (sra_walk_call_expr): Use new CALL_EXPR accessors
and walk arguments explicitly instead of as a list.
* tree-mudflap.c (mf_build_check_statement_for): Use build_call_expr.
(mx_register_decls): Likewise.
(mudflap_register_call): Likewise.
(mudflap_finish_file): Likewise.
* ipa-prop.c (ipa_callsite_compute_count): Use new CALL_EXPR accessors.
(ipa_callsite_compute_param): Likewise.
* tree-vect-patterns.c (vect_recog_pow_pattern): Use new CALL_EXPR
accessors and constructor.
* tree-nested.c (convert_nl_goto_reference): Use new CALL_EXPR
accessors and constructor.
(convert_tramp_reference): Likewise.
(convert_call_expr): Likewise.
(finalize_nesting_tree_1): Likewise.
* tree-ssa.c (tree_ssa_useless_type_conversion): Use new CALL_EXPR
accessors.
* tree-ssa-loop-prefetch.c (issue_prefetch_ref): Use build_call_expr.
* tree-inline.c (initialize_inlined_parameters): Pass entire
CALL_EXPR as parameter instead of arglist. Use new CALL_EXPR
accessors.
(estimate_num_insns_1): Use new CALL_EXPR accessors.
(expand_call_inline): Tidy up call to initialize_inlined_parameters.
* tree-vect-transform.c (vect_create_epilog_for_reduction): Use
TREE_OPERAND_LENGTH instead of TREE_CODE_LENGTH.
(vectorizable_reduction): Likewise.
(vectorizable_call): Use new CALL_EXPR iterators.
(vectorizable_conversion): Use build_call_expr.
(vectorizable_operation): Use TREE_OPERAND_LENGTH.
(vect_gen_widened_results_half): Use build_call_expr.
(vect_setup_realignment): Likewise.
(vectorizable_live_operation): Use TREE_OPERAND_LENGTH.
* tree-object-size.c (alloc_object_size): Use new CALL_EXPR accessors.
(pass_through_call): Likewise.
(compute_object_sizes): Likewise. Use fold_call_expr instead of
fold_builtin.
* tree-profile.c (tree_gen_interval_profiler): Use build_call_expr.
(tree_gen_pow2_profiler): Likewise.
(tree_gen_one_value_profiler): Likewise.
(tree_gen_ic_func_profiler): Likewise.
(tree_gen_average_profiler): Likewise.
(tree_gen_ior_profiler): Likewise.
* tree-ssa-structalias.c (get_constraint_for): Add case tcc_vl_exp.
(find_func_aliases): Use new CALL_EXPR accessors. Add case
tcc_vl_exp. Use TREE_OPERAND_LENGTH instead of TREE_CODE_LENGTH.
* tree-ssa-reassoc.c (get_rank): Use TREE_OPERAND_LENGTH instead
of TREE_CODE_LENGTH.
* stmt.c (warn_if_unused_value): Use TREE_OPERAND_LENGTH instead
of TREE_CODE_LENGTH.
* convert.c (convert_to_real): Use new CALL_EXPR accessors and
constructor.
(convert_to_integer): Likewise.
* tree-ssa-operands.c (get_call_expr_operands): Use new CALL_EXPR
accessors.
2007-02-15 Sandra Loosemore <sandra@codesourcery.com>
Brooks Moses <brooks.moses@codesourcery.com>
Lee Millward <lee.millward@codesourcery.com>
* config/alpha/alpha.c (alpha_expand_builtin): Use new CALL_EXPR
accessors.
* config/frv/frv.c (frv_expand_builtin): Likewise.
* config/s390/s390.c (s390_expand_builtin): Likewise.
* config/sparc/sparc.c (sparc_gimplify_va_arg): Use build_call_expr.
(sparc_expand_builtin): Use new CALL_EXPR accessors.
* config/i386/i386.c (ix86_function_ok_for_sibcall): Likewise.
(ix86_expand_binop_builtin): Pass entire CALL_EXPR as parameter
instead of arglist. Use new CALL_EXPR accessors on it. Fix callers.
(ix86_expand_store_builtin): Likewise.
(ix86_expand_unop_builtin): Likewise.
(ix86_expand_unop1_builtin): Likewise.
(ix86_expand_sse_compare): Likewise.
(ix86_expand_sse_comi): Likewise.
(ix86_expand_vec_init_builtin): Likewise.
(ix86_expand_vec_ext_builtin): Likewise.
(ix86_expand_vec_set_builtin): Likewise.
(ix86_expand_builtin): Use new CALL_EXPR accessors.
* config/sh/sh.c (sh_expand_builtin): Use new CALL_EXPR accessors.
* config/c4x/c4x.c (c4x_expand_builtin): Likewise.
* config/iq2000/iq2000.c (expand_one_builtin): Pass entire CALL_EXPR
instead of arglist. Use new CALL_EXPR accessors. Fix callers.
(iq2000_expand_builtin): Use new CALL_EXPR accessors.
* config/rs6000/rs6000-c.c (altivec_build_resolved_builtin): Use
build_call_expr.
* config/rs6000/rs6000.c (rs6000_gimplify_va_arg): Likewise.
(rs6000_expand_unop_builtin): Pass entire CALL_EXPR instead of
arglist. Use new CALL_EXPR accessors. Fix callers.
(altivec_expand_abs_builtin): Likewise.
(rs6000_expand_binop_builtin): Likewise.
(altivec_expand_predicate_builtin): Likewise.
(altivec_expand_lv_builtin): Likewise.
(spe_expand_stv_builtin): Likewise.
(altivec_expand_stv_builtin): Likewise.
(rs6000_expand_ternop_builtin): Likewise.
(altivec_expand_ld_builtin): Use new CALL_EXPR accessors.
(altivec_expand_st_builtin): Likewise.
(altivec_expand_dst_builtin): Likewise.
(altivec_expand_vec_init_builtin): Pass entire CALL_EXPR instead of
arglist. Use new CALL_EXPR accessors. Fix callers.
(altivec_expand_vec_set_builtin): Likewise.
(altivec_expand_vec_ext_builtin): Likewise.
(altivec_expand_builtin): Use new CALL_EXPR accessors.
(spe_expand_builtin): Likewise.
(spe_expand_predicate_builtin): Pass entire CALL_EXPR instead of
arglist. Use new CALL_EXPR accessors. Fix callers.
(spe_expand_evsel_builtin): Likewise.
(rs6000_expand_builtin): Use new CALL_EXPR accessors. VCFUX and
FCFSX cases must construct whole new CALL_EXPR, not just arglist.
* config/arm/arm.c (arm_expand_binop_builtin): Pass entire CALL_EXPR
instead of arglist. Use new CALL_EXPR accessors. Fix callers.
(arm_expand_unop_builtin): Likewise.
(arm_expand_builtin): Use new CALL_EXPR accessors.
* config/mips/mips.c (mips_expand_builtin): Use new CALL_EXPR
accessors.
* config/bfin/bfin.c (bfin_expand_binop_builtin): Pass entire CALL_EXPR
instead of arglist. Use new CALL_EXPR accessors. Fix callers.
(bfin_expand_unop_builtin): Likewise.
(bfin_expand_builtin): Use new CALL_EXPR accessors.
2007-02-15 Sandra Loosemore <sandra@codesourcery.com>
Brooks Moses <brooks.moses@codesourcery.com>
Lee Millward <lee.millward@codesourcery.com>
* c-semantics.c (build_stmt): Add internal diagnostic check.
* c-pretty-print.c (pp_c_postfix_expression): Use new CALL_EXPR
accessors. Print arguments explicitly instead of as a list.
* c-typeck.c (build_function_call): Use new CALL_EXPR constructors.
* c-omp.c (c_finish_omp_barrier): Use build_call_expr.
(c_finish_omp_flish): Likewise.
* c-common.c (verify_tree): Use new CALL_EXPR accessors. Traverse
arguments explicitly instead of as a list. Use TREE_OPERAND_LENGTH
instead of TREE_CODE_LENGTH.
(check_function_arguments_recurse): Use new CALL_EXPR accessors.
(c_warn_unused_result): Likewise.
2007-02-15 Sandra Loosemore <sandra@codesourcery.com>
Brooks Moses <brooks.moses@codesourcery.com>
Lee Millward <lee.millward@codesourcery.com>
* cp-tree.def (AGGR_INIT_EXPR): Adjust documentation.
Change class to tcc_vl_exp.
* call.c (build_call): Use build_call_list instead
of build3.
(build_over_call): Likewise.
(build_new_method_call): Use build_min_non_dep_call_list
instead of build_min_non_dep.
* error.c (dump_call_expr_args): New function.
(dump_aggr_init_expr_args): New function.
(dump_expr) <AGGR_INIT_EXPR, CALL_EXPR, INDIRECT_REF>: Use them.
Update to use new CALL_EXPR and AGGR_INIT_EXPR accessor macros.
* cvt.c (convert_to_void): Use build_call_array instead
of build3; use new AGGR_INIT_EXPR accessor macros.
* mangle.c (write_expression): Use TREE_OPERAND_LENGTH
instead of TREE_CODE_LENGTH.
* dump.c (cp_dump_tree) <AGGR_INIT_EXPR>: Update to use new
AGGR_INIT_EXPR accessor macros.
* cp-gimplify.c (cp_gimplify_init_expr): Use
AGGR_INIT_EXPR_SLOT to set the slot operand.
* cp-tree.h (AGGR_INIT_EXPR_FN): New macro.
(AGGR_INIT_EXPR_SLOT): New macro.
(AGGR_INIT_EXPR_ARG): New macro.
(aggr_init_expr_nargs): New macro.
(AGGR_INIT_EXPR_ARGP): New macro.
(aggr_init_expr_arg_iterator): New.
(init_aggr_init_expr_arg_iterator): New.
(next_aggr_init_expr_arg): New.
(first_aggr_init_expr_arg): New.
(more_aggr_init_expr_args_p): New.
(FOR_EACH_AGGR_INIT_EXPR_ARG): New.
(stabilize_aggr_init): New declaration.
(build_min_non_dep_call_list): Likewise.
* tree.c (process_aggr_init_operands): New function.
(build_aggr_init_array) New function.
(build_cplus_new): Update to use new CALL_EXPR and
AGGR_INIT_EXPR accessor macros. Replace use of build3 with
build_aggr_init_array.
(build_min_non_dep_call_list) New function.
(build_min_nt): Assert input code parameter is not a variable
length expression class.
(build_min, build_min_non_dep): Likewise.
(cp_tree_equal) <CALL_EXPR>: Iterate through the arguments
to check for equality instead of recursing. Handle tcc_vl_exp
tree code classes.
(stabilize_call): Update to only handle CALL_EXPRs, not
AGGR_INIT_EXPRs; use new CALL_EXPR accessor macros.
(stabilize_aggr_init): New function.
(stabilize_init): Use it.
* cxx-pretty-print.c (pp_cxx_postfix_expression)
<AGGR_INIT_EXPR, CALL_EXPR>: Update to use new CALL_EXPR and
AGGR_INIT_EXPR accessor macros and argument iterators.
* pt.c (tsubst_copy) <CALL_EXPR>: Replace build_nt with
build_vl_exp. Iterate through the operands, recursively
processing each one.
(tsubst_copy_and_build) <CALL_EXPR>: Update to use new
CALL_EXPR accessor macros.
(value_dependent_expression_p) <default>: Handle tcc_vl_exp
tree code classes. Use TREE_OPERAND_LENGTH instead of
TREE_CODE_LENGTH.
* semantics.c (finish_call_expr): Use build_nt_call_list
instead of build_nt.
(simplify_aggr_init_expr): Update to use new AGGR_INIT_EXPR
accessor macros. Use build_call_array to construct the
CALL_EXPR node instead of build3
* decl2.c (build_offset_ref_call_from_tree): Use
build_nt_call_list and build_min_non_dep_call_list instead
of build_min_nt and build_min_non_dep.
* parser.c (cp_parser_postfix_expression) <CPP_OPEN_PAREN>:
Use build_nt_call_list instead of build_min_nt.
2007-02-15 Sandra Loosemore <sandra@codesourcery.com>
Brooks Moses <brooks.moses@codesourcery.com>
Lee Millward <lee.millward@codesourcery.com>
* java-tree.h (BUILD_MONITOR_ENTER): Use build_call_nary instead
of build3.
(BUILD_MONITOR_EXIT): Likewise.
* java-gimplify.c (java_gimplify_component_ref): Use build_call_expr.
(java_gimplify_modify_expr): Likewise.
* class.c (cache_this_class_ref): Use build_call_expr.
(build_static_field_ref): Likewise.
(emit_indirect_register_classes): Likewise.
(emit_register_classes): Likewise.
* resource.c (write_resource_constructor): Use build_call_expr.
* builtins.c (builtin_creator_function): Change interpretation of
the second parameter to be the whole CALL_EXPR instead of the arglist.
(max_builtin): Tweak parameter list. Use new CALL_EXPR accessors.
(min_builtin): Likewise.
(abs_builtin): Likewise.
(java_build_function_call_expr): Likewise.
(convert_real): Likewise.
(UNMARSHAL3): Likewise.
(UNMARSHAL4): Likewise.
(UNMARSHAL5): Likewise.
(build_arglist_for_builtin): Delete. Fix callers to use
build_call_expr instead.
(putObject_builtin): Tweak parameter list. Use new CALL_EXPR
accessors.
(compareAndSwapInt_builtin): Likewise.
(compareAndSwapLong_builtin): Likewise.
(compareAndSwapObject_builtin): Likewise.
(putVolatile_builtin): Likewise.
(getVolatile_builtin): Likewise.
(VMSupportsCS8_builtin): Likewise.
(check_for_builtin): Pass entire CALL_EXPR to builtin expander
instead of arglist.
* expr.c (build_java_athrow): Use build_call_nary instead of build3.
(build_java_throw_out_of_bounds_exception): Likewise.
(java_check_reference): Likewise.
(build_java_arraystore_check): Likewise.
(build_newarray): Likewise.
(build_anewarray): Likewise.
(expand_java_multinewarray): Use build_call_list instead of build3.
(build_java_monitor): Use build_call_nary instead of build3.
(java_create_object): Likewise.
(expand_java_NEW): Likewise.
(build_instanceof): Likewise.
(expand_java_CHECKCAST): Likewise.
(build_java_soft_divmod): Likewise.
(build_java_binop): Likewise.
(build_field_ref): Likewise.
(build_class_init): Likewise.
(rewrite_arglist_getcaller): Use build_call_expr.
(build_invokeinterface): Use build_call_nary instead of build3.
(expand_invoke): Use build_call_list instead of build3.
(build_jni_stub): Use build_call_nary, build_call_list, or
build_call_expr instead of build3.
(expand_java_field_op): Use build_call_expr instead of build3.
(force_evaluation_order): Use new CALL_EXPR accessors.
* lang.c (java_get_callee_fndecl): Use new CALL_EXPR accessors.
2007-02-15 Sandra Loosemore <sandra@codesourcery.com>
Brooks Moses <brooks.moses@codesourcery.com>
Lee Millward <lee.millward@codesourcery.com>
* objc-act.c (receiver_is_class_object): Use new CALL_EXPR accessors.
(objc_get_callee_fndecl): Likewise.
2007-02-15 Sandra Loosemore <sandra@codesourcery.com>
Brooks Moses <brooks.moses@codesourcery.com>
Lee Millward <lee.millward@codesourcery.com>
* trans-expr.c (gfc_conv_power_op): Use build_call_expr.
(gfc_conv_string_tmp): Likewise.
(gfc_conv_concat_op): Likewise.
(gfc_build_compare_string): Likewise.
(gfc_conv_function_call): Use build_call_list instead of build3.
* trans-array.c (gfc_trans_allocate_array_storage): Use
build_call_expr.
(gfc_grow_array): Likewise.
(gfc_trans_array_ctor_element): Likewise.
(gfc_trans_array_constructor_value): Likewise.
(gfc_array_allocate): Likewise.
(gfc_array_deallocate): Likewise.
(gfc_trans_auto_array_allocation): Likewise.
(gfc_trans_dummy_array_bias): Likewise.
(gfc_conv_array_parameter): Likewise.
(gfc_trans_dealloc_allocated): Likewise.
(gfc_duplicate_allocatable): Likewise.
* trans-openmp.c (gfc_trans_omp_barrier): Use build_call_expr.
(gfc_trans_omp_flush): Likewise.
* trans-stmt.c (gfc_conv_elementel_dependencies): Use build_call_expr.
(gfc_trans_pause): Likewise.
(gfc_trans_stop): Likewise.
(gfc_trans_character_select): Likewise.
(gfc_do_allocate): Likewise.
(gfc_trans_assign_need_temp): Likewise.
(gfc_trans_pointer_assign_need_temp): Likewise.
(gfc_trans_forall_1): Likewise.
(gfc_trans_where_2): Likewise.
(gfc_trans_allocate): Likewise.
(gfc_trans_deallocate): Likewise.
* trans.c (gfc_trans_runtime_check): Use build_call_expr.
* trans-io.c (gfc_trans_open): Use build_call_expr.
(gfc_trans_close): Likewise.
(build_filepos): Likewise.
(gfc_trans_inquire): Likewise.
(NML_FIRST_ARG): Delete.
(NML_ADD_ARG): Delete.
(transfer_namelist_element): Use build_call_expr.
(build_dt): Likewise.
(gfc_trans_dt_end): Likewise.
(transfer_expr): Likewise.
(transfer_array-desc): Likewise.
* trans-decl.c (gfc_generate_function_code): Use build_call_expr.
(gfc_generate_constructors): Likewise.
* trans-intrinsic.c (gfc_conv_intrinsic_ctime): Use build_call_expr.
(gfc_conv_intrinsic_fdate): Likewise.
(gfc_conv_intrinsic_ttynam): Likewise.
(gfc_conv_intrinsic_array_transfer): Likewise.
(gfc_conv_associated): Likewise.
(gfc_conv_intrinsic_si_kind): Likewise.
(gfc_conv_intrinsic_trim): Likewise.
(gfc_conv_intrinsic_repeat: Likewise.
(gfc_conv_intrinsic_iargc): Likewise.
Co-Authored-By: Brooks Moses <brooks.moses@codesourcery.com>
Co-Authored-By: Lee Millward <lee.millward@codesourcery.com>
From-SVN: r122018
2007-02-16 00:50:49 +01:00
|
|
|
prefetch = build_call_expr (built_in_decls[BUILT_IN_PREFETCH],
|
|
|
|
2, addr, write_p);
|
2006-02-14 14:51:51 +01:00
|
|
|
bsi_insert_before (&bsi, prefetch, BSI_SAME_STMT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Issue prefetches for the references in GROUPS into loop as decided before.
|
|
|
|
HEAD is the number of iterations to prefetch ahead. UNROLL_FACTOR is the
|
|
|
|
factor by that LOOP was unrolled. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
issue_prefetches (struct mem_ref_group *groups,
|
|
|
|
unsigned unroll_factor, unsigned ahead)
|
|
|
|
{
|
|
|
|
struct mem_ref *ref;
|
|
|
|
|
|
|
|
for (; groups; groups = groups->next)
|
|
|
|
for (ref = groups->refs; ref; ref = ref->next)
|
|
|
|
if (ref->issue_prefetch_p)
|
|
|
|
issue_prefetch_ref (ref, unroll_factor, ahead);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Determines whether we can profitably unroll LOOP FACTOR times, and if
|
|
|
|
this is the case, fill in DESC by the description of number of
|
|
|
|
iterations. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
should_unroll_loop_p (struct loop *loop, struct tree_niter_desc *desc,
|
|
|
|
unsigned factor)
|
|
|
|
{
|
|
|
|
if (!can_unroll_loop_p (loop, factor, desc))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* We only consider loops without control flow for unrolling. This is not
|
|
|
|
a hard restriction -- tree_unroll_loop works with arbitrary loops
|
|
|
|
as well; but the unrolling/prefetching is usually more profitable for
|
|
|
|
loops consisting of a single basic block, and we want to limit the
|
|
|
|
code growth. */
|
|
|
|
if (loop->num_nodes > 2)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Determine the coefficient by that unroll LOOP, from the information
|
|
|
|
contained in the list of memory references REFS. Description of
|
2007-03-01 23:14:23 +01:00
|
|
|
umber of iterations of LOOP is stored to DESC. NINSNS is the number of
|
|
|
|
insns of the LOOP. EST_NITER is the estimated number of iterations of
|
|
|
|
the loop, or -1 if no estimate is available. */
|
2006-02-14 14:51:51 +01:00
|
|
|
|
|
|
|
static unsigned
|
|
|
|
determine_unroll_factor (struct loop *loop, struct mem_ref_group *refs,
|
2007-03-01 23:14:23 +01:00
|
|
|
unsigned ninsns, struct tree_niter_desc *desc,
|
|
|
|
HOST_WIDE_INT est_niter)
|
2006-02-14 14:51:51 +01:00
|
|
|
{
|
2006-11-12 21:05:49 +01:00
|
|
|
unsigned upper_bound;
|
|
|
|
unsigned nfactor, factor, mod_constraint;
|
2006-02-14 14:51:51 +01:00
|
|
|
struct mem_ref_group *agp;
|
|
|
|
struct mem_ref *ref;
|
|
|
|
|
2006-11-12 21:05:49 +01:00
|
|
|
/* First check whether the loop is not too large to unroll. We ignore
|
|
|
|
PARAM_MAX_UNROLL_TIMES, because for small loops, it prevented us
|
|
|
|
from unrolling them enough to make exactly one cache line covered by each
|
|
|
|
iteration. Also, the goal of PARAM_MAX_UNROLL_TIMES is to prevent
|
|
|
|
us from unrolling the loops too many times in cases where we only expect
|
|
|
|
gains from better scheduling and decreasing loop overhead, which is not
|
|
|
|
the case here. */
|
|
|
|
upper_bound = PARAM_VALUE (PARAM_MAX_UNROLLED_INSNS) / ninsns;
|
2007-03-01 23:14:23 +01:00
|
|
|
|
|
|
|
/* If we unrolled the loop more times than it iterates, the unrolled version
|
|
|
|
of the loop would be never entered. */
|
|
|
|
if (est_niter >= 0 && est_niter < (HOST_WIDE_INT) upper_bound)
|
|
|
|
upper_bound = est_niter;
|
|
|
|
|
2006-11-12 21:05:49 +01:00
|
|
|
if (upper_bound <= 1)
|
2006-02-14 14:51:51 +01:00
|
|
|
return 1;
|
|
|
|
|
2006-11-12 21:05:49 +01:00
|
|
|
/* Choose the factor so that we may prefetch each cache just once,
|
|
|
|
but bound the unrolling by UPPER_BOUND. */
|
|
|
|
factor = 1;
|
2006-02-14 14:51:51 +01:00
|
|
|
for (agp = refs; agp; agp = agp->next)
|
|
|
|
for (ref = agp->refs; ref; ref = ref->next)
|
2006-11-12 21:05:49 +01:00
|
|
|
if (should_issue_prefetch_p (ref))
|
|
|
|
{
|
|
|
|
mod_constraint = ref->prefetch_mod;
|
|
|
|
nfactor = least_common_multiple (mod_constraint, factor);
|
|
|
|
if (nfactor <= upper_bound)
|
|
|
|
factor = nfactor;
|
|
|
|
}
|
2006-02-14 14:51:51 +01:00
|
|
|
|
|
|
|
if (!should_unroll_loop_p (loop, desc, factor))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return factor;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Issue prefetch instructions for array references in LOOP. Returns
|
tree-vrp.c (execute_vrp): Do not pass loops structure through arguments.
* tree-vrp.c (execute_vrp): Do not pass loops structure through
arguments.
* loop-unswitch.c (unswitch_loops, unswitch_single_loop,
unswitch_loop): Ditto.
* tree-loop-linear.c (linear_transform_loops): Ditto.
* tree-ssa-loop-im.c (determine_lsm, tree_ssa_lim_initialize,
tree_ssa_lim): Ditto.
* tree-ssa-loop-niter.c (estimate_numbers_of_iterations,
free_numbers_of_iterations_estimates): Ditto.
* tree-ssa-loop-unswitch.c (tree_ssa_unswitch_loops,
tree_unswitch_single_loop, tree_unswitch_loop): Ditto.
* cfgloopmanip.c (fix_bb_placement, fix_bb_placements,
remove_path, add_loop, loopify, unloop, fix_loop_placements,
place_new_loop, duplicate_loop, duplicate_subloops,
update_single_exit_for_duplicated_loops, copy_loops_to,
duplicate_loop_to_header_edge, create_preheaders,
force_single_succ_latches, loop_version, fix_loop_structure):
Ditto.
* tree-ssa-loop-manip.c (tree_duplicate_loop_to_header_edge,
tree_unroll_loop): Ditto.
* tree-ssa-loop-ch.c (copy_loop_headers): Ditto.
* tree-scalar-evolution.c (select_loops_exit_conditions,
scev_initialize, scev_analysis): Ditto.
* tree-scalar-evolution.h (scev_initialize): Ditto.
* cfghooks.c (cfg_hook_duplicate_loop_to_header_edge): Ditto.
* cfgloopanal.c (mark_irreducible_loops, mark_loop_exit_edges): Ditto.
* tree-ssa-loop-ivopts.c (tree_ssa_iv_optimize): Ditto.
* modulo-sched.c (sms_schedule): Ditto.
* tree-ssa-dom.c (tree_ssa_dominator_optimize): Ditto.
* loop-init.c (loop_optimizer_init, rtl_move_loop_invariants,
rtl_unswitch, rtl_unroll_and_peel_loops, rtl_doloop): Ditto.
* ifcvt.c (if_convert): Ditto.
* tree-ssa-loop-ivcanon.c (try_unroll_loop_completely,
canonicalize_loop_induction_variables,
canonicalize_induction_variables,
tree_unroll_loops_completely, remove_empty_loops): Ditto.
* tree-ssa-loop.c (tree_ssa_loop_init, tree_ssa_loop_im,
tree_ssa_loop_unswitch, tree_vectorize, tree_linear_transform,
tree_ssa_loop_ivcanon, tree_ssa_empty_loop, tree_ssa_loop_bounds,
tree_complete_unroll, tree_ssa_loop_prefetch, tree_ssa_loop_ivopts,
tree_ssa_loop_done): Ditto.
* predict.c (predict_loops, tree_estimate_probability, estimate_loops,
estimate_bb_frequencies): Ditto.
* tree-vectorizer.c (slpeel_tree_duplicate_loop_to_edge_cfg,
slpeel_tree_peel_loop_to_edge, vectorize_loops): Ditto.
* loop-unroll.c (unroll_and_peel_loops, peel_loops_completely,
decide_unrolling_and_peeling, peel_loop_completely,
unroll_loop_constant_iterations, unroll_loop_runtime_iterations,
peel_loop_simple, unroll_loop_stupid): Ditto.
* loop-doloop.c (doloop_optimize_loops): Ditto.
* tree-cfgcleanup.c (cleanup_tree_cfg_loop): Ditto.
* loop-invariant.c (move_loop_invariants): Ditto.
* tree-ssa-dce.c (tree_ssa_dce_loop): Ditto.
* tree-ssa-loop-prefetch.c (loop_prefetch_arrays,
tree_ssa_prefetch_arrays): Ditto.
* lambda-code.c (gcc_loopnest_to_lambda_loopnest, perfect_nestify):
Ditto.
* tree-vect-transform.c (vect_do_peeling_for_loop_bound,
vect_do_peeling_for_alignment, vect_transform_loop): Ditto.
* cfgloop.c (flow_loops_cfg_dump, flow_loops_dump,
mark_single_exit_loops, cancel_loop, cancel_loop_tree,
verify_loop_structure): Ditto.
* tree-flow.h (vectorize_loops, tree_ssa_lim, tree_ssa_unswitch_loops,
canonicalize_induction_variables, tree_unroll_loops_completely,
tree_ssa_prefetch_arrays, remove_empty_loops, tree_ssa_iv_optimize,
estimate_numbers_of_iterations, free_numbers_of_iterations_estimates,
tree_duplicate_loop_to_header_edge, tree_ssa_loop_version,
tree_unroll_loop, linear_transform_loops): Declaration changed.
* basic-block.h: Remove declaration of struct loops.
* cfghooks.h (struct cfg_hooks): Change type of
cfg_hook_duplicate_loop_to_header_edge.
(cfg_hook_duplicate_loop_to_header_edge): Declaration changed.
* tree-vectorizer.h (slpeel_tree_peel_loop_to_edge,
vect_transform_loop): Declaration changed.
* lambda.h (gcc_loopnest_to_lambda_loopnest): Declaration changed.
* cfgloop.h (flow_loops_dump, fix_loop_structure,
mark_irreducible_loops, mark_single_exit_loops, mark_loop_exit_edges,
cancel_loop_tree, create_preheaders, force_single_succ_latches,
verify_loop_structure, duplicate_loop, duplicate_loop_to_header_edge,
loopify, loop_version, remove_path, unswitch_loops,
unroll_and_peel_loops, doloop_optimize_loops, move_loop_invariants):
Declaration changed.
From-SVN: r119189
2006-11-25 11:34:13 +01:00
|
|
|
true if the LOOP was unrolled. */
|
2006-02-14 14:51:51 +01:00
|
|
|
|
|
|
|
static bool
|
tree-vrp.c (execute_vrp): Do not pass loops structure through arguments.
* tree-vrp.c (execute_vrp): Do not pass loops structure through
arguments.
* loop-unswitch.c (unswitch_loops, unswitch_single_loop,
unswitch_loop): Ditto.
* tree-loop-linear.c (linear_transform_loops): Ditto.
* tree-ssa-loop-im.c (determine_lsm, tree_ssa_lim_initialize,
tree_ssa_lim): Ditto.
* tree-ssa-loop-niter.c (estimate_numbers_of_iterations,
free_numbers_of_iterations_estimates): Ditto.
* tree-ssa-loop-unswitch.c (tree_ssa_unswitch_loops,
tree_unswitch_single_loop, tree_unswitch_loop): Ditto.
* cfgloopmanip.c (fix_bb_placement, fix_bb_placements,
remove_path, add_loop, loopify, unloop, fix_loop_placements,
place_new_loop, duplicate_loop, duplicate_subloops,
update_single_exit_for_duplicated_loops, copy_loops_to,
duplicate_loop_to_header_edge, create_preheaders,
force_single_succ_latches, loop_version, fix_loop_structure):
Ditto.
* tree-ssa-loop-manip.c (tree_duplicate_loop_to_header_edge,
tree_unroll_loop): Ditto.
* tree-ssa-loop-ch.c (copy_loop_headers): Ditto.
* tree-scalar-evolution.c (select_loops_exit_conditions,
scev_initialize, scev_analysis): Ditto.
* tree-scalar-evolution.h (scev_initialize): Ditto.
* cfghooks.c (cfg_hook_duplicate_loop_to_header_edge): Ditto.
* cfgloopanal.c (mark_irreducible_loops, mark_loop_exit_edges): Ditto.
* tree-ssa-loop-ivopts.c (tree_ssa_iv_optimize): Ditto.
* modulo-sched.c (sms_schedule): Ditto.
* tree-ssa-dom.c (tree_ssa_dominator_optimize): Ditto.
* loop-init.c (loop_optimizer_init, rtl_move_loop_invariants,
rtl_unswitch, rtl_unroll_and_peel_loops, rtl_doloop): Ditto.
* ifcvt.c (if_convert): Ditto.
* tree-ssa-loop-ivcanon.c (try_unroll_loop_completely,
canonicalize_loop_induction_variables,
canonicalize_induction_variables,
tree_unroll_loops_completely, remove_empty_loops): Ditto.
* tree-ssa-loop.c (tree_ssa_loop_init, tree_ssa_loop_im,
tree_ssa_loop_unswitch, tree_vectorize, tree_linear_transform,
tree_ssa_loop_ivcanon, tree_ssa_empty_loop, tree_ssa_loop_bounds,
tree_complete_unroll, tree_ssa_loop_prefetch, tree_ssa_loop_ivopts,
tree_ssa_loop_done): Ditto.
* predict.c (predict_loops, tree_estimate_probability, estimate_loops,
estimate_bb_frequencies): Ditto.
* tree-vectorizer.c (slpeel_tree_duplicate_loop_to_edge_cfg,
slpeel_tree_peel_loop_to_edge, vectorize_loops): Ditto.
* loop-unroll.c (unroll_and_peel_loops, peel_loops_completely,
decide_unrolling_and_peeling, peel_loop_completely,
unroll_loop_constant_iterations, unroll_loop_runtime_iterations,
peel_loop_simple, unroll_loop_stupid): Ditto.
* loop-doloop.c (doloop_optimize_loops): Ditto.
* tree-cfgcleanup.c (cleanup_tree_cfg_loop): Ditto.
* loop-invariant.c (move_loop_invariants): Ditto.
* tree-ssa-dce.c (tree_ssa_dce_loop): Ditto.
* tree-ssa-loop-prefetch.c (loop_prefetch_arrays,
tree_ssa_prefetch_arrays): Ditto.
* lambda-code.c (gcc_loopnest_to_lambda_loopnest, perfect_nestify):
Ditto.
* tree-vect-transform.c (vect_do_peeling_for_loop_bound,
vect_do_peeling_for_alignment, vect_transform_loop): Ditto.
* cfgloop.c (flow_loops_cfg_dump, flow_loops_dump,
mark_single_exit_loops, cancel_loop, cancel_loop_tree,
verify_loop_structure): Ditto.
* tree-flow.h (vectorize_loops, tree_ssa_lim, tree_ssa_unswitch_loops,
canonicalize_induction_variables, tree_unroll_loops_completely,
tree_ssa_prefetch_arrays, remove_empty_loops, tree_ssa_iv_optimize,
estimate_numbers_of_iterations, free_numbers_of_iterations_estimates,
tree_duplicate_loop_to_header_edge, tree_ssa_loop_version,
tree_unroll_loop, linear_transform_loops): Declaration changed.
* basic-block.h: Remove declaration of struct loops.
* cfghooks.h (struct cfg_hooks): Change type of
cfg_hook_duplicate_loop_to_header_edge.
(cfg_hook_duplicate_loop_to_header_edge): Declaration changed.
* tree-vectorizer.h (slpeel_tree_peel_loop_to_edge,
vect_transform_loop): Declaration changed.
* lambda.h (gcc_loopnest_to_lambda_loopnest): Declaration changed.
* cfgloop.h (flow_loops_dump, fix_loop_structure,
mark_irreducible_loops, mark_single_exit_loops, mark_loop_exit_edges,
cancel_loop_tree, create_preheaders, force_single_succ_latches,
verify_loop_structure, duplicate_loop, duplicate_loop_to_header_edge,
loopify, loop_version, remove_path, unswitch_loops,
unroll_and_peel_loops, doloop_optimize_loops, move_loop_invariants):
Declaration changed.
From-SVN: r119189
2006-11-25 11:34:13 +01:00
|
|
|
loop_prefetch_arrays (struct loop *loop)
|
2006-02-14 14:51:51 +01:00
|
|
|
{
|
|
|
|
struct mem_ref_group *refs;
|
2007-03-01 23:14:23 +01:00
|
|
|
unsigned ahead, ninsns, time, unroll_factor;
|
|
|
|
HOST_WIDE_INT est_niter;
|
2006-02-14 14:51:51 +01:00
|
|
|
struct tree_niter_desc desc;
|
|
|
|
bool unrolled = false;
|
|
|
|
|
|
|
|
/* Step 1: gather the memory references. */
|
|
|
|
refs = gather_memory_references (loop);
|
|
|
|
|
|
|
|
/* Step 2: estimate the reuse effects. */
|
|
|
|
prune_by_reuse (refs);
|
|
|
|
|
|
|
|
if (!anything_to_prefetch_p (refs))
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
/* Step 3: determine the ahead and unroll factor. */
|
|
|
|
|
2007-03-01 23:14:23 +01:00
|
|
|
/* FIXME: the time should be weighted by the probabilities of the blocks in
|
|
|
|
the loop body. */
|
|
|
|
time = tree_num_loop_insns (loop, &eni_time_weights);
|
|
|
|
ahead = (PREFETCH_LATENCY + time - 1) / time;
|
|
|
|
est_niter = estimated_loop_iterations_int (loop, false);
|
2006-02-14 14:51:51 +01:00
|
|
|
|
2007-03-01 23:14:23 +01:00
|
|
|
/* The prefetches will run for AHEAD iterations of the original loop. Unless
|
|
|
|
the loop rolls at least AHEAD times, prefetching the references does not
|
|
|
|
make sense. */
|
|
|
|
if (est_niter >= 0 && est_niter <= (HOST_WIDE_INT) ahead)
|
2007-03-16 01:25:30 +01:00
|
|
|
{
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
fprintf (dump_file,
|
|
|
|
"Not prefetching -- loop estimated to roll only %d times\n",
|
|
|
|
(int) est_niter);
|
|
|
|
goto fail;
|
|
|
|
}
|
2006-02-14 14:51:51 +01:00
|
|
|
|
2007-03-01 23:14:23 +01:00
|
|
|
ninsns = tree_num_loop_insns (loop, &eni_size_weights);
|
|
|
|
unroll_factor = determine_unroll_factor (loop, refs, ninsns, &desc,
|
|
|
|
est_niter);
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
fprintf (dump_file, "Ahead %d, unroll factor %d\n", ahead, unroll_factor);
|
|
|
|
|
2006-02-14 14:51:51 +01:00
|
|
|
/* Step 4: what to prefetch? */
|
|
|
|
if (!schedule_prefetches (refs, unroll_factor, ahead))
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
/* Step 5: unroll the loop. TODO -- peeling of first and last few
|
|
|
|
iterations so that we do not issue superfluous prefetches. */
|
|
|
|
if (unroll_factor != 1)
|
|
|
|
{
|
tree-vrp.c (execute_vrp): Do not pass loops structure through arguments.
* tree-vrp.c (execute_vrp): Do not pass loops structure through
arguments.
* loop-unswitch.c (unswitch_loops, unswitch_single_loop,
unswitch_loop): Ditto.
* tree-loop-linear.c (linear_transform_loops): Ditto.
* tree-ssa-loop-im.c (determine_lsm, tree_ssa_lim_initialize,
tree_ssa_lim): Ditto.
* tree-ssa-loop-niter.c (estimate_numbers_of_iterations,
free_numbers_of_iterations_estimates): Ditto.
* tree-ssa-loop-unswitch.c (tree_ssa_unswitch_loops,
tree_unswitch_single_loop, tree_unswitch_loop): Ditto.
* cfgloopmanip.c (fix_bb_placement, fix_bb_placements,
remove_path, add_loop, loopify, unloop, fix_loop_placements,
place_new_loop, duplicate_loop, duplicate_subloops,
update_single_exit_for_duplicated_loops, copy_loops_to,
duplicate_loop_to_header_edge, create_preheaders,
force_single_succ_latches, loop_version, fix_loop_structure):
Ditto.
* tree-ssa-loop-manip.c (tree_duplicate_loop_to_header_edge,
tree_unroll_loop): Ditto.
* tree-ssa-loop-ch.c (copy_loop_headers): Ditto.
* tree-scalar-evolution.c (select_loops_exit_conditions,
scev_initialize, scev_analysis): Ditto.
* tree-scalar-evolution.h (scev_initialize): Ditto.
* cfghooks.c (cfg_hook_duplicate_loop_to_header_edge): Ditto.
* cfgloopanal.c (mark_irreducible_loops, mark_loop_exit_edges): Ditto.
* tree-ssa-loop-ivopts.c (tree_ssa_iv_optimize): Ditto.
* modulo-sched.c (sms_schedule): Ditto.
* tree-ssa-dom.c (tree_ssa_dominator_optimize): Ditto.
* loop-init.c (loop_optimizer_init, rtl_move_loop_invariants,
rtl_unswitch, rtl_unroll_and_peel_loops, rtl_doloop): Ditto.
* ifcvt.c (if_convert): Ditto.
* tree-ssa-loop-ivcanon.c (try_unroll_loop_completely,
canonicalize_loop_induction_variables,
canonicalize_induction_variables,
tree_unroll_loops_completely, remove_empty_loops): Ditto.
* tree-ssa-loop.c (tree_ssa_loop_init, tree_ssa_loop_im,
tree_ssa_loop_unswitch, tree_vectorize, tree_linear_transform,
tree_ssa_loop_ivcanon, tree_ssa_empty_loop, tree_ssa_loop_bounds,
tree_complete_unroll, tree_ssa_loop_prefetch, tree_ssa_loop_ivopts,
tree_ssa_loop_done): Ditto.
* predict.c (predict_loops, tree_estimate_probability, estimate_loops,
estimate_bb_frequencies): Ditto.
* tree-vectorizer.c (slpeel_tree_duplicate_loop_to_edge_cfg,
slpeel_tree_peel_loop_to_edge, vectorize_loops): Ditto.
* loop-unroll.c (unroll_and_peel_loops, peel_loops_completely,
decide_unrolling_and_peeling, peel_loop_completely,
unroll_loop_constant_iterations, unroll_loop_runtime_iterations,
peel_loop_simple, unroll_loop_stupid): Ditto.
* loop-doloop.c (doloop_optimize_loops): Ditto.
* tree-cfgcleanup.c (cleanup_tree_cfg_loop): Ditto.
* loop-invariant.c (move_loop_invariants): Ditto.
* tree-ssa-dce.c (tree_ssa_dce_loop): Ditto.
* tree-ssa-loop-prefetch.c (loop_prefetch_arrays,
tree_ssa_prefetch_arrays): Ditto.
* lambda-code.c (gcc_loopnest_to_lambda_loopnest, perfect_nestify):
Ditto.
* tree-vect-transform.c (vect_do_peeling_for_loop_bound,
vect_do_peeling_for_alignment, vect_transform_loop): Ditto.
* cfgloop.c (flow_loops_cfg_dump, flow_loops_dump,
mark_single_exit_loops, cancel_loop, cancel_loop_tree,
verify_loop_structure): Ditto.
* tree-flow.h (vectorize_loops, tree_ssa_lim, tree_ssa_unswitch_loops,
canonicalize_induction_variables, tree_unroll_loops_completely,
tree_ssa_prefetch_arrays, remove_empty_loops, tree_ssa_iv_optimize,
estimate_numbers_of_iterations, free_numbers_of_iterations_estimates,
tree_duplicate_loop_to_header_edge, tree_ssa_loop_version,
tree_unroll_loop, linear_transform_loops): Declaration changed.
* basic-block.h: Remove declaration of struct loops.
* cfghooks.h (struct cfg_hooks): Change type of
cfg_hook_duplicate_loop_to_header_edge.
(cfg_hook_duplicate_loop_to_header_edge): Declaration changed.
* tree-vectorizer.h (slpeel_tree_peel_loop_to_edge,
vect_transform_loop): Declaration changed.
* lambda.h (gcc_loopnest_to_lambda_loopnest): Declaration changed.
* cfgloop.h (flow_loops_dump, fix_loop_structure,
mark_irreducible_loops, mark_single_exit_loops, mark_loop_exit_edges,
cancel_loop_tree, create_preheaders, force_single_succ_latches,
verify_loop_structure, duplicate_loop, duplicate_loop_to_header_edge,
loopify, loop_version, remove_path, unswitch_loops,
unroll_and_peel_loops, doloop_optimize_loops, move_loop_invariants):
Declaration changed.
From-SVN: r119189
2006-11-25 11:34:13 +01:00
|
|
|
tree_unroll_loop (loop, unroll_factor,
|
2006-02-14 14:51:51 +01:00
|
|
|
single_dom_exit (loop), &desc);
|
|
|
|
unrolled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Step 6: issue the prefetches. */
|
|
|
|
issue_prefetches (refs, unroll_factor, ahead);
|
|
|
|
|
|
|
|
fail:
|
|
|
|
release_mem_refs (refs);
|
|
|
|
return unrolled;
|
|
|
|
}
|
|
|
|
|
tree-vrp.c (execute_vrp): Do not pass loops structure through arguments.
* tree-vrp.c (execute_vrp): Do not pass loops structure through
arguments.
* loop-unswitch.c (unswitch_loops, unswitch_single_loop,
unswitch_loop): Ditto.
* tree-loop-linear.c (linear_transform_loops): Ditto.
* tree-ssa-loop-im.c (determine_lsm, tree_ssa_lim_initialize,
tree_ssa_lim): Ditto.
* tree-ssa-loop-niter.c (estimate_numbers_of_iterations,
free_numbers_of_iterations_estimates): Ditto.
* tree-ssa-loop-unswitch.c (tree_ssa_unswitch_loops,
tree_unswitch_single_loop, tree_unswitch_loop): Ditto.
* cfgloopmanip.c (fix_bb_placement, fix_bb_placements,
remove_path, add_loop, loopify, unloop, fix_loop_placements,
place_new_loop, duplicate_loop, duplicate_subloops,
update_single_exit_for_duplicated_loops, copy_loops_to,
duplicate_loop_to_header_edge, create_preheaders,
force_single_succ_latches, loop_version, fix_loop_structure):
Ditto.
* tree-ssa-loop-manip.c (tree_duplicate_loop_to_header_edge,
tree_unroll_loop): Ditto.
* tree-ssa-loop-ch.c (copy_loop_headers): Ditto.
* tree-scalar-evolution.c (select_loops_exit_conditions,
scev_initialize, scev_analysis): Ditto.
* tree-scalar-evolution.h (scev_initialize): Ditto.
* cfghooks.c (cfg_hook_duplicate_loop_to_header_edge): Ditto.
* cfgloopanal.c (mark_irreducible_loops, mark_loop_exit_edges): Ditto.
* tree-ssa-loop-ivopts.c (tree_ssa_iv_optimize): Ditto.
* modulo-sched.c (sms_schedule): Ditto.
* tree-ssa-dom.c (tree_ssa_dominator_optimize): Ditto.
* loop-init.c (loop_optimizer_init, rtl_move_loop_invariants,
rtl_unswitch, rtl_unroll_and_peel_loops, rtl_doloop): Ditto.
* ifcvt.c (if_convert): Ditto.
* tree-ssa-loop-ivcanon.c (try_unroll_loop_completely,
canonicalize_loop_induction_variables,
canonicalize_induction_variables,
tree_unroll_loops_completely, remove_empty_loops): Ditto.
* tree-ssa-loop.c (tree_ssa_loop_init, tree_ssa_loop_im,
tree_ssa_loop_unswitch, tree_vectorize, tree_linear_transform,
tree_ssa_loop_ivcanon, tree_ssa_empty_loop, tree_ssa_loop_bounds,
tree_complete_unroll, tree_ssa_loop_prefetch, tree_ssa_loop_ivopts,
tree_ssa_loop_done): Ditto.
* predict.c (predict_loops, tree_estimate_probability, estimate_loops,
estimate_bb_frequencies): Ditto.
* tree-vectorizer.c (slpeel_tree_duplicate_loop_to_edge_cfg,
slpeel_tree_peel_loop_to_edge, vectorize_loops): Ditto.
* loop-unroll.c (unroll_and_peel_loops, peel_loops_completely,
decide_unrolling_and_peeling, peel_loop_completely,
unroll_loop_constant_iterations, unroll_loop_runtime_iterations,
peel_loop_simple, unroll_loop_stupid): Ditto.
* loop-doloop.c (doloop_optimize_loops): Ditto.
* tree-cfgcleanup.c (cleanup_tree_cfg_loop): Ditto.
* loop-invariant.c (move_loop_invariants): Ditto.
* tree-ssa-dce.c (tree_ssa_dce_loop): Ditto.
* tree-ssa-loop-prefetch.c (loop_prefetch_arrays,
tree_ssa_prefetch_arrays): Ditto.
* lambda-code.c (gcc_loopnest_to_lambda_loopnest, perfect_nestify):
Ditto.
* tree-vect-transform.c (vect_do_peeling_for_loop_bound,
vect_do_peeling_for_alignment, vect_transform_loop): Ditto.
* cfgloop.c (flow_loops_cfg_dump, flow_loops_dump,
mark_single_exit_loops, cancel_loop, cancel_loop_tree,
verify_loop_structure): Ditto.
* tree-flow.h (vectorize_loops, tree_ssa_lim, tree_ssa_unswitch_loops,
canonicalize_induction_variables, tree_unroll_loops_completely,
tree_ssa_prefetch_arrays, remove_empty_loops, tree_ssa_iv_optimize,
estimate_numbers_of_iterations, free_numbers_of_iterations_estimates,
tree_duplicate_loop_to_header_edge, tree_ssa_loop_version,
tree_unroll_loop, linear_transform_loops): Declaration changed.
* basic-block.h: Remove declaration of struct loops.
* cfghooks.h (struct cfg_hooks): Change type of
cfg_hook_duplicate_loop_to_header_edge.
(cfg_hook_duplicate_loop_to_header_edge): Declaration changed.
* tree-vectorizer.h (slpeel_tree_peel_loop_to_edge,
vect_transform_loop): Declaration changed.
* lambda.h (gcc_loopnest_to_lambda_loopnest): Declaration changed.
* cfgloop.h (flow_loops_dump, fix_loop_structure,
mark_irreducible_loops, mark_single_exit_loops, mark_loop_exit_edges,
cancel_loop_tree, create_preheaders, force_single_succ_latches,
verify_loop_structure, duplicate_loop, duplicate_loop_to_header_edge,
loopify, loop_version, remove_path, unswitch_loops,
unroll_and_peel_loops, doloop_optimize_loops, move_loop_invariants):
Declaration changed.
From-SVN: r119189
2006-11-25 11:34:13 +01:00
|
|
|
/* Issue prefetch instructions for array references in loops. */
|
2006-02-14 14:51:51 +01:00
|
|
|
|
2006-09-06 08:13:22 +02:00
|
|
|
unsigned int
|
tree-vrp.c (execute_vrp): Do not pass loops structure through arguments.
* tree-vrp.c (execute_vrp): Do not pass loops structure through
arguments.
* loop-unswitch.c (unswitch_loops, unswitch_single_loop,
unswitch_loop): Ditto.
* tree-loop-linear.c (linear_transform_loops): Ditto.
* tree-ssa-loop-im.c (determine_lsm, tree_ssa_lim_initialize,
tree_ssa_lim): Ditto.
* tree-ssa-loop-niter.c (estimate_numbers_of_iterations,
free_numbers_of_iterations_estimates): Ditto.
* tree-ssa-loop-unswitch.c (tree_ssa_unswitch_loops,
tree_unswitch_single_loop, tree_unswitch_loop): Ditto.
* cfgloopmanip.c (fix_bb_placement, fix_bb_placements,
remove_path, add_loop, loopify, unloop, fix_loop_placements,
place_new_loop, duplicate_loop, duplicate_subloops,
update_single_exit_for_duplicated_loops, copy_loops_to,
duplicate_loop_to_header_edge, create_preheaders,
force_single_succ_latches, loop_version, fix_loop_structure):
Ditto.
* tree-ssa-loop-manip.c (tree_duplicate_loop_to_header_edge,
tree_unroll_loop): Ditto.
* tree-ssa-loop-ch.c (copy_loop_headers): Ditto.
* tree-scalar-evolution.c (select_loops_exit_conditions,
scev_initialize, scev_analysis): Ditto.
* tree-scalar-evolution.h (scev_initialize): Ditto.
* cfghooks.c (cfg_hook_duplicate_loop_to_header_edge): Ditto.
* cfgloopanal.c (mark_irreducible_loops, mark_loop_exit_edges): Ditto.
* tree-ssa-loop-ivopts.c (tree_ssa_iv_optimize): Ditto.
* modulo-sched.c (sms_schedule): Ditto.
* tree-ssa-dom.c (tree_ssa_dominator_optimize): Ditto.
* loop-init.c (loop_optimizer_init, rtl_move_loop_invariants,
rtl_unswitch, rtl_unroll_and_peel_loops, rtl_doloop): Ditto.
* ifcvt.c (if_convert): Ditto.
* tree-ssa-loop-ivcanon.c (try_unroll_loop_completely,
canonicalize_loop_induction_variables,
canonicalize_induction_variables,
tree_unroll_loops_completely, remove_empty_loops): Ditto.
* tree-ssa-loop.c (tree_ssa_loop_init, tree_ssa_loop_im,
tree_ssa_loop_unswitch, tree_vectorize, tree_linear_transform,
tree_ssa_loop_ivcanon, tree_ssa_empty_loop, tree_ssa_loop_bounds,
tree_complete_unroll, tree_ssa_loop_prefetch, tree_ssa_loop_ivopts,
tree_ssa_loop_done): Ditto.
* predict.c (predict_loops, tree_estimate_probability, estimate_loops,
estimate_bb_frequencies): Ditto.
* tree-vectorizer.c (slpeel_tree_duplicate_loop_to_edge_cfg,
slpeel_tree_peel_loop_to_edge, vectorize_loops): Ditto.
* loop-unroll.c (unroll_and_peel_loops, peel_loops_completely,
decide_unrolling_and_peeling, peel_loop_completely,
unroll_loop_constant_iterations, unroll_loop_runtime_iterations,
peel_loop_simple, unroll_loop_stupid): Ditto.
* loop-doloop.c (doloop_optimize_loops): Ditto.
* tree-cfgcleanup.c (cleanup_tree_cfg_loop): Ditto.
* loop-invariant.c (move_loop_invariants): Ditto.
* tree-ssa-dce.c (tree_ssa_dce_loop): Ditto.
* tree-ssa-loop-prefetch.c (loop_prefetch_arrays,
tree_ssa_prefetch_arrays): Ditto.
* lambda-code.c (gcc_loopnest_to_lambda_loopnest, perfect_nestify):
Ditto.
* tree-vect-transform.c (vect_do_peeling_for_loop_bound,
vect_do_peeling_for_alignment, vect_transform_loop): Ditto.
* cfgloop.c (flow_loops_cfg_dump, flow_loops_dump,
mark_single_exit_loops, cancel_loop, cancel_loop_tree,
verify_loop_structure): Ditto.
* tree-flow.h (vectorize_loops, tree_ssa_lim, tree_ssa_unswitch_loops,
canonicalize_induction_variables, tree_unroll_loops_completely,
tree_ssa_prefetch_arrays, remove_empty_loops, tree_ssa_iv_optimize,
estimate_numbers_of_iterations, free_numbers_of_iterations_estimates,
tree_duplicate_loop_to_header_edge, tree_ssa_loop_version,
tree_unroll_loop, linear_transform_loops): Declaration changed.
* basic-block.h: Remove declaration of struct loops.
* cfghooks.h (struct cfg_hooks): Change type of
cfg_hook_duplicate_loop_to_header_edge.
(cfg_hook_duplicate_loop_to_header_edge): Declaration changed.
* tree-vectorizer.h (slpeel_tree_peel_loop_to_edge,
vect_transform_loop): Declaration changed.
* lambda.h (gcc_loopnest_to_lambda_loopnest): Declaration changed.
* cfgloop.h (flow_loops_dump, fix_loop_structure,
mark_irreducible_loops, mark_single_exit_loops, mark_loop_exit_edges,
cancel_loop_tree, create_preheaders, force_single_succ_latches,
verify_loop_structure, duplicate_loop, duplicate_loop_to_header_edge,
loopify, loop_version, remove_path, unswitch_loops,
unroll_and_peel_loops, doloop_optimize_loops, move_loop_invariants):
Declaration changed.
From-SVN: r119189
2006-11-25 11:34:13 +01:00
|
|
|
tree_ssa_prefetch_arrays (void)
|
2006-02-14 14:51:51 +01:00
|
|
|
{
|
tree-vrp.c (adjust_range_with_scev): Use get_chrec_loop.
* tree-vrp.c (adjust_range_with_scev): Use get_chrec_loop.
* loop-unswitch.c (unswitch_loops): Use FOR_EACH_LOOP.
* tree-loop-linear.c (linear_transform_loops): Ditto.
* tree-ssa-loop-im.c (determine_lsm): Ditto.
* tree-ssa-loop-niter.c (estimate_numbers_of_iterations,
free_numbers_of_iterations_estimates): Ditto.
* tree_ssa_unswitch_loops (tree_ssa_unswitch_loops): Ditto.
* tree-ssa-loop-ch.c (copy_loop_headers): Ditto.
* tree-ssa-loop-ivopts.c (tree_ssa_iv_optimize): Ditto.
* modulo-sched.c (sms_schedule): Ditto.
* tree-ssa-loop-ivcanon.c (canonicalize_induction_variables,
tree_unroll_loops_completely): Ditto.
* predict.c (predict_loops): Ditto.
* tree-if-conv.c (main_tree_if_conversion): Ditto.
* loop-unroll.c (unroll_and_peel_loops, peel_loops_completely,
decide_unrolling_and_peeling): Ditto.
* cfgloopmanip.c (unloop): Use delete_loop.
(place_new_loop): Access larray vector instead of parray.
(create_preheaders, force_single_succ_latches,
fix_loop_structure): Use FOR_EACH_LOOP and delete_loop..
* loop-doloop.c (doloop_optimize_loops): Ditto.
* loop-invariant.c (move_loop_invariants): Ditto.
* tree-cfg.c (replace_uses_by): Ditto.
* tree-ssa-loop-prefetch.c (tree_ssa_prefetch_arrays): Ditto.
* tree-chrec.h (CHREC_VAR, CHREC_LEFT, CHREC_RIGHT, CHREC_VARIABLE):
Moved to ...
* tree.h (CHREC_VAR, CHREC_LEFT, CHREC_RIGHT, CHREC_VARIABLE):
... here.
* tree-scalar-evolution.c (chrec_contains_symbols_defined_in_loop,
compute_overall_effect_of_inner_loop, chrec_is_positive): Use
get_loop and get_chrec_loop.
(number_of_iterations_for_all_loops): Use number_of_loops.
(scev_initialize, scev_reset, scev_const_prop): Use FOR_EACH_LOOP.
* tree-scalar-evolution.h (get_chrec_loop): New inline function.
* cfgloopanal.c (mark_irreducible_loops): Use number_of_loops,
and FOR_EACH_LOOP.
* tree-chrec.c (evolution_function_is_invariant_rec_p,
chrec_convert_1): Use get_loop and get_chrec_loop.
* loop-init.c (loop_optimizer_init): Use number_of_loops.
(loop_optimizer_init): Use FOR_EACH_LOOP.
* tree-vectorizer.c (vect_loops_num): Removed.
(vectorize_loops): Store number of loops locally. Use
FOR_EACH_LOOP and get_loop.
* tree-vectorizer.h (vect_loops_num): Removed.
* tree-data-ref.c (get_number_of_iters_for_loop): Use get_loop.
(find_data_references_in_loop): Do not set parallel_p.
* tree-data-ref.h: Do not declare VEC(loop_p).
* cfgloop.c (flow_loops_dump, mark_single_exit_loops,
verify_loop_structure): Use FOR_EACH_LOOP.
(flow_loops_free): Use FOR_EACH_LOOP, free larray vector.
(initialize_loops_parallel_p): Removed.
(flow_loops_find): Push the loops into a vector.
(delete_loop): New function.
(cancel_loop): Use delete_loop.
* cfgloop.h: Declare VEC(loop_p).
(struct loop): Remove parallel_p field.
(struct loops): Replace num and parray field by larray vector.
Remove shared_headers field.
(delete_loop): Declare.
(get_loop, get_loops, number_of_loops, fel_next, fel_init,
FOR_EACH_LOOP): New.
* doc/loop.tex: Document new accessor functions.
From-SVN: r119713
2006-12-10 23:17:15 +01:00
|
|
|
loop_iterator li;
|
2006-02-14 14:51:51 +01:00
|
|
|
struct loop *loop;
|
|
|
|
bool unrolled = false;
|
2006-09-06 08:13:22 +02:00
|
|
|
int todo_flags = 0;
|
2006-02-14 14:51:51 +01:00
|
|
|
|
|
|
|
if (!HAVE_prefetch
|
|
|
|
/* It is possible to ask compiler for say -mtune=i486 -march=pentium4.
|
|
|
|
-mtune=i486 causes us having PREFETCH_BLOCK 0, since this is part
|
|
|
|
of processor costs and i486 does not have prefetch, but
|
|
|
|
-march=pentium4 causes HAVE_prefetch to be true. Ugh. */
|
|
|
|
|| PREFETCH_BLOCK == 0)
|
2006-09-06 08:13:22 +02:00
|
|
|
return 0;
|
2006-02-14 14:51:51 +01:00
|
|
|
|
params.c (set_param_value): Initialize the "set" field.
* params.c (set_param_value): Initialize the "set" field.
* params.h (struct param_info): Add "set" field.
(PARAM_SET_P): New macro.
(PREFETCH_LATENCY, SIMULTANEOUS_PREFETCHES, L1_CACHE_SIZE,
L1_CACHE_LINE_SIZE): New macros.
* toplev.c (DEFPARAM): Initialize the "set" field.
* tree-ssa-loop-prefetch.c (PREFETCH_LATENCY,
SIMULTANEOUS_PREFETCHES): Removed.
(PREFETCH_BLOCK): Use L1_CACHE_LINE_SIZE.
(tree_ssa_prefetch_arrays): Dump the values of the parameters.
* config/sparc/sparc.c: Include params.h.
(sparc_override_options): Set SIMULTANEOUS_PREFETCHES and
L1_CACHE_LINE_SIZE parameters.
* config/sparc/sparc.h (PREFETCH_BLOCK, SIMULTANEOUS_PREFETCHES):
Removed.
* config/i386/i386.h (PREFETCH_BLOCK, SIMULTANEOUS_PREFETCHES):
Removed.
* config/i386/i386.c: Include params.h.
(k8_cost): Change default value for SIMULTANEOUS_PREFETCHES.
(override_options): Set SIMULTANEOUS_PREFETCHES and
L1_CACHE_LINE_SIZE parameters.
* config/sh/sh.h (SIMULTANEOUS_PREFETCHES): Removed.
(OPTIMIZATION_OPTIONS): Set SIMULTANEOUS_PREFETCHES and
L1_CACHE_LINE_SIZE parameters.
* config/ia64/ia64.c (ia64_optimization_options): Set
SIMULTANEOUS_PREFETCHES and L1_CACHE_LINE_SIZE parameters.
* config/ia64/ia64.h (SIMULTANEOUS_PREFETCHES, PREFETCH_BLOCK):
Removed.
* params.def (PARAM_PREFETCH_LATENCY, PARAM_SIMULTANEOUS_PREFETCHES,
PARAM_L1_CACHE_SIZE, PARAM_L1_CACHE_LINE_SIZE): New params.
* doc/invoke.texi: Document new params.
From-SVN: r118728
2006-11-12 20:17:02 +01:00
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
{
|
|
|
|
fprintf (dump_file, "Prefetching parameters:\n");
|
|
|
|
fprintf (dump_file, " simultaneous prefetches: %d\n",
|
|
|
|
SIMULTANEOUS_PREFETCHES);
|
|
|
|
fprintf (dump_file, " prefetch latency: %d\n", PREFETCH_LATENCY);
|
|
|
|
fprintf (dump_file, " L1 cache size: %d (%d bytes)\n",
|
|
|
|
L1_CACHE_SIZE, L1_CACHE_SIZE * L1_CACHE_LINE_SIZE);
|
|
|
|
fprintf (dump_file, " L1 cache line size: %d\n", L1_CACHE_LINE_SIZE);
|
|
|
|
fprintf (dump_file, " prefetch block size: %d\n", PREFETCH_BLOCK);
|
|
|
|
fprintf (dump_file, "\n");
|
|
|
|
}
|
|
|
|
|
2006-02-14 14:51:51 +01:00
|
|
|
initialize_original_copy_tables ();
|
|
|
|
|
|
|
|
if (!built_in_decls[BUILT_IN_PREFETCH])
|
|
|
|
{
|
|
|
|
tree type = build_function_type (void_type_node,
|
|
|
|
tree_cons (NULL_TREE,
|
|
|
|
const_ptr_type_node,
|
|
|
|
NULL_TREE));
|
2006-10-23 21:47:58 +02:00
|
|
|
tree decl = add_builtin_function ("__builtin_prefetch", type,
|
|
|
|
BUILT_IN_PREFETCH, BUILT_IN_NORMAL,
|
|
|
|
NULL, NULL_TREE);
|
2006-02-14 14:51:51 +01:00
|
|
|
DECL_IS_NOVOPS (decl) = true;
|
|
|
|
built_in_decls[BUILT_IN_PREFETCH] = decl;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We assume that size of cache line is a power of two, so verify this
|
|
|
|
here. */
|
|
|
|
gcc_assert ((PREFETCH_BLOCK & (PREFETCH_BLOCK - 1)) == 0);
|
|
|
|
|
tree-vrp.c (adjust_range_with_scev): Use get_chrec_loop.
* tree-vrp.c (adjust_range_with_scev): Use get_chrec_loop.
* loop-unswitch.c (unswitch_loops): Use FOR_EACH_LOOP.
* tree-loop-linear.c (linear_transform_loops): Ditto.
* tree-ssa-loop-im.c (determine_lsm): Ditto.
* tree-ssa-loop-niter.c (estimate_numbers_of_iterations,
free_numbers_of_iterations_estimates): Ditto.
* tree_ssa_unswitch_loops (tree_ssa_unswitch_loops): Ditto.
* tree-ssa-loop-ch.c (copy_loop_headers): Ditto.
* tree-ssa-loop-ivopts.c (tree_ssa_iv_optimize): Ditto.
* modulo-sched.c (sms_schedule): Ditto.
* tree-ssa-loop-ivcanon.c (canonicalize_induction_variables,
tree_unroll_loops_completely): Ditto.
* predict.c (predict_loops): Ditto.
* tree-if-conv.c (main_tree_if_conversion): Ditto.
* loop-unroll.c (unroll_and_peel_loops, peel_loops_completely,
decide_unrolling_and_peeling): Ditto.
* cfgloopmanip.c (unloop): Use delete_loop.
(place_new_loop): Access larray vector instead of parray.
(create_preheaders, force_single_succ_latches,
fix_loop_structure): Use FOR_EACH_LOOP and delete_loop..
* loop-doloop.c (doloop_optimize_loops): Ditto.
* loop-invariant.c (move_loop_invariants): Ditto.
* tree-cfg.c (replace_uses_by): Ditto.
* tree-ssa-loop-prefetch.c (tree_ssa_prefetch_arrays): Ditto.
* tree-chrec.h (CHREC_VAR, CHREC_LEFT, CHREC_RIGHT, CHREC_VARIABLE):
Moved to ...
* tree.h (CHREC_VAR, CHREC_LEFT, CHREC_RIGHT, CHREC_VARIABLE):
... here.
* tree-scalar-evolution.c (chrec_contains_symbols_defined_in_loop,
compute_overall_effect_of_inner_loop, chrec_is_positive): Use
get_loop and get_chrec_loop.
(number_of_iterations_for_all_loops): Use number_of_loops.
(scev_initialize, scev_reset, scev_const_prop): Use FOR_EACH_LOOP.
* tree-scalar-evolution.h (get_chrec_loop): New inline function.
* cfgloopanal.c (mark_irreducible_loops): Use number_of_loops,
and FOR_EACH_LOOP.
* tree-chrec.c (evolution_function_is_invariant_rec_p,
chrec_convert_1): Use get_loop and get_chrec_loop.
* loop-init.c (loop_optimizer_init): Use number_of_loops.
(loop_optimizer_init): Use FOR_EACH_LOOP.
* tree-vectorizer.c (vect_loops_num): Removed.
(vectorize_loops): Store number of loops locally. Use
FOR_EACH_LOOP and get_loop.
* tree-vectorizer.h (vect_loops_num): Removed.
* tree-data-ref.c (get_number_of_iters_for_loop): Use get_loop.
(find_data_references_in_loop): Do not set parallel_p.
* tree-data-ref.h: Do not declare VEC(loop_p).
* cfgloop.c (flow_loops_dump, mark_single_exit_loops,
verify_loop_structure): Use FOR_EACH_LOOP.
(flow_loops_free): Use FOR_EACH_LOOP, free larray vector.
(initialize_loops_parallel_p): Removed.
(flow_loops_find): Push the loops into a vector.
(delete_loop): New function.
(cancel_loop): Use delete_loop.
* cfgloop.h: Declare VEC(loop_p).
(struct loop): Remove parallel_p field.
(struct loops): Replace num and parray field by larray vector.
Remove shared_headers field.
(delete_loop): Declare.
(get_loop, get_loops, number_of_loops, fel_next, fel_init,
FOR_EACH_LOOP): New.
* doc/loop.tex: Document new accessor functions.
From-SVN: r119713
2006-12-10 23:17:15 +01:00
|
|
|
FOR_EACH_LOOP (li, loop, LI_FROM_INNERMOST)
|
2006-02-14 14:51:51 +01:00
|
|
|
{
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
fprintf (dump_file, "Processing loop %d:\n", loop->num);
|
|
|
|
|
tree-vrp.c (execute_vrp): Do not pass loops structure through arguments.
* tree-vrp.c (execute_vrp): Do not pass loops structure through
arguments.
* loop-unswitch.c (unswitch_loops, unswitch_single_loop,
unswitch_loop): Ditto.
* tree-loop-linear.c (linear_transform_loops): Ditto.
* tree-ssa-loop-im.c (determine_lsm, tree_ssa_lim_initialize,
tree_ssa_lim): Ditto.
* tree-ssa-loop-niter.c (estimate_numbers_of_iterations,
free_numbers_of_iterations_estimates): Ditto.
* tree-ssa-loop-unswitch.c (tree_ssa_unswitch_loops,
tree_unswitch_single_loop, tree_unswitch_loop): Ditto.
* cfgloopmanip.c (fix_bb_placement, fix_bb_placements,
remove_path, add_loop, loopify, unloop, fix_loop_placements,
place_new_loop, duplicate_loop, duplicate_subloops,
update_single_exit_for_duplicated_loops, copy_loops_to,
duplicate_loop_to_header_edge, create_preheaders,
force_single_succ_latches, loop_version, fix_loop_structure):
Ditto.
* tree-ssa-loop-manip.c (tree_duplicate_loop_to_header_edge,
tree_unroll_loop): Ditto.
* tree-ssa-loop-ch.c (copy_loop_headers): Ditto.
* tree-scalar-evolution.c (select_loops_exit_conditions,
scev_initialize, scev_analysis): Ditto.
* tree-scalar-evolution.h (scev_initialize): Ditto.
* cfghooks.c (cfg_hook_duplicate_loop_to_header_edge): Ditto.
* cfgloopanal.c (mark_irreducible_loops, mark_loop_exit_edges): Ditto.
* tree-ssa-loop-ivopts.c (tree_ssa_iv_optimize): Ditto.
* modulo-sched.c (sms_schedule): Ditto.
* tree-ssa-dom.c (tree_ssa_dominator_optimize): Ditto.
* loop-init.c (loop_optimizer_init, rtl_move_loop_invariants,
rtl_unswitch, rtl_unroll_and_peel_loops, rtl_doloop): Ditto.
* ifcvt.c (if_convert): Ditto.
* tree-ssa-loop-ivcanon.c (try_unroll_loop_completely,
canonicalize_loop_induction_variables,
canonicalize_induction_variables,
tree_unroll_loops_completely, remove_empty_loops): Ditto.
* tree-ssa-loop.c (tree_ssa_loop_init, tree_ssa_loop_im,
tree_ssa_loop_unswitch, tree_vectorize, tree_linear_transform,
tree_ssa_loop_ivcanon, tree_ssa_empty_loop, tree_ssa_loop_bounds,
tree_complete_unroll, tree_ssa_loop_prefetch, tree_ssa_loop_ivopts,
tree_ssa_loop_done): Ditto.
* predict.c (predict_loops, tree_estimate_probability, estimate_loops,
estimate_bb_frequencies): Ditto.
* tree-vectorizer.c (slpeel_tree_duplicate_loop_to_edge_cfg,
slpeel_tree_peel_loop_to_edge, vectorize_loops): Ditto.
* loop-unroll.c (unroll_and_peel_loops, peel_loops_completely,
decide_unrolling_and_peeling, peel_loop_completely,
unroll_loop_constant_iterations, unroll_loop_runtime_iterations,
peel_loop_simple, unroll_loop_stupid): Ditto.
* loop-doloop.c (doloop_optimize_loops): Ditto.
* tree-cfgcleanup.c (cleanup_tree_cfg_loop): Ditto.
* loop-invariant.c (move_loop_invariants): Ditto.
* tree-ssa-dce.c (tree_ssa_dce_loop): Ditto.
* tree-ssa-loop-prefetch.c (loop_prefetch_arrays,
tree_ssa_prefetch_arrays): Ditto.
* lambda-code.c (gcc_loopnest_to_lambda_loopnest, perfect_nestify):
Ditto.
* tree-vect-transform.c (vect_do_peeling_for_loop_bound,
vect_do_peeling_for_alignment, vect_transform_loop): Ditto.
* cfgloop.c (flow_loops_cfg_dump, flow_loops_dump,
mark_single_exit_loops, cancel_loop, cancel_loop_tree,
verify_loop_structure): Ditto.
* tree-flow.h (vectorize_loops, tree_ssa_lim, tree_ssa_unswitch_loops,
canonicalize_induction_variables, tree_unroll_loops_completely,
tree_ssa_prefetch_arrays, remove_empty_loops, tree_ssa_iv_optimize,
estimate_numbers_of_iterations, free_numbers_of_iterations_estimates,
tree_duplicate_loop_to_header_edge, tree_ssa_loop_version,
tree_unroll_loop, linear_transform_loops): Declaration changed.
* basic-block.h: Remove declaration of struct loops.
* cfghooks.h (struct cfg_hooks): Change type of
cfg_hook_duplicate_loop_to_header_edge.
(cfg_hook_duplicate_loop_to_header_edge): Declaration changed.
* tree-vectorizer.h (slpeel_tree_peel_loop_to_edge,
vect_transform_loop): Declaration changed.
* lambda.h (gcc_loopnest_to_lambda_loopnest): Declaration changed.
* cfgloop.h (flow_loops_dump, fix_loop_structure,
mark_irreducible_loops, mark_single_exit_loops, mark_loop_exit_edges,
cancel_loop_tree, create_preheaders, force_single_succ_latches,
verify_loop_structure, duplicate_loop, duplicate_loop_to_header_edge,
loopify, loop_version, remove_path, unswitch_loops,
unroll_and_peel_loops, doloop_optimize_loops, move_loop_invariants):
Declaration changed.
From-SVN: r119189
2006-11-25 11:34:13 +01:00
|
|
|
unrolled |= loop_prefetch_arrays (loop);
|
2006-02-14 14:51:51 +01:00
|
|
|
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
fprintf (dump_file, "\n\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (unrolled)
|
|
|
|
{
|
|
|
|
scev_reset ();
|
2006-09-06 08:13:22 +02:00
|
|
|
todo_flags |= TODO_cleanup_cfg;
|
2006-02-14 14:51:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
free_original_copy_tables ();
|
2006-09-06 08:13:22 +02:00
|
|
|
return todo_flags;
|
2006-02-14 14:51:51 +01:00
|
|
|
}
|