gcc/gcc/graphite-blocking.c

268 lines
6.5 KiB
C
Raw Normal View History

/* Heuristics and transform for loop blocking and strip mining on
polyhedral representation.
cloog.m4: Set up to work against ISL only. 2012-07-02 Richard Guenther <rguenther@suse.de> Michael Matz <matz@suse.de> Tobias Grosser <tobias@grosser.es> Sebastian Pop <sebpop@gmail.com> config/ * cloog.m4: Set up to work against ISL only. * isl.m4: New file. * Makefile.def: Add ISL host module, remove PPL host module. Adjust ClooG host module to use the proper ISL. * Makefile.tpl: Pass ISL include flags instead of PPL ones. * configure.ac: Include config/isl.m4. Add ISL host library, remove PPL. Remove PPL configury, add ISL configury, adjust ClooG configury. * Makefile.in: Regenerated. * configure: Likewise. gcc/ * Makefile.in: Remove PPL flags in favor of ISL ones. (BACKENDLIBS): Remove PPL libs. (INCLUDES): Remove PPL includes in favor of ISL ones. (graphite-clast-to-gimple.o): Remove graphite-dependences.h and graphite-cloog-compat.h dependencies. (graphite-dependences.o): Likewise. (graphite-poly.o): Likewise. * configure.ac: Declare ISL vars instead of PPL ones. * configure: Regenerated. * doc/install.texi: Replace PPL requirement documentation with ISL one. * graphite-blocking.c: Remove PPL code, add ISL equivalent. * graphite-clast-to-gimple.c: Likewise. * graphite-dependences.c: Likewise. * graphite-interchange.c: Likewise. * graphite-poly.h: Likewise. * graphite-poly.c: Likewise. * graphite-sese-to-poly.c: Likewise. * graphite.c: Likewise. * graphite-scop-detection.c: Re-arrange includes. * graphite-cloog-util.c: Remove. * graphite-cloog-util.h: Likewise. * graphite-ppl.h: Likewise. * graphite-ppl.c: Likewise. * graphite-dependences.h: Likewise. libgomp/ * testsuite/libgomp.graphite/force-parallel-4.c: Adjust. * testsuite/libgomp.graphite/force-parallel-5.c: Likewise. * testsuite/libgomp.graphite/force-parallel-7.c: Likewise. * testsuite/libgomp.graphite/force-parallel-8.c: Likewise. Co-Authored-By: Michael Matz <matz@suse.de> Co-Authored-By: Sebastian Pop <sebpop@gmail.com> Co-Authored-By: Tobias Grosser <tobias@grosser.es> From-SVN: r189156
2012-07-02 13:43:46 +02:00
Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
Contributed by Sebastian Pop <sebastian.pop@amd.com> and
Pranav Garg <pranav.garg2107@gmail.com>.
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 3, 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 COPYING3. If not see
<http://www.gnu.org/licenses/>. */
cloog.m4: Set up to work against ISL only. 2012-07-02 Richard Guenther <rguenther@suse.de> Michael Matz <matz@suse.de> Tobias Grosser <tobias@grosser.es> Sebastian Pop <sebpop@gmail.com> config/ * cloog.m4: Set up to work against ISL only. * isl.m4: New file. * Makefile.def: Add ISL host module, remove PPL host module. Adjust ClooG host module to use the proper ISL. * Makefile.tpl: Pass ISL include flags instead of PPL ones. * configure.ac: Include config/isl.m4. Add ISL host library, remove PPL. Remove PPL configury, add ISL configury, adjust ClooG configury. * Makefile.in: Regenerated. * configure: Likewise. gcc/ * Makefile.in: Remove PPL flags in favor of ISL ones. (BACKENDLIBS): Remove PPL libs. (INCLUDES): Remove PPL includes in favor of ISL ones. (graphite-clast-to-gimple.o): Remove graphite-dependences.h and graphite-cloog-compat.h dependencies. (graphite-dependences.o): Likewise. (graphite-poly.o): Likewise. * configure.ac: Declare ISL vars instead of PPL ones. * configure: Regenerated. * doc/install.texi: Replace PPL requirement documentation with ISL one. * graphite-blocking.c: Remove PPL code, add ISL equivalent. * graphite-clast-to-gimple.c: Likewise. * graphite-dependences.c: Likewise. * graphite-interchange.c: Likewise. * graphite-poly.h: Likewise. * graphite-poly.c: Likewise. * graphite-sese-to-poly.c: Likewise. * graphite.c: Likewise. * graphite-scop-detection.c: Re-arrange includes. * graphite-cloog-util.c: Remove. * graphite-cloog-util.h: Likewise. * graphite-ppl.h: Likewise. * graphite-ppl.c: Likewise. * graphite-dependences.h: Likewise. libgomp/ * testsuite/libgomp.graphite/force-parallel-4.c: Adjust. * testsuite/libgomp.graphite/force-parallel-5.c: Likewise. * testsuite/libgomp.graphite/force-parallel-7.c: Likewise. * testsuite/libgomp.graphite/force-parallel-8.c: Likewise. Co-Authored-By: Michael Matz <matz@suse.de> Co-Authored-By: Sebastian Pop <sebpop@gmail.com> Co-Authored-By: Tobias Grosser <tobias@grosser.es> From-SVN: r189156
2012-07-02 13:43:46 +02:00
#include "config.h"
cloog.m4: Set up to work against ISL only. 2012-07-02 Richard Guenther <rguenther@suse.de> Michael Matz <matz@suse.de> Tobias Grosser <tobias@grosser.es> Sebastian Pop <sebpop@gmail.com> config/ * cloog.m4: Set up to work against ISL only. * isl.m4: New file. * Makefile.def: Add ISL host module, remove PPL host module. Adjust ClooG host module to use the proper ISL. * Makefile.tpl: Pass ISL include flags instead of PPL ones. * configure.ac: Include config/isl.m4. Add ISL host library, remove PPL. Remove PPL configury, add ISL configury, adjust ClooG configury. * Makefile.in: Regenerated. * configure: Likewise. gcc/ * Makefile.in: Remove PPL flags in favor of ISL ones. (BACKENDLIBS): Remove PPL libs. (INCLUDES): Remove PPL includes in favor of ISL ones. (graphite-clast-to-gimple.o): Remove graphite-dependences.h and graphite-cloog-compat.h dependencies. (graphite-dependences.o): Likewise. (graphite-poly.o): Likewise. * configure.ac: Declare ISL vars instead of PPL ones. * configure: Regenerated. * doc/install.texi: Replace PPL requirement documentation with ISL one. * graphite-blocking.c: Remove PPL code, add ISL equivalent. * graphite-clast-to-gimple.c: Likewise. * graphite-dependences.c: Likewise. * graphite-interchange.c: Likewise. * graphite-poly.h: Likewise. * graphite-poly.c: Likewise. * graphite-sese-to-poly.c: Likewise. * graphite.c: Likewise. * graphite-scop-detection.c: Re-arrange includes. * graphite-cloog-util.c: Remove. * graphite-cloog-util.h: Likewise. * graphite-ppl.h: Likewise. * graphite-ppl.c: Likewise. * graphite-dependences.h: Likewise. libgomp/ * testsuite/libgomp.graphite/force-parallel-4.c: Adjust. * testsuite/libgomp.graphite/force-parallel-5.c: Likewise. * testsuite/libgomp.graphite/force-parallel-7.c: Likewise. * testsuite/libgomp.graphite/force-parallel-8.c: Likewise. Co-Authored-By: Michael Matz <matz@suse.de> Co-Authored-By: Sebastian Pop <sebpop@gmail.com> Co-Authored-By: Tobias Grosser <tobias@grosser.es> From-SVN: r189156
2012-07-02 13:43:46 +02:00
#ifdef HAVE_cloog
#include <isl/set.h>
#include <isl/map.h>
#include <isl/union_map.h>
#include <isl/constraint.h>
#include <cloog/cloog.h>
#include <cloog/isl/domain.h>
#endif
#include "system.h"
#include "coretypes.h"
#include "tree-flow.h"
#include "tree-dump.h"
#include "cfgloop.h"
#include "tree-chrec.h"
#include "tree-data-ref.h"
2010-12-28 18:09:16 +01:00
#include "sese.h"
#ifdef HAVE_cloog
#include "graphite-poly.h"
/* Strip mines with a factor STRIDE the scattering (time) dimension
around PBB at depth TIME_DEPTH.
The following example comes from the wiki page:
http://gcc.gnu.org/wiki/Graphite/Strip_mine
The strip mine of a loop with a tile of 64 can be obtained with a
scattering function as follows:
$ cat ./albert_strip_mine.cloog
# language: C
c
# parameter {n | n >= 0}
1 3
# n 1
1 1 0
1
n
1 # Number of statements:
1
# {i | 0 <= i <= n}
2 4
# i n 1
1 1 0 0
1 -1 1 0
0 0 0
1
i
1 # Scattering functions
3 6
# NEW OLD i n 1
1 -64 0 1 0 0
1 64 0 -1 0 63
0 0 1 -1 0 0
1
NEW OLD
#the output of CLooG is like this:
#$ cloog ./albert_strip_mine.cloog
# for (NEW=0;NEW<=floord(n,64);NEW++) {
# for (OLD=max(64*NEW,0);OLD<=min(64*NEW+63,n);OLD++) {
# S1(i = OLD) ;
# }
# }
*/
static void
pbb_strip_mine_time_depth (poly_bb_p pbb, int time_depth, int stride)
{
cloog.m4: Set up to work against ISL only. 2012-07-02 Richard Guenther <rguenther@suse.de> Michael Matz <matz@suse.de> Tobias Grosser <tobias@grosser.es> Sebastian Pop <sebpop@gmail.com> config/ * cloog.m4: Set up to work against ISL only. * isl.m4: New file. * Makefile.def: Add ISL host module, remove PPL host module. Adjust ClooG host module to use the proper ISL. * Makefile.tpl: Pass ISL include flags instead of PPL ones. * configure.ac: Include config/isl.m4. Add ISL host library, remove PPL. Remove PPL configury, add ISL configury, adjust ClooG configury. * Makefile.in: Regenerated. * configure: Likewise. gcc/ * Makefile.in: Remove PPL flags in favor of ISL ones. (BACKENDLIBS): Remove PPL libs. (INCLUDES): Remove PPL includes in favor of ISL ones. (graphite-clast-to-gimple.o): Remove graphite-dependences.h and graphite-cloog-compat.h dependencies. (graphite-dependences.o): Likewise. (graphite-poly.o): Likewise. * configure.ac: Declare ISL vars instead of PPL ones. * configure: Regenerated. * doc/install.texi: Replace PPL requirement documentation with ISL one. * graphite-blocking.c: Remove PPL code, add ISL equivalent. * graphite-clast-to-gimple.c: Likewise. * graphite-dependences.c: Likewise. * graphite-interchange.c: Likewise. * graphite-poly.h: Likewise. * graphite-poly.c: Likewise. * graphite-sese-to-poly.c: Likewise. * graphite.c: Likewise. * graphite-scop-detection.c: Re-arrange includes. * graphite-cloog-util.c: Remove. * graphite-cloog-util.h: Likewise. * graphite-ppl.h: Likewise. * graphite-ppl.c: Likewise. * graphite-dependences.h: Likewise. libgomp/ * testsuite/libgomp.graphite/force-parallel-4.c: Adjust. * testsuite/libgomp.graphite/force-parallel-5.c: Likewise. * testsuite/libgomp.graphite/force-parallel-7.c: Likewise. * testsuite/libgomp.graphite/force-parallel-8.c: Likewise. Co-Authored-By: Michael Matz <matz@suse.de> Co-Authored-By: Sebastian Pop <sebpop@gmail.com> Co-Authored-By: Tobias Grosser <tobias@grosser.es> From-SVN: r189156
2012-07-02 13:43:46 +02:00
isl_space *d;
isl_constraint *c;
int iter, strip;
/* STRIP is the dimension that iterates with stride STRIDE. */
/* ITER is the dimension that enumerates single iterations inside
one strip that has at most STRIDE iterations. */
strip = time_depth;
iter = strip + 2;
cloog.m4: Set up to work against ISL only. 2012-07-02 Richard Guenther <rguenther@suse.de> Michael Matz <matz@suse.de> Tobias Grosser <tobias@grosser.es> Sebastian Pop <sebpop@gmail.com> config/ * cloog.m4: Set up to work against ISL only. * isl.m4: New file. * Makefile.def: Add ISL host module, remove PPL host module. Adjust ClooG host module to use the proper ISL. * Makefile.tpl: Pass ISL include flags instead of PPL ones. * configure.ac: Include config/isl.m4. Add ISL host library, remove PPL. Remove PPL configury, add ISL configury, adjust ClooG configury. * Makefile.in: Regenerated. * configure: Likewise. gcc/ * Makefile.in: Remove PPL flags in favor of ISL ones. (BACKENDLIBS): Remove PPL libs. (INCLUDES): Remove PPL includes in favor of ISL ones. (graphite-clast-to-gimple.o): Remove graphite-dependences.h and graphite-cloog-compat.h dependencies. (graphite-dependences.o): Likewise. (graphite-poly.o): Likewise. * configure.ac: Declare ISL vars instead of PPL ones. * configure: Regenerated. * doc/install.texi: Replace PPL requirement documentation with ISL one. * graphite-blocking.c: Remove PPL code, add ISL equivalent. * graphite-clast-to-gimple.c: Likewise. * graphite-dependences.c: Likewise. * graphite-interchange.c: Likewise. * graphite-poly.h: Likewise. * graphite-poly.c: Likewise. * graphite-sese-to-poly.c: Likewise. * graphite.c: Likewise. * graphite-scop-detection.c: Re-arrange includes. * graphite-cloog-util.c: Remove. * graphite-cloog-util.h: Likewise. * graphite-ppl.h: Likewise. * graphite-ppl.c: Likewise. * graphite-dependences.h: Likewise. libgomp/ * testsuite/libgomp.graphite/force-parallel-4.c: Adjust. * testsuite/libgomp.graphite/force-parallel-5.c: Likewise. * testsuite/libgomp.graphite/force-parallel-7.c: Likewise. * testsuite/libgomp.graphite/force-parallel-8.c: Likewise. Co-Authored-By: Michael Matz <matz@suse.de> Co-Authored-By: Sebastian Pop <sebpop@gmail.com> Co-Authored-By: Tobias Grosser <tobias@grosser.es> From-SVN: r189156
2012-07-02 13:43:46 +02:00
pbb->transformed = isl_map_insert_dims (pbb->transformed, isl_dim_out,
strip, 2);
/* Lower bound of the striped loop. */
cloog.m4: Set up to work against ISL only. 2012-07-02 Richard Guenther <rguenther@suse.de> Michael Matz <matz@suse.de> Tobias Grosser <tobias@grosser.es> Sebastian Pop <sebpop@gmail.com> config/ * cloog.m4: Set up to work against ISL only. * isl.m4: New file. * Makefile.def: Add ISL host module, remove PPL host module. Adjust ClooG host module to use the proper ISL. * Makefile.tpl: Pass ISL include flags instead of PPL ones. * configure.ac: Include config/isl.m4. Add ISL host library, remove PPL. Remove PPL configury, add ISL configury, adjust ClooG configury. * Makefile.in: Regenerated. * configure: Likewise. gcc/ * Makefile.in: Remove PPL flags in favor of ISL ones. (BACKENDLIBS): Remove PPL libs. (INCLUDES): Remove PPL includes in favor of ISL ones. (graphite-clast-to-gimple.o): Remove graphite-dependences.h and graphite-cloog-compat.h dependencies. (graphite-dependences.o): Likewise. (graphite-poly.o): Likewise. * configure.ac: Declare ISL vars instead of PPL ones. * configure: Regenerated. * doc/install.texi: Replace PPL requirement documentation with ISL one. * graphite-blocking.c: Remove PPL code, add ISL equivalent. * graphite-clast-to-gimple.c: Likewise. * graphite-dependences.c: Likewise. * graphite-interchange.c: Likewise. * graphite-poly.h: Likewise. * graphite-poly.c: Likewise. * graphite-sese-to-poly.c: Likewise. * graphite.c: Likewise. * graphite-scop-detection.c: Re-arrange includes. * graphite-cloog-util.c: Remove. * graphite-cloog-util.h: Likewise. * graphite-ppl.h: Likewise. * graphite-ppl.c: Likewise. * graphite-dependences.h: Likewise. libgomp/ * testsuite/libgomp.graphite/force-parallel-4.c: Adjust. * testsuite/libgomp.graphite/force-parallel-5.c: Likewise. * testsuite/libgomp.graphite/force-parallel-7.c: Likewise. * testsuite/libgomp.graphite/force-parallel-8.c: Likewise. Co-Authored-By: Michael Matz <matz@suse.de> Co-Authored-By: Sebastian Pop <sebpop@gmail.com> Co-Authored-By: Tobias Grosser <tobias@grosser.es> From-SVN: r189156
2012-07-02 13:43:46 +02:00
d = isl_map_get_space (pbb->transformed);
c = isl_inequality_alloc (isl_local_space_from_space (d));
c = isl_constraint_set_coefficient_si (c, isl_dim_out, strip, -stride);
c = isl_constraint_set_coefficient_si (c, isl_dim_out, iter, 1);
pbb->transformed = isl_map_add_constraint (pbb->transformed, c);
/* Upper bound of the striped loop. */
cloog.m4: Set up to work against ISL only. 2012-07-02 Richard Guenther <rguenther@suse.de> Michael Matz <matz@suse.de> Tobias Grosser <tobias@grosser.es> Sebastian Pop <sebpop@gmail.com> config/ * cloog.m4: Set up to work against ISL only. * isl.m4: New file. * Makefile.def: Add ISL host module, remove PPL host module. Adjust ClooG host module to use the proper ISL. * Makefile.tpl: Pass ISL include flags instead of PPL ones. * configure.ac: Include config/isl.m4. Add ISL host library, remove PPL. Remove PPL configury, add ISL configury, adjust ClooG configury. * Makefile.in: Regenerated. * configure: Likewise. gcc/ * Makefile.in: Remove PPL flags in favor of ISL ones. (BACKENDLIBS): Remove PPL libs. (INCLUDES): Remove PPL includes in favor of ISL ones. (graphite-clast-to-gimple.o): Remove graphite-dependences.h and graphite-cloog-compat.h dependencies. (graphite-dependences.o): Likewise. (graphite-poly.o): Likewise. * configure.ac: Declare ISL vars instead of PPL ones. * configure: Regenerated. * doc/install.texi: Replace PPL requirement documentation with ISL one. * graphite-blocking.c: Remove PPL code, add ISL equivalent. * graphite-clast-to-gimple.c: Likewise. * graphite-dependences.c: Likewise. * graphite-interchange.c: Likewise. * graphite-poly.h: Likewise. * graphite-poly.c: Likewise. * graphite-sese-to-poly.c: Likewise. * graphite.c: Likewise. * graphite-scop-detection.c: Re-arrange includes. * graphite-cloog-util.c: Remove. * graphite-cloog-util.h: Likewise. * graphite-ppl.h: Likewise. * graphite-ppl.c: Likewise. * graphite-dependences.h: Likewise. libgomp/ * testsuite/libgomp.graphite/force-parallel-4.c: Adjust. * testsuite/libgomp.graphite/force-parallel-5.c: Likewise. * testsuite/libgomp.graphite/force-parallel-7.c: Likewise. * testsuite/libgomp.graphite/force-parallel-8.c: Likewise. Co-Authored-By: Michael Matz <matz@suse.de> Co-Authored-By: Sebastian Pop <sebpop@gmail.com> Co-Authored-By: Tobias Grosser <tobias@grosser.es> From-SVN: r189156
2012-07-02 13:43:46 +02:00
d = isl_map_get_space (pbb->transformed);
c = isl_inequality_alloc (isl_local_space_from_space (d));
c = isl_constraint_set_coefficient_si (c, isl_dim_out, strip, stride);
c = isl_constraint_set_coefficient_si (c, isl_dim_out, iter, -1);
c = isl_constraint_set_constant_si (c, stride - 1);
pbb->transformed = isl_map_add_constraint (pbb->transformed, c);
/* Static scheduling for ITER level.
This is mandatory to keep the 2d + 1 canonical scheduling format. */
cloog.m4: Set up to work against ISL only. 2012-07-02 Richard Guenther <rguenther@suse.de> Michael Matz <matz@suse.de> Tobias Grosser <tobias@grosser.es> Sebastian Pop <sebpop@gmail.com> config/ * cloog.m4: Set up to work against ISL only. * isl.m4: New file. * Makefile.def: Add ISL host module, remove PPL host module. Adjust ClooG host module to use the proper ISL. * Makefile.tpl: Pass ISL include flags instead of PPL ones. * configure.ac: Include config/isl.m4. Add ISL host library, remove PPL. Remove PPL configury, add ISL configury, adjust ClooG configury. * Makefile.in: Regenerated. * configure: Likewise. gcc/ * Makefile.in: Remove PPL flags in favor of ISL ones. (BACKENDLIBS): Remove PPL libs. (INCLUDES): Remove PPL includes in favor of ISL ones. (graphite-clast-to-gimple.o): Remove graphite-dependences.h and graphite-cloog-compat.h dependencies. (graphite-dependences.o): Likewise. (graphite-poly.o): Likewise. * configure.ac: Declare ISL vars instead of PPL ones. * configure: Regenerated. * doc/install.texi: Replace PPL requirement documentation with ISL one. * graphite-blocking.c: Remove PPL code, add ISL equivalent. * graphite-clast-to-gimple.c: Likewise. * graphite-dependences.c: Likewise. * graphite-interchange.c: Likewise. * graphite-poly.h: Likewise. * graphite-poly.c: Likewise. * graphite-sese-to-poly.c: Likewise. * graphite.c: Likewise. * graphite-scop-detection.c: Re-arrange includes. * graphite-cloog-util.c: Remove. * graphite-cloog-util.h: Likewise. * graphite-ppl.h: Likewise. * graphite-ppl.c: Likewise. * graphite-dependences.h: Likewise. libgomp/ * testsuite/libgomp.graphite/force-parallel-4.c: Adjust. * testsuite/libgomp.graphite/force-parallel-5.c: Likewise. * testsuite/libgomp.graphite/force-parallel-7.c: Likewise. * testsuite/libgomp.graphite/force-parallel-8.c: Likewise. Co-Authored-By: Michael Matz <matz@suse.de> Co-Authored-By: Sebastian Pop <sebpop@gmail.com> Co-Authored-By: Tobias Grosser <tobias@grosser.es> From-SVN: r189156
2012-07-02 13:43:46 +02:00
d = isl_map_get_space (pbb->transformed);
c = isl_equality_alloc (isl_local_space_from_space (d));
c = isl_constraint_set_coefficient_si (c, isl_dim_out, strip + 1, 1);
pbb->transformed = isl_map_add_constraint (pbb->transformed, c);
}
/* Returns true when strip mining with STRIDE of the loop LST is
profitable. */
static bool
lst_strip_mine_profitable_p (lst_p lst, int stride)
{
Replace Value with mpz_t 2010-04-12 Andreas Simbuerger <simbuerg@fim.uni-passau.de> * graphite-blocking.c (pbb_strip_mine_profitable_p): Replace Value with mpz_t. * graphite-clast-to-gimple.c (clast_to_gcc_expression): Same. (precision_for_value): Same. (precision_for_interval): Same. (gcc_type_for_interval): Same. (graphite_create_new_guard): Same. (compute_bounds_for_level): Same. (graphite_create_new_loop_guard): Same. * graphite-interchange.c (build_linearized_memory_access): Same. (pdr_stride_in_loop): Same. (memory_strides_in_loop_1): Same. (memory_strides_in_loop): Same. (extend_scattering): Same. (psct_scattering_dim_for_loop_depth): Same. (pbb_number_of_iterations): Same. * graphite-poly.h (debug_iteration_domains): Same. * graphite-ppl.c (new_Cloog_Domain_from_ppl_Pointset_Powerset): Same. (ppl_set_inhomogeneous_gmp): Same. (ppl_strip_loop): Same. (ppl_lexico_compare_linear_expressions): Same. (ppl_read_polyhedron_matrix): Same. (ppl_max_for_le_pointset): Same. * graphite-ppl.h (ppl_read_polyhedron_matrix): Same. (tree_int_to_gmp): Same. (gmp_cst_to_tree): Same. (ppl_set_inhomogeneous): Same. (ppl_set_inhomogeneous_tree): Same. (ppl_set_coef): Same. (ppl_set_coef_tree): Same. * graphite-sese-to-poly.c (build_pbb_scattering_polyhedrons): Same. (build_scop_scattering): Same. (scan_tree_for_params_right_scev): Same. (scan_tree_for_params): Same. (find_params_in_bb): Same. (find_scop_parameters): Same. (add_upper_bounds_from_estimated_nit): Same. (build_loop_iteration_domains): Same. (add_condition_to_domain): Same. (pdr_add_memory_accesses): Same. From-SVN: r159133
2010-05-06 23:53:35 +02:00
mpz_t niter, strip_stride;
bool res;
gcc_assert (LST_LOOP_P (lst));
Resolve CLooG's value_* macros to their respective mpz_* counterparts. 2010-04-11 Andreas Simbuerger <simbuerg@fim.uni-passau.de> * graphite-blocking.c (pbb_strip_mine_profitable_p): Resolve CLooG's value_* macros to their respective mpz_* counterparts. * graphite-clast-to-gimple.c (clast_to_gcc_expression): Same. (graphite_create_new_loop_guard): Same. * graphite-interchange.c (build_linearized_memory_access): Same. (pdr_stride_in_loop): Same. (memory_strides_in_loop_1): Same. (1st_interchange_profitable_p): Same. * graphite-poly.c (extend_scattering): Same. (psct_scattering_dim_for_loop_depth): Same. (pbb_number_of_iterations): Same. (pbb_number_of_iterations_at_time): Same. * graphite-poly.h (new_1st_loop): Same. * graphite-ppl.c (cloog_matrix_to_ppl_constraint): Same. (oppose_constraint): Same. (insert_constraint_into_matrix): Same. (ppl_set_inhomogeneous_gmp): Same. (ppl_set_coef_gmp): Same. (ppl_strip_loop): Same. (ppl_lexico_compare_linear_expressions): Same. (ppl_max_for_le_pointset): Same. (ppl_min_for_le_pointset): Same. (ppl_build_realtion): Same. * graphite-ppl.h (gmp_cst_to_tree): Same. (ppl_set_inhomogeneous): Same. (ppl_set_inhomogeneous_tree): Same. (ppl_set_coef): Same. (ppl_set_coef_tree): Same. * graphite-sese-to-poly.c (build_pbb_scattering_polyhedrons): Same. (build_scop_scattering): Same. (add_value_to_dim): Same. (scan_tree_for_params_right_scev): Same. (scan_tree_for_params_int): Same. (scan_tree_for_params): Same. (find_params_in_bb): Same. (find_scop_parameters): Same. (add_upper_bounds_from_estimated_nit): Same. (build_loop_iteration_domains): Same. (create_linear_expr_from_tree): Same. (add_condition_to_domain): Same. (pdr_add_memory_accesses): Same. From-SVN: r159132
2010-05-06 23:53:29 +02:00
mpz_init (strip_stride);
mpz_init (niter);
Resolve CLooG's value_* macros to their respective mpz_* counterparts. 2010-04-11 Andreas Simbuerger <simbuerg@fim.uni-passau.de> * graphite-blocking.c (pbb_strip_mine_profitable_p): Resolve CLooG's value_* macros to their respective mpz_* counterparts. * graphite-clast-to-gimple.c (clast_to_gcc_expression): Same. (graphite_create_new_loop_guard): Same. * graphite-interchange.c (build_linearized_memory_access): Same. (pdr_stride_in_loop): Same. (memory_strides_in_loop_1): Same. (1st_interchange_profitable_p): Same. * graphite-poly.c (extend_scattering): Same. (psct_scattering_dim_for_loop_depth): Same. (pbb_number_of_iterations): Same. (pbb_number_of_iterations_at_time): Same. * graphite-poly.h (new_1st_loop): Same. * graphite-ppl.c (cloog_matrix_to_ppl_constraint): Same. (oppose_constraint): Same. (insert_constraint_into_matrix): Same. (ppl_set_inhomogeneous_gmp): Same. (ppl_set_coef_gmp): Same. (ppl_strip_loop): Same. (ppl_lexico_compare_linear_expressions): Same. (ppl_max_for_le_pointset): Same. (ppl_min_for_le_pointset): Same. (ppl_build_realtion): Same. * graphite-ppl.h (gmp_cst_to_tree): Same. (ppl_set_inhomogeneous): Same. (ppl_set_inhomogeneous_tree): Same. (ppl_set_coef): Same. (ppl_set_coef_tree): Same. * graphite-sese-to-poly.c (build_pbb_scattering_polyhedrons): Same. (build_scop_scattering): Same. (add_value_to_dim): Same. (scan_tree_for_params_right_scev): Same. (scan_tree_for_params_int): Same. (scan_tree_for_params): Same. (find_params_in_bb): Same. (find_scop_parameters): Same. (add_upper_bounds_from_estimated_nit): Same. (build_loop_iteration_domains): Same. (create_linear_expr_from_tree): Same. (add_condition_to_domain): Same. (pdr_add_memory_accesses): Same. From-SVN: r159132
2010-05-06 23:53:29 +02:00
mpz_set_si (strip_stride, stride);
lst_niter_for_loop (lst, niter);
Resolve CLooG's value_* macros to their respective mpz_* counterparts. 2010-04-11 Andreas Simbuerger <simbuerg@fim.uni-passau.de> * graphite-blocking.c (pbb_strip_mine_profitable_p): Resolve CLooG's value_* macros to their respective mpz_* counterparts. * graphite-clast-to-gimple.c (clast_to_gcc_expression): Same. (graphite_create_new_loop_guard): Same. * graphite-interchange.c (build_linearized_memory_access): Same. (pdr_stride_in_loop): Same. (memory_strides_in_loop_1): Same. (1st_interchange_profitable_p): Same. * graphite-poly.c (extend_scattering): Same. (psct_scattering_dim_for_loop_depth): Same. (pbb_number_of_iterations): Same. (pbb_number_of_iterations_at_time): Same. * graphite-poly.h (new_1st_loop): Same. * graphite-ppl.c (cloog_matrix_to_ppl_constraint): Same. (oppose_constraint): Same. (insert_constraint_into_matrix): Same. (ppl_set_inhomogeneous_gmp): Same. (ppl_set_coef_gmp): Same. (ppl_strip_loop): Same. (ppl_lexico_compare_linear_expressions): Same. (ppl_max_for_le_pointset): Same. (ppl_min_for_le_pointset): Same. (ppl_build_realtion): Same. * graphite-ppl.h (gmp_cst_to_tree): Same. (ppl_set_inhomogeneous): Same. (ppl_set_inhomogeneous_tree): Same. (ppl_set_coef): Same. (ppl_set_coef_tree): Same. * graphite-sese-to-poly.c (build_pbb_scattering_polyhedrons): Same. (build_scop_scattering): Same. (add_value_to_dim): Same. (scan_tree_for_params_right_scev): Same. (scan_tree_for_params_int): Same. (scan_tree_for_params): Same. (find_params_in_bb): Same. (find_scop_parameters): Same. (add_upper_bounds_from_estimated_nit): Same. (build_loop_iteration_domains): Same. (create_linear_expr_from_tree): Same. (add_condition_to_domain): Same. (pdr_add_memory_accesses): Same. From-SVN: r159132
2010-05-06 23:53:29 +02:00
res = (mpz_cmp (niter, strip_stride) > 0);
Resolve CLooG's value_* macros to their respective mpz_* counterparts. 2010-04-11 Andreas Simbuerger <simbuerg@fim.uni-passau.de> * graphite-blocking.c (pbb_strip_mine_profitable_p): Resolve CLooG's value_* macros to their respective mpz_* counterparts. * graphite-clast-to-gimple.c (clast_to_gcc_expression): Same. (graphite_create_new_loop_guard): Same. * graphite-interchange.c (build_linearized_memory_access): Same. (pdr_stride_in_loop): Same. (memory_strides_in_loop_1): Same. (1st_interchange_profitable_p): Same. * graphite-poly.c (extend_scattering): Same. (psct_scattering_dim_for_loop_depth): Same. (pbb_number_of_iterations): Same. (pbb_number_of_iterations_at_time): Same. * graphite-poly.h (new_1st_loop): Same. * graphite-ppl.c (cloog_matrix_to_ppl_constraint): Same. (oppose_constraint): Same. (insert_constraint_into_matrix): Same. (ppl_set_inhomogeneous_gmp): Same. (ppl_set_coef_gmp): Same. (ppl_strip_loop): Same. (ppl_lexico_compare_linear_expressions): Same. (ppl_max_for_le_pointset): Same. (ppl_min_for_le_pointset): Same. (ppl_build_realtion): Same. * graphite-ppl.h (gmp_cst_to_tree): Same. (ppl_set_inhomogeneous): Same. (ppl_set_inhomogeneous_tree): Same. (ppl_set_coef): Same. (ppl_set_coef_tree): Same. * graphite-sese-to-poly.c (build_pbb_scattering_polyhedrons): Same. (build_scop_scattering): Same. (add_value_to_dim): Same. (scan_tree_for_params_right_scev): Same. (scan_tree_for_params_int): Same. (scan_tree_for_params): Same. (find_params_in_bb): Same. (find_scop_parameters): Same. (add_upper_bounds_from_estimated_nit): Same. (build_loop_iteration_domains): Same. (create_linear_expr_from_tree): Same. (add_condition_to_domain): Same. (pdr_add_memory_accesses): Same. From-SVN: r159132
2010-05-06 23:53:29 +02:00
mpz_clear (strip_stride);
mpz_clear (niter);
return res;
}
/* Strip-mines all the loops of LST with STRIDE. Return the number of
loops strip-mined. */
static int
lst_do_strip_mine_loop (lst_p lst, int depth, int stride)
{
int i;
lst_p l;
poly_bb_p pbb;
if (!lst)
return 0;
if (LST_LOOP_P (lst))
{
int res = 0;
vec.h (FOR_EACH_VEC_ELT): Define. gcc/ * vec.h (FOR_EACH_VEC_ELT): Define. * c-decl.c: Use it. * cfgloop.c: Likewise. * cfgloopmanip.c: Likewise. * cgraph.c: Likewise. * cgraphunit.c: Likewise. * combine.c: Likewise. * config/bfin/bfin.c: Likewise. * config/mips/mips.c: Likewise. * config/rs6000/rs6000.c: Likewise. * dbxout.c: Likewise. * df-scan.c: Likewise. * dominance.c: Likewise. * dse.c: Likewise. * dwarf2out.c: Likewise. * except.c: Likewise. * expr.c: Likewise. * function.c: Likewise. * gcse.c: Likewise. * genattr.c: Likewise. * ggc-common.c: Likewise. * gimplify.c: Likewise. * graphite-blocking.c: Likewise. * graphite-clast-to-gimple.c: Likewise. * graphite-dependences.c: Likewise. * graphite-interchange.c: Likewise. * graphite-poly.c: Likewise. * graphite-scop-detection.c: Likewise. * graphite-sese-to-poly.c: Likewise. * graphite.c: Likewise. * haifa-sched.c: Likewise. * ifcvt.c: Likewise. * implicit-zee.c: Likewise. * ipa-prop.c: Likewise. * ipa-struct-reorg.c: Likewise. * ipa.c: Likewise. * ira-build.c: Likewise. * ira-color.c: Likewise. * ira-emit.c: Likewise. * lambda-code.c: Likewise. * loop-invariant.c: Likewise. * loop-unroll.c: Likewise. * lower-subreg.c: Likewise. * lto-cgraph.c: Likewise. * lto-opts.c: Likewise. * lto-streamer-in.c: Likewise. * lto-streamer-out.c: Likewise. * lto-streamer.c: Likewise. * lto-symtab.c: Likewise. * matrix-reorg.c: Likewise. * opts.c: Likewise. * predict.c: Likewise. * print-tree.c: Likewise. * sdbout.c: Likewise. * sel-sched-dump.c: Likewise. * sel-sched-ir.c: Likewise. * sel-sched.c: Likewise. * sese.c: Likewise. * stor-layout.c: Likewise. * tree-cfg.c: Likewise. * tree-cfgcleanup.c: Likewise. * tree-chrec.c: Likewise. * tree-data-ref.c: Likewise. * tree-emutls.c: Likewise. * tree-inline.c: Likewise. * tree-into-ssa.c: Likewise. * tree-loop-distribution.c: Likewise. * tree-loop-linear.c: Likewise. * tree-mudflap.c: Likewise. * tree-outof-ssa.c: Likewise. * tree-parloops.c: Likewise. * tree-predcom.c: Likewise. * tree-pretty-print.c: Likewise. * tree-scalar-evolution.c: Likewise. * tree-ssa-live.c: Likewise. * tree-ssa-loop-im.c: Likewise. * tree-ssa-loop-ivcanon.c: Likewise. * tree-ssa-loop-ivopts.c: Likewise. * tree-ssa-loop-manip.c: Likewise. * tree-ssa-loop-niter.c: Likewise. * tree-ssa-loop-prefetch.c: Likewise. * tree-ssa-phiprop.c: Likewise. * tree-ssa-pre.c: Likewise. * tree-ssa-reassoc.c: Likewise. * tree-ssa-sccvn.c: Likewise. * tree-ssa-structalias.c: Likewise. * tree-ssa.c: Likewise. * tree-vect-data-refs.c: Likewise. * tree-vect-loop-manip.c: Likewise. * tree-vect-loop.c: Likewise. * tree-vect-patterns.c: Likewise. * tree-vect-slp.c: Likewise. * tree-vect-stmts.c: Likewise. * tree-vrp.c: Likewise. * tree.c: Likewise. * value-prof.c: Likewise. * var-tracking.c: Likewise. * varasm.c: Likewise. * vmsdbgout.c: Likewise. gcc/ada/ * gcc-interface/decl.c: Use FOR_EACH_VEC_ELT. * gcc-interface/trans.c: Likewise. * gcc-interface/utils.c: Likewise. gcc/c-family/ * c-common.c: Use FOR_EACH_VEC_ELT. * c-gimplify.c: Likewise. * c-pragma.c: Likewise. gcc/cp/ * call.c: Use FOR_EACH_VEC_ELT. * class.c: Likewise. * decl.c: Likewise. * decl2.c: Likewise. * error.c: Likewise. * except.c: Likewise. * mangle.c: Likewise. * method.c: Likewise. * name-lookup.c: Likewise. * parser.c: Likewise. * pt.c: Likewise. * repo.c: Likewise. * semantics.c: Likewise. * typeck2.c: Likewise. gcc/fortran/ * trans-openmp.c: Use FOR_EACH_VEC_ELT. gcc/java/ * class.c: Use FOR_EACH_VEC_ELT. * expr.c: Likewise. * jcf-parse.c: Likewise. * resource.c: Likewise. gcc/lto/ * lto.c: Use FOR_EACH_VEC_ELT. From-SVN: r163401
2010-08-20 14:48:59 +02:00
FOR_EACH_VEC_ELT (lst_p, LST_SEQ (lst), i, l)
res += lst_do_strip_mine_loop (l, depth, stride);
return res;
}
pbb = LST_PBB (lst);
pbb_strip_mine_time_depth (pbb, psct_dynamic_dim (pbb, depth), stride);
return 1;
}
/* Strip-mines all the loops of LST with STRIDE. When STRIDE is zero,
read the stride from the PARAM_LOOP_BLOCK_TILE_SIZE. Return the
number of strip-mined loops.
Strip mining transforms a loop
| for (i = 0; i < N; i++)
| S (i);
into the following loop nest:
| for (k = 0; k < N; k += STRIDE)
| for (j = 0; j < STRIDE; j++)
| S (i = k + j);
*/
static int
lst_do_strip_mine (lst_p lst, int stride)
{
int i;
lst_p l;
int res = 0;
int depth;
if (!stride)
stride = PARAM_VALUE (PARAM_LOOP_BLOCK_TILE_SIZE);
if (!lst
|| !LST_LOOP_P (lst))
return false;
vec.h (FOR_EACH_VEC_ELT): Define. gcc/ * vec.h (FOR_EACH_VEC_ELT): Define. * c-decl.c: Use it. * cfgloop.c: Likewise. * cfgloopmanip.c: Likewise. * cgraph.c: Likewise. * cgraphunit.c: Likewise. * combine.c: Likewise. * config/bfin/bfin.c: Likewise. * config/mips/mips.c: Likewise. * config/rs6000/rs6000.c: Likewise. * dbxout.c: Likewise. * df-scan.c: Likewise. * dominance.c: Likewise. * dse.c: Likewise. * dwarf2out.c: Likewise. * except.c: Likewise. * expr.c: Likewise. * function.c: Likewise. * gcse.c: Likewise. * genattr.c: Likewise. * ggc-common.c: Likewise. * gimplify.c: Likewise. * graphite-blocking.c: Likewise. * graphite-clast-to-gimple.c: Likewise. * graphite-dependences.c: Likewise. * graphite-interchange.c: Likewise. * graphite-poly.c: Likewise. * graphite-scop-detection.c: Likewise. * graphite-sese-to-poly.c: Likewise. * graphite.c: Likewise. * haifa-sched.c: Likewise. * ifcvt.c: Likewise. * implicit-zee.c: Likewise. * ipa-prop.c: Likewise. * ipa-struct-reorg.c: Likewise. * ipa.c: Likewise. * ira-build.c: Likewise. * ira-color.c: Likewise. * ira-emit.c: Likewise. * lambda-code.c: Likewise. * loop-invariant.c: Likewise. * loop-unroll.c: Likewise. * lower-subreg.c: Likewise. * lto-cgraph.c: Likewise. * lto-opts.c: Likewise. * lto-streamer-in.c: Likewise. * lto-streamer-out.c: Likewise. * lto-streamer.c: Likewise. * lto-symtab.c: Likewise. * matrix-reorg.c: Likewise. * opts.c: Likewise. * predict.c: Likewise. * print-tree.c: Likewise. * sdbout.c: Likewise. * sel-sched-dump.c: Likewise. * sel-sched-ir.c: Likewise. * sel-sched.c: Likewise. * sese.c: Likewise. * stor-layout.c: Likewise. * tree-cfg.c: Likewise. * tree-cfgcleanup.c: Likewise. * tree-chrec.c: Likewise. * tree-data-ref.c: Likewise. * tree-emutls.c: Likewise. * tree-inline.c: Likewise. * tree-into-ssa.c: Likewise. * tree-loop-distribution.c: Likewise. * tree-loop-linear.c: Likewise. * tree-mudflap.c: Likewise. * tree-outof-ssa.c: Likewise. * tree-parloops.c: Likewise. * tree-predcom.c: Likewise. * tree-pretty-print.c: Likewise. * tree-scalar-evolution.c: Likewise. * tree-ssa-live.c: Likewise. * tree-ssa-loop-im.c: Likewise. * tree-ssa-loop-ivcanon.c: Likewise. * tree-ssa-loop-ivopts.c: Likewise. * tree-ssa-loop-manip.c: Likewise. * tree-ssa-loop-niter.c: Likewise. * tree-ssa-loop-prefetch.c: Likewise. * tree-ssa-phiprop.c: Likewise. * tree-ssa-pre.c: Likewise. * tree-ssa-reassoc.c: Likewise. * tree-ssa-sccvn.c: Likewise. * tree-ssa-structalias.c: Likewise. * tree-ssa.c: Likewise. * tree-vect-data-refs.c: Likewise. * tree-vect-loop-manip.c: Likewise. * tree-vect-loop.c: Likewise. * tree-vect-patterns.c: Likewise. * tree-vect-slp.c: Likewise. * tree-vect-stmts.c: Likewise. * tree-vrp.c: Likewise. * tree.c: Likewise. * value-prof.c: Likewise. * var-tracking.c: Likewise. * varasm.c: Likewise. * vmsdbgout.c: Likewise. gcc/ada/ * gcc-interface/decl.c: Use FOR_EACH_VEC_ELT. * gcc-interface/trans.c: Likewise. * gcc-interface/utils.c: Likewise. gcc/c-family/ * c-common.c: Use FOR_EACH_VEC_ELT. * c-gimplify.c: Likewise. * c-pragma.c: Likewise. gcc/cp/ * call.c: Use FOR_EACH_VEC_ELT. * class.c: Likewise. * decl.c: Likewise. * decl2.c: Likewise. * error.c: Likewise. * except.c: Likewise. * mangle.c: Likewise. * method.c: Likewise. * name-lookup.c: Likewise. * parser.c: Likewise. * pt.c: Likewise. * repo.c: Likewise. * semantics.c: Likewise. * typeck2.c: Likewise. gcc/fortran/ * trans-openmp.c: Use FOR_EACH_VEC_ELT. gcc/java/ * class.c: Use FOR_EACH_VEC_ELT. * expr.c: Likewise. * jcf-parse.c: Likewise. * resource.c: Likewise. gcc/lto/ * lto.c: Use FOR_EACH_VEC_ELT. From-SVN: r163401
2010-08-20 14:48:59 +02:00
FOR_EACH_VEC_ELT (lst_p, LST_SEQ (lst), i, l)
res += lst_do_strip_mine (l, stride);
depth = lst_depth (lst);
if (depth >= 0
&& lst_strip_mine_profitable_p (lst, stride))
{
res += lst_do_strip_mine_loop (lst, lst_depth (lst), stride);
lst_add_loop_under_loop (lst);
}
return res;
}
/* Strip mines all the loops in SCOP. Returns the number of
strip-mined loops. */
int
scop_do_strip_mine (scop_p scop, int stride)
{
return lst_do_strip_mine (SCOP_TRANSFORMED_SCHEDULE (scop), stride);
}
/* Loop blocks all the loops in SCOP. Returns true when we manage to
block some loops. */
bool
scop_do_block (scop_p scop)
{
store_scattering (scop);
/* If we don't strip mine at least two loops, or not interchange
loops, the strip mine alone will not be profitable, and the
transform is not a loop blocking: so revert the transform. */
if (lst_do_strip_mine (SCOP_TRANSFORMED_SCHEDULE (scop), 0) < 2
|| scop_do_interchange (scop) == 0)
{
restore_scattering (scop);
return false;
}
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "SCoP will be loop blocked.\n");
return true;
}
#endif