blob: cc8118bba7e03da698925eaaab23500cff532b86 [file] [log] [blame]
Tobias Grosser30aa24c2011-05-14 19:02:06 +00001//===- Schedule.cpp - Calculate an optimized schedule ---------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
Tobias Grosser234a4822015-08-15 09:34:33 +000010// This pass generates an entirey new schedule tree from the data dependences
11// and iteration domains. The new schedule tree is computed in two steps:
Tobias Grosser30aa24c2011-05-14 19:02:06 +000012//
Tobias Grosser234a4822015-08-15 09:34:33 +000013// 1) The isl scheduling optimizer is run
14//
15// The isl scheduling optimizer creates a new schedule tree that maximizes
16// parallelism and tileability and minimizes data-dependence distances. The
17// algorithm used is a modified version of the ``Pluto'' algorithm:
18//
19// U. Bondhugula, A. Hartono, J. Ramanujam, and P. Sadayappan.
20// A Practical Automatic Polyhedral Parallelizer and Locality Optimizer.
21// In Proceedings of the 2008 ACM SIGPLAN Conference On Programming Language
22// Design and Implementation, PLDI ’08, pages 101–113. ACM, 2008.
23//
24// 2) A set of post-scheduling transformations is applied on the schedule tree.
25//
26// These optimizations include:
27//
28// - Tiling of the innermost tilable bands
29// - Prevectorization - The coice of a possible outer loop that is strip-mined
30// to the innermost level to enable inner-loop
31// vectorization.
32// - Some optimizations for spatial locality are also planned.
33//
34// For a detailed description of the schedule tree itself please see section 6
35// of:
36//
37// Polyhedral AST generation is more than scanning polyhedra
38// Tobias Grosser, Sven Verdoolaege, Albert Cohen
39// ACM Transations on Programming Languages and Systems (TOPLAS),
40// 37(4), July 2015
41// http://www.grosser.es/#pub-polyhedral-AST-generation
42//
43// This publication also contains a detailed discussion of the different options
44// for polyhedral loop unrolling, full/partial tile separation and other uses
45// of the schedule tree.
46//
Tobias Grosser30aa24c2011-05-14 19:02:06 +000047//===----------------------------------------------------------------------===//
48
Tobias Grosser967239c2011-10-23 20:59:44 +000049#include "polly/ScheduleOptimizer.h"
Tobias Grosserba0d0922015-05-09 09:13:42 +000050#include "polly/CodeGen/CodeGeneration.h"
51#include "polly/DependenceInfo.h"
52#include "polly/LinkAllPasses.h"
53#include "polly/Options.h"
54#include "polly/ScopInfo.h"
55#include "polly/Support/GICHelper.h"
56#include "llvm/Support/Debug.h"
Tobias Grosser2493e922011-12-07 07:42:57 +000057#include "isl/aff.h"
Tobias Grosserde68cc92011-06-30 20:01:02 +000058#include "isl/band.h"
Tobias Grosser8ad6bc32012-01-31 13:26:29 +000059#include "isl/constraint.h"
60#include "isl/map.h"
Tobias Grosser42152ff2012-01-30 19:38:47 +000061#include "isl/options.h"
Tobias Grosser97d87452015-05-30 06:46:59 +000062#include "isl/printer.h"
Tobias Grosser8ad6bc32012-01-31 13:26:29 +000063#include "isl/schedule.h"
Tobias Grosserbbb4cec2015-03-22 12:06:39 +000064#include "isl/schedule_node.h"
Tobias Grosser8ad6bc32012-01-31 13:26:29 +000065#include "isl/space.h"
Tobias Grossercd524dc2015-05-09 09:36:38 +000066#include "isl/union_map.h"
67#include "isl/union_set.h"
Tobias Grosser30aa24c2011-05-14 19:02:06 +000068
69using namespace llvm;
70using namespace polly;
71
Chandler Carruth95fef942014-04-22 03:30:19 +000072#define DEBUG_TYPE "polly-opt-isl"
73
Tobias Grossera26db472012-01-30 19:38:43 +000074static cl::opt<std::string>
Tobias Grosser483a90d2014-07-09 10:50:10 +000075 OptimizeDeps("polly-opt-optimize-only",
76 cl::desc("Only a certain kind of dependences (all/raw)"),
77 cl::Hidden, cl::init("all"), cl::ZeroOrMore,
78 cl::cat(PollyCategory));
Tobias Grosser1deda292012-02-14 14:02:48 +000079
80static cl::opt<std::string>
Tobias Grosser483a90d2014-07-09 10:50:10 +000081 SimplifyDeps("polly-opt-simplify-deps",
82 cl::desc("Dependences should be simplified (yes/no)"),
83 cl::Hidden, cl::init("yes"), cl::ZeroOrMore,
84 cl::cat(PollyCategory));
Tobias Grossera26db472012-01-30 19:38:43 +000085
Tobias Grosser483a90d2014-07-09 10:50:10 +000086static cl::opt<int> MaxConstantTerm(
87 "polly-opt-max-constant-term",
88 cl::desc("The maximal constant term allowed (-1 is unlimited)"), cl::Hidden,
89 cl::init(20), cl::ZeroOrMore, cl::cat(PollyCategory));
Tobias Grosser992e60c2012-02-20 08:41:15 +000090
Tobias Grosser483a90d2014-07-09 10:50:10 +000091static cl::opt<int> MaxCoefficient(
92 "polly-opt-max-coefficient",
93 cl::desc("The maximal coefficient allowed (-1 is unlimited)"), cl::Hidden,
94 cl::init(20), cl::ZeroOrMore, cl::cat(PollyCategory));
95
96static cl::opt<std::string> FusionStrategy(
97 "polly-opt-fusion", cl::desc("The fusion strategy to choose (min/max)"),
98 cl::Hidden, cl::init("min"), cl::ZeroOrMore, cl::cat(PollyCategory));
Tobias Grosser92f54802012-02-20 08:41:47 +000099
Tobias Grossere602a072013-05-07 07:30:56 +0000100static cl::opt<std::string>
Tobias Grosser483a90d2014-07-09 10:50:10 +0000101 MaximizeBandDepth("polly-opt-maximize-bands",
102 cl::desc("Maximize the band depth (yes/no)"), cl::Hidden,
103 cl::init("yes"), cl::ZeroOrMore, cl::cat(PollyCategory));
Tobias Grosserb3ad85b2012-01-30 19:38:50 +0000104
Michael Kruse315aa322016-05-02 11:35:27 +0000105static cl::opt<std::string> OuterCoincidence(
106 "polly-opt-outer-coincidence",
107 cl::desc("Try to construct schedules where the outer member of each band "
108 "satisfies the coincidence constraints (yes/no)"),
109 cl::Hidden, cl::init("no"), cl::ZeroOrMore, cl::cat(PollyCategory));
110
Tobias Grosser07c1c2f2015-08-19 08:46:11 +0000111static cl::opt<int> PrevectorWidth(
112 "polly-prevect-width",
113 cl::desc(
114 "The number of loop iterations to strip-mine for pre-vectorization"),
115 cl::Hidden, cl::init(4), cl::ZeroOrMore, cl::cat(PollyCategory));
116
Tobias Grosser04832712015-08-20 13:45:02 +0000117static cl::opt<bool> FirstLevelTiling("polly-tiling",
118 cl::desc("Enable loop tiling"),
119 cl::init(true), cl::ZeroOrMore,
120 cl::cat(PollyCategory));
121
122static cl::opt<int> FirstLevelDefaultTileSize(
Tobias Grosser483a90d2014-07-09 10:50:10 +0000123 "polly-default-tile-size",
124 cl::desc("The default tile size (if not enough were provided by"
125 " --polly-tile-sizes)"),
126 cl::Hidden, cl::init(32), cl::ZeroOrMore, cl::cat(PollyCategory));
Johannes Doerfertc3958b22014-05-28 17:21:02 +0000127
Tobias Grosser04832712015-08-20 13:45:02 +0000128static cl::list<int> FirstLevelTileSizes(
129 "polly-tile-sizes", cl::desc("A tile size for each loop dimension, filled "
130 "with --polly-default-tile-size"),
131 cl::Hidden, cl::ZeroOrMore, cl::CommaSeparated, cl::cat(PollyCategory));
132
133static cl::opt<bool>
134 SecondLevelTiling("polly-2nd-level-tiling",
135 cl::desc("Enable a 2nd level loop of loop tiling"),
136 cl::init(false), cl::ZeroOrMore, cl::cat(PollyCategory));
137
138static cl::opt<int> SecondLevelDefaultTileSize(
139 "polly-2nd-level-default-tile-size",
140 cl::desc("The default 2nd-level tile size (if not enough were provided by"
141 " --polly-2nd-level-tile-sizes)"),
142 cl::Hidden, cl::init(16), cl::ZeroOrMore, cl::cat(PollyCategory));
143
144static cl::list<int>
145 SecondLevelTileSizes("polly-2nd-level-tile-sizes",
146 cl::desc("A tile size for each loop dimension, filled "
147 "with --polly-default-tile-size"),
148 cl::Hidden, cl::ZeroOrMore, cl::CommaSeparated,
149 cl::cat(PollyCategory));
150
Tobias Grosser42e24892015-08-20 13:45:05 +0000151static cl::opt<bool> RegisterTiling("polly-register-tiling",
152 cl::desc("Enable register tiling"),
153 cl::init(false), cl::ZeroOrMore,
154 cl::cat(PollyCategory));
155
156static cl::opt<int> RegisterDefaultTileSize(
157 "polly-register-tiling-default-tile-size",
158 cl::desc("The default register tile size (if not enough were provided by"
159 " --polly-register-tile-sizes)"),
160 cl::Hidden, cl::init(2), cl::ZeroOrMore, cl::cat(PollyCategory));
161
162static cl::list<int>
163 RegisterTileSizes("polly-register-tile-sizes",
164 cl::desc("A tile size for each loop dimension, filled "
165 "with --polly-register-tile-size"),
166 cl::Hidden, cl::ZeroOrMore, cl::CommaSeparated,
167 cl::cat(PollyCategory));
168
Roman Gareev9c3eb592016-05-28 16:17:58 +0000169static cl::opt<bool>
170 PMBasedOpts("polly-pattern-matching-based-opts",
171 cl::desc("Perform optimizations based on pattern matching"),
172 cl::init(false), cl::ZeroOrMore, cl::cat(PollyCategory));
173
Tobias Grosserca7f5bb2015-10-20 09:12:21 +0000174/// @brief Create an isl_union_set, which describes the isolate option based
175/// on IsoalteDomain.
176///
177/// @param IsolateDomain An isl_set whose last dimension is the only one that
178/// should belong to the current band node.
179static __isl_give isl_union_set *
180getIsolateOptions(__isl_take isl_set *IsolateDomain) {
181 auto Dims = isl_set_dim(IsolateDomain, isl_dim_set);
182 auto *IsolateRelation = isl_map_from_domain(IsolateDomain);
183 IsolateRelation = isl_map_move_dims(IsolateRelation, isl_dim_out, 0,
184 isl_dim_in, Dims - 1, 1);
185 auto *IsolateOption = isl_map_wrap(IsolateRelation);
186 auto *Id = isl_id_alloc(isl_set_get_ctx(IsolateOption), "isolate", NULL);
187 return isl_union_set_from_set(isl_set_set_tuple_id(IsolateOption, Id));
188}
189
190/// @brief Create an isl_union_set, which describes the atomic option for the
191/// dimension of the current node.
192///
193/// It may help to reduce the size of generated code.
194///
195/// @param Ctx An isl_ctx, which is used to create the isl_union_set.
196static __isl_give isl_union_set *getAtomicOptions(__isl_take isl_ctx *Ctx) {
197 auto *Space = isl_space_set_alloc(Ctx, 0, 1);
198 auto *AtomicOption = isl_set_universe(Space);
199 auto *Id = isl_id_alloc(Ctx, "atomic", NULL);
200 return isl_union_set_from_set(isl_set_set_tuple_id(AtomicOption, Id));
201}
202
203/// @brief Make the last dimension of Set to take values
204/// from 0 to VectorWidth - 1.
205///
206/// @param Set A set, which should be modified.
207/// @param VectorWidth A parameter, which determines the constraint.
208static __isl_give isl_set *addExtentConstraints(__isl_take isl_set *Set,
209 int VectorWidth) {
210 auto Dims = isl_set_dim(Set, isl_dim_set);
211 auto Space = isl_set_get_space(Set);
212 auto *LocalSpace = isl_local_space_from_space(Space);
213 auto *ExtConstr =
214 isl_constraint_alloc_inequality(isl_local_space_copy(LocalSpace));
215 ExtConstr = isl_constraint_set_constant_si(ExtConstr, 0);
216 ExtConstr =
217 isl_constraint_set_coefficient_si(ExtConstr, isl_dim_set, Dims - 1, 1);
218 Set = isl_set_add_constraint(Set, ExtConstr);
219 ExtConstr = isl_constraint_alloc_inequality(LocalSpace);
220 ExtConstr = isl_constraint_set_constant_si(ExtConstr, VectorWidth - 1);
221 ExtConstr =
222 isl_constraint_set_coefficient_si(ExtConstr, isl_dim_set, Dims - 1, -1);
223 return isl_set_add_constraint(Set, ExtConstr);
224}
225
226/// @brief Build the desired set of partial tile prefixes.
227///
228/// We build a set of partial tile prefixes, which are prefixes of the vector
229/// loop that have exactly VectorWidth iterations.
230///
231/// 1. Get all prefixes of the vector loop.
232/// 2. Extend it to a set, which has exactly VectorWidth iterations for
233/// any prefix from the set that was built on the previous step.
234/// 3. Subtract loop domain from it, project out the vector loop dimension and
Roman Gareev76614d32016-05-31 11:22:21 +0000235/// get a set of prefixes, which don't have exactly VectorWidth iterations.
Tobias Grosserca7f5bb2015-10-20 09:12:21 +0000236/// 4. Subtract it from all prefixes of the vector loop and get the desired
237/// set.
238///
239/// @param ScheduleRange A range of a map, which describes a prefix schedule
240/// relation.
241static __isl_give isl_set *
242getPartialTilePrefixes(__isl_take isl_set *ScheduleRange, int VectorWidth) {
243 auto Dims = isl_set_dim(ScheduleRange, isl_dim_set);
244 auto *LoopPrefixes = isl_set_project_out(isl_set_copy(ScheduleRange),
245 isl_dim_set, Dims - 1, 1);
246 auto *ExtentPrefixes =
247 isl_set_add_dims(isl_set_copy(LoopPrefixes), isl_dim_set, 1);
248 ExtentPrefixes = addExtentConstraints(ExtentPrefixes, VectorWidth);
249 auto *BadPrefixes = isl_set_subtract(ExtentPrefixes, ScheduleRange);
250 BadPrefixes = isl_set_project_out(BadPrefixes, isl_dim_set, Dims - 1, 1);
251 return isl_set_subtract(LoopPrefixes, BadPrefixes);
252}
253
254__isl_give isl_schedule_node *ScheduleTreeOptimizer::isolateFullPartialTiles(
255 __isl_take isl_schedule_node *Node, int VectorWidth) {
256 assert(isl_schedule_node_get_type(Node) == isl_schedule_node_band);
257 Node = isl_schedule_node_child(Node, 0);
258 Node = isl_schedule_node_child(Node, 0);
259 auto *SchedRelUMap = isl_schedule_node_get_prefix_schedule_relation(Node);
260 auto *ScheduleRelation = isl_map_from_union_map(SchedRelUMap);
261 auto *ScheduleRange = isl_map_range(ScheduleRelation);
262 auto *IsolateDomain = getPartialTilePrefixes(ScheduleRange, VectorWidth);
263 auto *AtomicOption = getAtomicOptions(isl_set_get_ctx(IsolateDomain));
264 auto *IsolateOption = getIsolateOptions(IsolateDomain);
265 Node = isl_schedule_node_parent(Node);
266 Node = isl_schedule_node_parent(Node);
267 auto *Options = isl_union_set_union(IsolateOption, AtomicOption);
268 Node = isl_schedule_node_band_set_ast_build_options(Node, Options);
269 return Node;
270}
271
Tobias Grosserb241d922015-07-28 18:03:36 +0000272__isl_give isl_schedule_node *
Tobias Grosserfa57e9b2015-08-24 06:01:47 +0000273ScheduleTreeOptimizer::prevectSchedBand(__isl_take isl_schedule_node *Node,
274 unsigned DimToVectorize,
275 int VectorWidth) {
Tobias Grosserb241d922015-07-28 18:03:36 +0000276 assert(isl_schedule_node_get_type(Node) == isl_schedule_node_band);
Tobias Grosserc6699b72011-06-30 20:29:13 +0000277
Tobias Grosserb241d922015-07-28 18:03:36 +0000278 auto Space = isl_schedule_node_band_get_space(Node);
279 auto ScheduleDimensions = isl_space_dim(Space, isl_dim_set);
280 isl_space_free(Space);
281 assert(DimToVectorize < ScheduleDimensions);
Tobias Grosserf5338802011-10-06 00:03:35 +0000282
Tobias Grosserb241d922015-07-28 18:03:36 +0000283 if (DimToVectorize > 0) {
284 Node = isl_schedule_node_band_split(Node, DimToVectorize);
285 Node = isl_schedule_node_child(Node, 0);
286 }
287 if (DimToVectorize < ScheduleDimensions - 1)
288 Node = isl_schedule_node_band_split(Node, 1);
289 Space = isl_schedule_node_band_get_space(Node);
290 auto Sizes = isl_multi_val_zero(Space);
291 auto Ctx = isl_schedule_node_get_ctx(Node);
292 Sizes =
293 isl_multi_val_set_val(Sizes, 0, isl_val_int_from_si(Ctx, VectorWidth));
294 Node = isl_schedule_node_band_tile(Node, Sizes);
Tobias Grosserca7f5bb2015-10-20 09:12:21 +0000295 Node = isolateFullPartialTiles(Node, VectorWidth);
Tobias Grosserb241d922015-07-28 18:03:36 +0000296 Node = isl_schedule_node_child(Node, 0);
Tobias Grosser42e24892015-08-20 13:45:05 +0000297 // Make sure the "trivially vectorizable loop" is not unrolled. Otherwise,
298 // we will have troubles to match it in the backend.
299 Node = isl_schedule_node_band_set_ast_build_options(
Tobias Grosserfc490a92015-08-20 19:08:16 +0000300 Node, isl_union_set_read_from_str(Ctx, "{ unroll[x]: 1 = 0 }"));
301 Node = isl_schedule_node_band_sink(Node);
Tobias Grosserb241d922015-07-28 18:03:36 +0000302 Node = isl_schedule_node_child(Node, 0);
Roman Gareev11001e12016-02-23 09:00:13 +0000303 if (isl_schedule_node_get_type(Node) == isl_schedule_node_leaf)
304 Node = isl_schedule_node_parent(Node);
305 isl_id *LoopMarker = isl_id_alloc(Ctx, "SIMD", nullptr);
306 Node = isl_schedule_node_insert_mark(Node, LoopMarker);
Tobias Grosserb241d922015-07-28 18:03:36 +0000307 return Node;
Tobias Grosserc6699b72011-06-30 20:29:13 +0000308}
309
Tobias Grosserd891b542015-08-20 12:16:23 +0000310__isl_give isl_schedule_node *
Tobias Grosserfa57e9b2015-08-24 06:01:47 +0000311ScheduleTreeOptimizer::tileNode(__isl_take isl_schedule_node *Node,
312 const char *Identifier, ArrayRef<int> TileSizes,
313 int DefaultTileSize) {
Tobias Grosser9bdea572015-08-20 12:22:37 +0000314 auto Ctx = isl_schedule_node_get_ctx(Node);
315 auto Space = isl_schedule_node_band_get_space(Node);
316 auto Dims = isl_space_dim(Space, isl_dim_set);
317 auto Sizes = isl_multi_val_zero(Space);
Tobias Grosser1ac884d2015-08-23 09:11:00 +0000318 std::string IdentifierString(Identifier);
Tobias Grosser9bdea572015-08-20 12:22:37 +0000319 for (unsigned i = 0; i < Dims; i++) {
320 auto tileSize = i < TileSizes.size() ? TileSizes[i] : DefaultTileSize;
321 Sizes = isl_multi_val_set_val(Sizes, i, isl_val_int_from_si(Ctx, tileSize));
322 }
Tobias Grosser1ac884d2015-08-23 09:11:00 +0000323 auto TileLoopMarkerStr = IdentifierString + " - Tiles";
324 isl_id *TileLoopMarker =
325 isl_id_alloc(Ctx, TileLoopMarkerStr.c_str(), nullptr);
326 Node = isl_schedule_node_insert_mark(Node, TileLoopMarker);
327 Node = isl_schedule_node_child(Node, 0);
Tobias Grosser9bdea572015-08-20 12:22:37 +0000328 Node = isl_schedule_node_band_tile(Node, Sizes);
Tobias Grosser1ac884d2015-08-23 09:11:00 +0000329 Node = isl_schedule_node_child(Node, 0);
330 auto PointLoopMarkerStr = IdentifierString + " - Points";
331 isl_id *PointLoopMarker =
332 isl_id_alloc(Ctx, PointLoopMarkerStr.c_str(), nullptr);
333 Node = isl_schedule_node_insert_mark(Node, PointLoopMarker);
334 Node = isl_schedule_node_child(Node, 0);
335 return Node;
Tobias Grosser9bdea572015-08-20 12:22:37 +0000336}
337
Roman Gareevb17b9a82016-06-12 17:20:05 +0000338__isl_give isl_schedule_node *
339ScheduleTreeOptimizer::applyRegisterTiling(__isl_take isl_schedule_node *Node,
340 llvm::ArrayRef<int> TileSizes,
341 int DefaultTileSize) {
342 auto *Ctx = isl_schedule_node_get_ctx(Node);
343 Node = tileNode(Node, "Register tiling", TileSizes, DefaultTileSize);
344 Node = isl_schedule_node_band_set_ast_build_options(
345 Node, isl_union_set_read_from_str(Ctx, "{unroll[x]}"));
346 return Node;
347}
348
Tobias Grosserfa57e9b2015-08-24 06:01:47 +0000349bool ScheduleTreeOptimizer::isTileableBandNode(
Tobias Grosser862b9b52015-08-20 12:32:45 +0000350 __isl_keep isl_schedule_node *Node) {
Tobias Grosserbbb4cec2015-03-22 12:06:39 +0000351 if (isl_schedule_node_get_type(Node) != isl_schedule_node_band)
Tobias Grosser862b9b52015-08-20 12:32:45 +0000352 return false;
Tobias Grosserde68cc92011-06-30 20:01:02 +0000353
Tobias Grosserbbb4cec2015-03-22 12:06:39 +0000354 if (isl_schedule_node_n_children(Node) != 1)
Tobias Grosser862b9b52015-08-20 12:32:45 +0000355 return false;
Tobias Grosserde68cc92011-06-30 20:01:02 +0000356
Tobias Grosserbbb4cec2015-03-22 12:06:39 +0000357 if (!isl_schedule_node_band_get_permutable(Node))
Tobias Grosser862b9b52015-08-20 12:32:45 +0000358 return false;
Tobias Grosser44f19ac2011-07-05 22:15:53 +0000359
Tobias Grosserbbb4cec2015-03-22 12:06:39 +0000360 auto Space = isl_schedule_node_band_get_space(Node);
361 auto Dims = isl_space_dim(Space, isl_dim_set);
Tobias Grosser9bdea572015-08-20 12:22:37 +0000362 isl_space_free(Space);
Tobias Grosserde68cc92011-06-30 20:01:02 +0000363
Tobias Grosser9bdea572015-08-20 12:22:37 +0000364 if (Dims <= 1)
Tobias Grosser862b9b52015-08-20 12:32:45 +0000365 return false;
Tobias Grosserde68cc92011-06-30 20:01:02 +0000366
Tobias Grosserbbb4cec2015-03-22 12:06:39 +0000367 auto Child = isl_schedule_node_get_child(Node, 0);
368 auto Type = isl_schedule_node_get_type(Child);
369 isl_schedule_node_free(Child);
370
Tobias Grosser9bdea572015-08-20 12:22:37 +0000371 if (Type != isl_schedule_node_leaf)
Tobias Grosser862b9b52015-08-20 12:32:45 +0000372 return false;
373
374 return true;
375}
376
377__isl_give isl_schedule_node *
Roman Gareev9c3eb592016-05-28 16:17:58 +0000378ScheduleTreeOptimizer::standardBandOpts(__isl_take isl_schedule_node *Node,
379 void *User) {
Tobias Grosser04832712015-08-20 13:45:02 +0000380 if (FirstLevelTiling)
Tobias Grosser1ac884d2015-08-23 09:11:00 +0000381 Node = tileNode(Node, "1st level tiling", FirstLevelTileSizes,
382 FirstLevelDefaultTileSize);
Tobias Grosser04832712015-08-20 13:45:02 +0000383
384 if (SecondLevelTiling)
Tobias Grosser1ac884d2015-08-23 09:11:00 +0000385 Node = tileNode(Node, "2nd level tiling", SecondLevelTileSizes,
386 SecondLevelDefaultTileSize);
Tobias Grosserbbb4cec2015-03-22 12:06:39 +0000387
Roman Gareevb17b9a82016-06-12 17:20:05 +0000388 if (RegisterTiling)
389 Node =
390 applyRegisterTiling(Node, RegisterTileSizes, RegisterDefaultTileSize);
Tobias Grosser42e24892015-08-20 13:45:05 +0000391
Tobias Grosserbbb4cec2015-03-22 12:06:39 +0000392 if (PollyVectorizerChoice == VECTORIZER_NONE)
Tobias Grosserf10f4632015-08-19 08:03:37 +0000393 return Node;
Tobias Grosserbbb4cec2015-03-22 12:06:39 +0000394
Tobias Grosser862b9b52015-08-20 12:32:45 +0000395 auto Space = isl_schedule_node_band_get_space(Node);
396 auto Dims = isl_space_dim(Space, isl_dim_set);
397 isl_space_free(Space);
398
Tobias Grosserb241d922015-07-28 18:03:36 +0000399 for (int i = Dims - 1; i >= 0; i--)
Tobias Grosserf10f4632015-08-19 08:03:37 +0000400 if (isl_schedule_node_band_member_get_coincident(Node, i)) {
Tobias Grosserfa57e9b2015-08-24 06:01:47 +0000401 Node = prevectSchedBand(Node, i, PrevectorWidth);
Tobias Grosserbbb4cec2015-03-22 12:06:39 +0000402 break;
403 }
Tobias Grosserbbb4cec2015-03-22 12:06:39 +0000404
Tobias Grosserf10f4632015-08-19 08:03:37 +0000405 return Node;
Tobias Grosserde68cc92011-06-30 20:01:02 +0000406}
407
Roman Gareev9c3eb592016-05-28 16:17:58 +0000408/// @brief Check whether output dimensions of the map rely on the specified
409/// input dimension.
410///
411/// @param IslMap The isl map to be considered.
412/// @param DimNum The number of an input dimension to be checked.
413static bool isInputDimUsed(__isl_take isl_map *IslMap, unsigned DimNum) {
414 auto *CheckedAccessRelation =
415 isl_map_project_out(isl_map_copy(IslMap), isl_dim_in, DimNum, 1);
416 CheckedAccessRelation =
417 isl_map_insert_dims(CheckedAccessRelation, isl_dim_in, DimNum, 1);
418 auto *InputDimsId = isl_map_get_tuple_id(IslMap, isl_dim_in);
419 CheckedAccessRelation =
420 isl_map_set_tuple_id(CheckedAccessRelation, isl_dim_in, InputDimsId);
421 InputDimsId = isl_map_get_tuple_id(IslMap, isl_dim_out);
422 CheckedAccessRelation =
423 isl_map_set_tuple_id(CheckedAccessRelation, isl_dim_out, InputDimsId);
424 auto res = !isl_map_is_equal(CheckedAccessRelation, IslMap);
425 isl_map_free(CheckedAccessRelation);
426 isl_map_free(IslMap);
427 return res;
428}
429
430/// @brief Check if the SCoP statement could probably be optimized with
431/// analytical modeling.
432///
433/// containsMatrMult tries to determine whether the following conditions
434/// are true:
435/// 1. all memory accesses of the statement will have stride 0 or 1,
436/// if we interchange loops (switch the variable used in the inner
437/// loop to the outer loop).
438/// 2. all memory accesses of the statement except from the last one, are
439/// read memory access and the last one is write memory access.
Roman Gareev76614d32016-05-31 11:22:21 +0000440/// 3. all subscripts of the last memory access of the statement don't contain
Roman Gareev9c3eb592016-05-28 16:17:58 +0000441/// the variable used in the inner loop.
442///
443/// @param PartialSchedule The PartialSchedule that contains a SCoP statement
444/// to check.
445static bool containsMatrMult(__isl_keep isl_map *PartialSchedule) {
446 auto InputDimsId = isl_map_get_tuple_id(PartialSchedule, isl_dim_in);
447 auto *ScpStmt = static_cast<ScopStmt *>(isl_id_get_user(InputDimsId));
448 isl_id_free(InputDimsId);
449 if (ScpStmt->size() <= 1)
450 return false;
451 auto MemA = ScpStmt->begin();
452 for (unsigned i = 0; i < ScpStmt->size() - 2 && MemA != ScpStmt->end();
453 i++, MemA++)
Roman Gareev76614d32016-05-31 11:22:21 +0000454 if (!(*MemA)->isRead() ||
455 ((*MemA)->isArrayKind() &&
456 !((*MemA)->isStrideOne(isl_map_copy(PartialSchedule)) ||
Roman Gareev9c3eb592016-05-28 16:17:58 +0000457 (*MemA)->isStrideZero(isl_map_copy(PartialSchedule)))))
458 return false;
459 MemA++;
Roman Gareev76614d32016-05-31 11:22:21 +0000460 if (!(*MemA)->isWrite() || !(*MemA)->isArrayKind() ||
461 !((*MemA)->isStrideOne(isl_map_copy(PartialSchedule)) ||
Roman Gareev9c3eb592016-05-28 16:17:58 +0000462 (*MemA)->isStrideZero(isl_map_copy(PartialSchedule))))
463 return false;
464 auto DimNum = isl_map_dim(PartialSchedule, isl_dim_in);
465 return !isInputDimUsed((*MemA)->getAccessRelation(), DimNum - 1);
466}
467
468/// @brief Circular shift of output dimensions of the integer map.
469///
470/// @param IslMap The isl map to be modified.
471static __isl_give isl_map *circularShiftOutputDims(__isl_take isl_map *IslMap) {
Roman Gareev9c3eb592016-05-28 16:17:58 +0000472 auto DimNum = isl_map_dim(IslMap, isl_dim_out);
Roman Gareev4b8c7ae2016-06-03 18:46:29 +0000473 if (DimNum == 0)
474 return IslMap;
475 auto InputDimsId = isl_map_get_tuple_id(IslMap, isl_dim_in);
Roman Gareev9c3eb592016-05-28 16:17:58 +0000476 IslMap = isl_map_move_dims(IslMap, isl_dim_in, 0, isl_dim_out, DimNum - 1, 1);
477 IslMap = isl_map_move_dims(IslMap, isl_dim_out, 0, isl_dim_in, 0, 1);
478 return isl_map_set_tuple_id(IslMap, isl_dim_in, InputDimsId);
479}
480
481bool ScheduleTreeOptimizer::isMatrMultPattern(
482 __isl_keep isl_schedule_node *Node) {
483 auto *PartialSchedule =
484 isl_schedule_node_band_get_partial_schedule_union_map(Node);
485 if (isl_union_map_n_map(PartialSchedule) != 1)
486 return false;
487 auto *NewPartialSchedule = isl_map_from_union_map(PartialSchedule);
488 auto DimNum = isl_map_dim(NewPartialSchedule, isl_dim_in);
489 if (DimNum != 3) {
490 isl_map_free(NewPartialSchedule);
491 return false;
492 }
Roman Gareevba0fb972016-06-04 06:34:04 +0000493 assert(isl_map_dim(NewPartialSchedule, isl_dim_out) == 3 &&
494 "Each schedule dimension should be represented by a union piecewise"
495 "quasi-affine expression.");
Roman Gareev9c3eb592016-05-28 16:17:58 +0000496 NewPartialSchedule = circularShiftOutputDims(NewPartialSchedule);
497 if (containsMatrMult(NewPartialSchedule)) {
498 isl_map_free(NewPartialSchedule);
499 return true;
500 }
501 isl_map_free(NewPartialSchedule);
502 return false;
503}
504
505__isl_give isl_schedule_node *
506ScheduleTreeOptimizer::optimizeBand(__isl_take isl_schedule_node *Node,
507 void *User) {
508 if (!isTileableBandNode(Node))
509 return Node;
510
511 if (PMBasedOpts && isMatrMultPattern(Node))
512 DEBUG(dbgs() << "The matrix multiplication pattern was detected\n");
513
514 return standardBandOpts(Node, User);
515}
516
Tobias Grosser808cd692015-07-14 09:33:13 +0000517__isl_give isl_schedule *
Tobias Grosserfa57e9b2015-08-24 06:01:47 +0000518ScheduleTreeOptimizer::optimizeSchedule(__isl_take isl_schedule *Schedule) {
Tobias Grosserbbb4cec2015-03-22 12:06:39 +0000519 isl_schedule_node *Root = isl_schedule_get_root(Schedule);
Tobias Grosserfa57e9b2015-08-24 06:01:47 +0000520 Root = optimizeScheduleNode(Root);
Tobias Grosser808cd692015-07-14 09:33:13 +0000521 isl_schedule_free(Schedule);
Tobias Grosser808cd692015-07-14 09:33:13 +0000522 auto S = isl_schedule_node_get_schedule(Root);
Tobias Grosserbbb4cec2015-03-22 12:06:39 +0000523 isl_schedule_node_free(Root);
Tobias Grosser808cd692015-07-14 09:33:13 +0000524 return S;
Tobias Grosser30aa24c2011-05-14 19:02:06 +0000525}
526
Tobias Grosserfa57e9b2015-08-24 06:01:47 +0000527__isl_give isl_schedule_node *ScheduleTreeOptimizer::optimizeScheduleNode(
528 __isl_take isl_schedule_node *Node) {
529 Node = isl_schedule_node_map_descendant_bottom_up(Node, optimizeBand, NULL);
530 return Node;
531}
532
533bool ScheduleTreeOptimizer::isProfitableSchedule(
Johannes Doerfert7ceb0402015-02-11 17:25:09 +0000534 Scop &S, __isl_keep isl_union_map *NewSchedule) {
535 // To understand if the schedule has been optimized we check if the schedule
536 // has changed at all.
537 // TODO: We can improve this by tracking if any necessarily beneficial
538 // transformations have been performed. This can e.g. be tiling, loop
539 // interchange, or ...) We can track this either at the place where the
540 // transformation has been performed or, in case of automatic ILP based
541 // optimizations, by comparing (yet to be defined) performance metrics
542 // before/after the scheduling optimizer
543 // (e.g., #stride-one accesses)
544 isl_union_map *OldSchedule = S.getSchedule();
545 bool changed = !isl_union_map_is_equal(OldSchedule, NewSchedule);
546 isl_union_map_free(OldSchedule);
547 return changed;
548}
549
Tobias Grosserfa57e9b2015-08-24 06:01:47 +0000550namespace {
551class IslScheduleOptimizer : public ScopPass {
552public:
553 static char ID;
554 explicit IslScheduleOptimizer() : ScopPass(ID) { LastSchedule = nullptr; }
555
556 ~IslScheduleOptimizer() { isl_schedule_free(LastSchedule); }
557
Johannes Doerfert45be6442015-09-27 15:43:29 +0000558 /// @brief Optimize the schedule of the SCoP @p S.
Tobias Grosserfa57e9b2015-08-24 06:01:47 +0000559 bool runOnScop(Scop &S) override;
Tobias Grosserfa57e9b2015-08-24 06:01:47 +0000560
Johannes Doerfert45be6442015-09-27 15:43:29 +0000561 /// @brief Print the new schedule for the SCoP @p S.
562 void printScop(raw_ostream &OS, Scop &S) const override;
563
564 /// @brief Register all analyses and transformation required.
565 void getAnalysisUsage(AnalysisUsage &AU) const override;
Tobias Grosserfa57e9b2015-08-24 06:01:47 +0000566
Johannes Doerfert0f376302015-09-27 15:42:28 +0000567 /// @brief Release the internal memory.
568 void releaseMemory() override {
Tobias Grosserfa57e9b2015-08-24 06:01:47 +0000569 isl_schedule_free(LastSchedule);
570 LastSchedule = nullptr;
Tobias Grosserfa57e9b2015-08-24 06:01:47 +0000571 }
Johannes Doerfert45be6442015-09-27 15:43:29 +0000572
573private:
574 isl_schedule *LastSchedule;
Tobias Grosserfa57e9b2015-08-24 06:01:47 +0000575};
576}
577
578char IslScheduleOptimizer::ID = 0;
579
Tobias Grosser73600b82011-10-08 00:30:40 +0000580bool IslScheduleOptimizer::runOnScop(Scop &S) {
Johannes Doerfert6f7921f2015-02-14 12:02:24 +0000581
582 // Skip empty SCoPs but still allow code generation as it will delete the
583 // loops present but not needed.
584 if (S.getSize() == 0) {
585 S.markAsOptimized();
586 return false;
587 }
588
Hongbin Zheng2a798852016-03-03 08:15:33 +0000589 const Dependences &D =
590 getAnalysis<DependenceInfo>().getDependences(Dependences::AL_Statement);
Tobias Grosser30aa24c2011-05-14 19:02:06 +0000591
Johannes Doerfert7e6424b2015-03-05 00:43:48 +0000592 if (!D.hasValidDependences())
Tobias Grosser38c36ea2014-02-23 15:15:44 +0000593 return false;
594
Tobias Grosser28781422012-10-16 07:29:19 +0000595 isl_schedule_free(LastSchedule);
Tobias Grosser5a56cbf2014-04-16 07:33:47 +0000596 LastSchedule = nullptr;
Tobias Grosser28781422012-10-16 07:29:19 +0000597
Tobias Grosser30aa24c2011-05-14 19:02:06 +0000598 // Build input data.
Johannes Doerfert7e6424b2015-03-05 00:43:48 +0000599 int ValidityKinds =
600 Dependences::TYPE_RAW | Dependences::TYPE_WAR | Dependences::TYPE_WAW;
Tobias Grosser1deda292012-02-14 14:02:48 +0000601 int ProximityKinds;
602
603 if (OptimizeDeps == "all")
Johannes Doerfert7e6424b2015-03-05 00:43:48 +0000604 ProximityKinds =
605 Dependences::TYPE_RAW | Dependences::TYPE_WAR | Dependences::TYPE_WAW;
Tobias Grosser1deda292012-02-14 14:02:48 +0000606 else if (OptimizeDeps == "raw")
Johannes Doerfert7e6424b2015-03-05 00:43:48 +0000607 ProximityKinds = Dependences::TYPE_RAW;
Tobias Grosser1deda292012-02-14 14:02:48 +0000608 else {
609 errs() << "Do not know how to optimize for '" << OptimizeDeps << "'"
Tobias Grosser4d96c8d2013-03-23 01:05:07 +0000610 << " Falling back to optimizing all dependences.\n";
Johannes Doerfert7e6424b2015-03-05 00:43:48 +0000611 ProximityKinds =
612 Dependences::TYPE_RAW | Dependences::TYPE_WAR | Dependences::TYPE_WAW;
Tobias Grosser1deda292012-02-14 14:02:48 +0000613 }
614
Tobias Grosser5f9a7622012-02-14 14:02:40 +0000615 isl_union_set *Domain = S.getDomains();
Tobias Grosser30aa24c2011-05-14 19:02:06 +0000616
Tobias Grosser98610ee2012-02-13 23:31:39 +0000617 if (!Domain)
Tobias Grosser30aa24c2011-05-14 19:02:06 +0000618 return false;
619
Johannes Doerfert7e6424b2015-03-05 00:43:48 +0000620 isl_union_map *Validity = D.getDependences(ValidityKinds);
621 isl_union_map *Proximity = D.getDependences(ProximityKinds);
Tobias Grosser8a507022012-03-16 11:51:41 +0000622
Tobias Grossera26db472012-01-30 19:38:43 +0000623 // Simplify the dependences by removing the constraints introduced by the
624 // domains. This can speed up the scheduling time significantly, as large
625 // constant coefficients will be removed from the dependences. The
626 // introduction of some additional dependences reduces the possible
627 // transformations, but in most cases, such transformation do not seem to be
628 // interesting anyway. In some cases this option may stop the scheduler to
629 // find any schedule.
630 if (SimplifyDeps == "yes") {
Tobias Grosser00383a72012-02-14 14:02:44 +0000631 Validity = isl_union_map_gist_domain(Validity, isl_union_set_copy(Domain));
632 Validity = isl_union_map_gist_range(Validity, isl_union_set_copy(Domain));
Tobias Grosser4d96c8d2013-03-23 01:05:07 +0000633 Proximity =
634 isl_union_map_gist_domain(Proximity, isl_union_set_copy(Domain));
Tobias Grosser00383a72012-02-14 14:02:44 +0000635 Proximity = isl_union_map_gist_range(Proximity, isl_union_set_copy(Domain));
Tobias Grossera26db472012-01-30 19:38:43 +0000636 } else if (SimplifyDeps != "no") {
637 errs() << "warning: Option -polly-opt-simplify-deps should either be 'yes' "
638 "or 'no'. Falling back to default: 'yes'\n";
639 }
640
Tobias Grosser30aa24c2011-05-14 19:02:06 +0000641 DEBUG(dbgs() << "\n\nCompute schedule from: ");
Tobias Grosser01aea582014-10-22 23:16:28 +0000642 DEBUG(dbgs() << "Domain := " << stringFromIslObj(Domain) << ";\n");
643 DEBUG(dbgs() << "Proximity := " << stringFromIslObj(Proximity) << ";\n");
644 DEBUG(dbgs() << "Validity := " << stringFromIslObj(Validity) << ";\n");
Tobias Grosser30aa24c2011-05-14 19:02:06 +0000645
Michael Krusec59f22c2015-06-18 16:45:40 +0000646 unsigned IslSerializeSCCs;
Tobias Grosserb3ad85b2012-01-30 19:38:50 +0000647
648 if (FusionStrategy == "max") {
Michael Krusec59f22c2015-06-18 16:45:40 +0000649 IslSerializeSCCs = 0;
Tobias Grosserb3ad85b2012-01-30 19:38:50 +0000650 } else if (FusionStrategy == "min") {
Michael Krusec59f22c2015-06-18 16:45:40 +0000651 IslSerializeSCCs = 1;
Tobias Grosserb3ad85b2012-01-30 19:38:50 +0000652 } else {
653 errs() << "warning: Unknown fusion strategy. Falling back to maximal "
654 "fusion.\n";
Michael Krusec59f22c2015-06-18 16:45:40 +0000655 IslSerializeSCCs = 0;
Tobias Grosserb3ad85b2012-01-30 19:38:50 +0000656 }
657
Tobias Grosser95e860c2012-01-30 19:38:54 +0000658 int IslMaximizeBands;
659
Tobias Grossera4ea90b2012-01-30 22:43:56 +0000660 if (MaximizeBandDepth == "yes") {
Tobias Grosser95e860c2012-01-30 19:38:54 +0000661 IslMaximizeBands = 1;
Tobias Grossera4ea90b2012-01-30 22:43:56 +0000662 } else if (MaximizeBandDepth == "no") {
Tobias Grosser95e860c2012-01-30 19:38:54 +0000663 IslMaximizeBands = 0;
664 } else {
665 errs() << "warning: Option -polly-opt-maximize-bands should either be 'yes'"
666 " or 'no'. Falling back to default: 'yes'\n";
667 IslMaximizeBands = 1;
668 }
669
Michael Kruse315aa322016-05-02 11:35:27 +0000670 int IslOuterCoincidence;
671
672 if (OuterCoincidence == "yes") {
673 IslOuterCoincidence = 1;
674 } else if (OuterCoincidence == "no") {
675 IslOuterCoincidence = 0;
676 } else {
677 errs() << "warning: Option -polly-opt-outer-coincidence should either be "
678 "'yes' or 'no'. Falling back to default: 'no'\n";
679 IslOuterCoincidence = 0;
680 }
681
682 isl_options_set_schedule_outer_coincidence(S.getIslCtx(),
683 IslOuterCoincidence);
Michael Krusec59f22c2015-06-18 16:45:40 +0000684 isl_options_set_schedule_serialize_sccs(S.getIslCtx(), IslSerializeSCCs);
Tobias Grosser95e860c2012-01-30 19:38:54 +0000685 isl_options_set_schedule_maximize_band_depth(S.getIslCtx(), IslMaximizeBands);
Tobias Grosser992e60c2012-02-20 08:41:15 +0000686 isl_options_set_schedule_max_constant_term(S.getIslCtx(), MaxConstantTerm);
Tobias Grosser92f54802012-02-20 08:41:47 +0000687 isl_options_set_schedule_max_coefficient(S.getIslCtx(), MaxCoefficient);
Tobias Grosser4f6bcef2015-03-31 07:52:36 +0000688 isl_options_set_tile_scale_tile_loops(S.getIslCtx(), 0);
Tobias Grosser42152ff2012-01-30 19:38:47 +0000689
690 isl_options_set_on_error(S.getIslCtx(), ISL_ON_ERROR_CONTINUE);
Tobias Grossera38c9242014-01-26 19:36:28 +0000691
692 isl_schedule_constraints *ScheduleConstraints;
693 ScheduleConstraints = isl_schedule_constraints_on_domain(Domain);
694 ScheduleConstraints =
695 isl_schedule_constraints_set_proximity(ScheduleConstraints, Proximity);
696 ScheduleConstraints = isl_schedule_constraints_set_validity(
697 ScheduleConstraints, isl_union_map_copy(Validity));
698 ScheduleConstraints =
699 isl_schedule_constraints_set_coincidence(ScheduleConstraints, Validity);
Tobias Grosser00383a72012-02-14 14:02:44 +0000700 isl_schedule *Schedule;
Tobias Grossera38c9242014-01-26 19:36:28 +0000701 Schedule = isl_schedule_constraints_compute_schedule(ScheduleConstraints);
Tobias Grosser42152ff2012-01-30 19:38:47 +0000702 isl_options_set_on_error(S.getIslCtx(), ISL_ON_ERROR_ABORT);
703
704 // In cases the scheduler is not able to optimize the code, we just do not
705 // touch the schedule.
Tobias Grosser98610ee2012-02-13 23:31:39 +0000706 if (!Schedule)
Tobias Grosser42152ff2012-01-30 19:38:47 +0000707 return false;
Tobias Grosser30aa24c2011-05-14 19:02:06 +0000708
Tobias Grosser97d87452015-05-30 06:46:59 +0000709 DEBUG({
710 auto *P = isl_printer_to_str(S.getIslCtx());
711 P = isl_printer_set_yaml_style(P, ISL_YAML_STYLE_BLOCK);
712 P = isl_printer_print_schedule(P, Schedule);
713 dbgs() << "NewScheduleTree: \n" << isl_printer_get_str(P) << "\n";
714 isl_printer_free(P);
715 });
Tobias Grosser4d63b9d2012-02-20 08:41:21 +0000716
Tobias Grosserfa57e9b2015-08-24 06:01:47 +0000717 isl_schedule *NewSchedule = ScheduleTreeOptimizer::optimizeSchedule(Schedule);
Tobias Grosser808cd692015-07-14 09:33:13 +0000718 isl_union_map *NewScheduleMap = isl_schedule_get_map(NewSchedule);
Johannes Doerfert7ceb0402015-02-11 17:25:09 +0000719
Tobias Grosserfa57e9b2015-08-24 06:01:47 +0000720 if (!ScheduleTreeOptimizer::isProfitableSchedule(S, NewScheduleMap)) {
Tobias Grosser808cd692015-07-14 09:33:13 +0000721 isl_union_map_free(NewScheduleMap);
722 isl_schedule_free(NewSchedule);
Johannes Doerfert7ceb0402015-02-11 17:25:09 +0000723 return false;
724 }
725
Tobias Grosser808cd692015-07-14 09:33:13 +0000726 S.setScheduleTree(NewSchedule);
Johannes Doerfert7ceb0402015-02-11 17:25:09 +0000727 S.markAsOptimized();
Tobias Grosser30aa24c2011-05-14 19:02:06 +0000728
Tobias Grosser808cd692015-07-14 09:33:13 +0000729 isl_union_map_free(NewScheduleMap);
Tobias Grosser30aa24c2011-05-14 19:02:06 +0000730 return false;
731}
732
Johannes Doerfert3fe584d2015-03-01 18:40:25 +0000733void IslScheduleOptimizer::printScop(raw_ostream &OS, Scop &) const {
Tobias Grosser28781422012-10-16 07:29:19 +0000734 isl_printer *p;
735 char *ScheduleStr;
736
737 OS << "Calculated schedule:\n";
738
739 if (!LastSchedule) {
740 OS << "n/a\n";
741 return;
742 }
743
744 p = isl_printer_to_str(isl_schedule_get_ctx(LastSchedule));
745 p = isl_printer_print_schedule(p, LastSchedule);
746 ScheduleStr = isl_printer_get_str(p);
747 isl_printer_free(p);
748
749 OS << ScheduleStr << "\n";
Tobias Grosser30aa24c2011-05-14 19:02:06 +0000750}
751
Tobias Grosser73600b82011-10-08 00:30:40 +0000752void IslScheduleOptimizer::getAnalysisUsage(AnalysisUsage &AU) const {
Tobias Grosser30aa24c2011-05-14 19:02:06 +0000753 ScopPass::getAnalysisUsage(AU);
Johannes Doerfertf6557f92015-03-04 22:43:40 +0000754 AU.addRequired<DependenceInfo>();
Tobias Grosser30aa24c2011-05-14 19:02:06 +0000755}
756
Tobias Grosser4d96c8d2013-03-23 01:05:07 +0000757Pass *polly::createIslScheduleOptimizerPass() {
Tobias Grosser73600b82011-10-08 00:30:40 +0000758 return new IslScheduleOptimizer();
Tobias Grosser30aa24c2011-05-14 19:02:06 +0000759}
Tobias Grosser4d96c8d2013-03-23 01:05:07 +0000760
761INITIALIZE_PASS_BEGIN(IslScheduleOptimizer, "polly-opt-isl",
762 "Polly - Optimize schedule of SCoP", false, false);
Johannes Doerfertf6557f92015-03-04 22:43:40 +0000763INITIALIZE_PASS_DEPENDENCY(DependenceInfo);
Johannes Doerfert99191c72016-05-31 09:41:04 +0000764INITIALIZE_PASS_DEPENDENCY(ScopInfoRegionPass);
Tobias Grosser4d96c8d2013-03-23 01:05:07 +0000765INITIALIZE_PASS_END(IslScheduleOptimizer, "polly-opt-isl",
766 "Polly - Optimize schedule of SCoP", false, false)