OSDN Git Service

2009-08-28 Sebastian Pop <sebastian.pop@amd.com>
[pf3gnuchains/gcc-fork.git] / gcc / graphite-poly.c
1 /* Graphite polyhedral representation.
2    Copyright (C) 2009 Free Software Foundation, Inc.
3    Contributed by Sebastian Pop <sebastian.pop@amd.com> and
4    Tobias Grosser <grosser@fim.uni-passau.de>.
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
12
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3.  If not see
20 <http://www.gnu.org/licenses/>.  */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "tm.h"
25 #include "ggc.h"
26 #include "tree.h"
27 #include "rtl.h"
28 #include "output.h"
29 #include "basic-block.h"
30 #include "diagnostic.h"
31 #include "tree-flow.h"
32 #include "toplev.h"
33 #include "tree-dump.h"
34 #include "timevar.h"
35 #include "cfgloop.h"
36 #include "tree-chrec.h"
37 #include "tree-data-ref.h"
38 #include "tree-scalar-evolution.h"
39 #include "tree-pass.h"
40 #include "domwalk.h"
41 #include "value-prof.h"
42 #include "pointer-set.h"
43 #include "gimple.h"
44 #include "params.h"
45
46 #ifdef HAVE_cloog
47 #include "cloog/cloog.h"
48 #include "ppl_c.h"
49 #include "sese.h"
50 #include "graphite-ppl.h"
51 #include "graphite.h"
52 #include "graphite-poly.h"
53 #include "graphite-dependences.h"
54
55 /* Return the maximal loop depth in SCOP.  */
56
57 int
58 scop_max_loop_depth (scop_p scop)
59 {
60   int i;
61   poly_bb_p pbb;
62   int max_nb_loops = 0;
63
64   for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++)
65     {
66       int nb_loops = pbb_dim_iter_domain (pbb);
67       if (max_nb_loops < nb_loops)
68         max_nb_loops = nb_loops;
69     }
70
71   return max_nb_loops;
72 }
73
74 /* Extend the scattering matrix of PBB to MAX_SCATTERING scattering
75    dimensions.  */
76
77 static void
78 extend_scattering (poly_bb_p pbb, int max_scattering)
79 {
80   ppl_dimension_type nb_old_dims, nb_new_dims;
81   int nb_added_dims, i;
82   ppl_Coefficient_t coef;
83   Value one;
84
85   nb_added_dims = max_scattering - pbb_nb_scattering_transform (pbb);
86   value_init (one);
87   value_set_si (one, 1);
88   ppl_new_Coefficient (&coef);
89   ppl_assign_Coefficient_from_mpz_t (coef, one);
90
91   gcc_assert (nb_added_dims >= 0);
92
93   nb_old_dims = pbb_nb_scattering_transform (pbb) + pbb_dim_iter_domain (pbb)
94     + scop_nb_params (PBB_SCOP (pbb));
95   nb_new_dims = nb_old_dims + nb_added_dims;
96
97   ppl_insert_dimensions (PBB_TRANSFORMED_SCATTERING (pbb),
98                          pbb_nb_scattering_transform (pbb), nb_added_dims);
99   PBB_NB_SCATTERING_TRANSFORM (pbb) += nb_added_dims;
100
101   /* Add identity matrix for the added dimensions.  */
102   for (i = max_scattering - nb_added_dims; i < max_scattering; i++)
103     {
104       ppl_Constraint_t cstr;
105       ppl_Linear_Expression_t expr;
106
107       ppl_new_Linear_Expression_with_dimension (&expr, nb_new_dims);
108       ppl_Linear_Expression_add_to_coefficient (expr, i, coef);
109       ppl_new_Constraint (&cstr, expr, PPL_CONSTRAINT_TYPE_EQUAL);
110       ppl_Polyhedron_add_constraint (PBB_TRANSFORMED_SCATTERING (pbb), cstr);
111       ppl_delete_Constraint (cstr);
112       ppl_delete_Linear_Expression (expr);
113     }
114
115   ppl_delete_Coefficient (coef);
116   value_clear (one);
117 }
118
119 /* All scattering matrices in SCOP will have the same number of scattering
120    dimensions.  */
121
122 int
123 unify_scattering_dimensions (scop_p scop)
124 {
125   int i;
126   poly_bb_p pbb;
127   graphite_dim_t max_scattering = 0;
128
129   for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++)
130     max_scattering = MAX (pbb_nb_scattering_transform (pbb), max_scattering);
131
132   for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++)
133     extend_scattering (pbb, max_scattering);
134
135   return max_scattering;
136 }
137
138 /* Prints to FILE the scattering function of PBB.  */
139
140 void
141 print_scattering_function (FILE *file, poly_bb_p pbb)
142 {
143   graphite_dim_t i;
144
145   if (!PBB_TRANSFORMED (pbb))
146     return;
147
148   fprintf (file, "scattering bb_%d (\n", GBB_BB (PBB_BLACK_BOX (pbb))->index);
149   fprintf (file, "#  eq");
150
151   for (i = 0; i < pbb_nb_scattering_transform (pbb); i++)
152     fprintf (file, "     s%d", (int) i);
153
154   for (i = 0; i < pbb_nb_local_vars (pbb); i++)
155     fprintf (file, "    lv%d", (int) i);
156
157   for (i = 0; i < pbb_dim_iter_domain (pbb); i++)
158     fprintf (file, "     i%d", (int) i);
159
160   for (i = 0; i < pbb_nb_params (pbb); i++)
161     fprintf (file, "     p%d", (int) i);
162
163   fprintf (file, "    cst\n");
164
165   ppl_print_polyhedron_matrix (file, PBB_TRANSFORMED_SCATTERING (pbb));
166
167   fprintf (file, ")\n");
168 }
169
170 /* Prints to FILE the iteration domain of PBB.  */
171
172 void
173 print_iteration_domain (FILE *file, poly_bb_p pbb)
174 {
175   print_pbb_domain (file, pbb);
176 }
177
178 /* Prints to FILE the scattering functions of every PBB of SCOP.  */
179
180 void
181 print_scattering_functions (FILE *file, scop_p scop)
182 {
183   int i;
184   poly_bb_p pbb;
185
186   for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++)
187     print_scattering_function (file, pbb);
188 }
189
190 /* Prints to FILE the iteration domains of every PBB of SCOP.  */
191
192 void
193 print_iteration_domains (FILE *file, scop_p scop)
194 {
195   int i;
196   poly_bb_p pbb;
197
198   for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++)
199     print_iteration_domain (file, pbb);
200 }
201
202 /* Prints to STDERR the scattering function of PBB.  */
203
204 void
205 debug_scattering_function (poly_bb_p pbb)
206 {
207   print_scattering_function (stderr, pbb);
208 }
209
210 /* Prints to STDERR the iteration domain of PBB.  */
211
212 void
213 debug_iteration_domain (poly_bb_p pbb)
214 {
215   print_iteration_domain (stderr, pbb);
216 }
217
218 /* Prints to STDERR the scattering functions of every PBB of SCOP.  */
219
220 void
221 debug_scattering_functions (scop_p scop)
222 {
223   print_scattering_functions (stderr, scop);
224 }
225
226 /* Prints to STDERR the iteration domains of every PBB of SCOP.  */
227
228 void
229 debug_iteration_domains (scop_p scop)
230 {
231   print_iteration_domains (stderr, scop);
232 }
233
234 /* Apply graphite transformations to all the basic blocks of SCOP.  */
235
236 bool
237 apply_poly_transforms (scop_p scop)
238 {
239   bool transform_done = false;
240
241   /* Generate code even if we did not apply any real transformation.
242      This also allows to check the performance for the identity
243      transformation: GIMPLE -> GRAPHITE -> GIMPLE
244      Keep in mind that CLooG optimizes in control, so the loop structure
245      may change, even if we only use -fgraphite-identity.  */
246   if (flag_graphite_identity)
247     transform_done = true;
248
249   if (flag_loop_parallelize_all)
250     transform_done = true;
251
252   if (flag_loop_block)
253     gcc_unreachable (); /* Not yet supported.  */
254
255   if (flag_loop_strip_mine)
256     transform_done |= scop_do_strip_mine (scop);
257
258   if (flag_loop_interchange)
259     transform_done |= scop_do_interchange (scop);
260
261   return transform_done;
262 }
263
264 /* Create a new polyhedral data reference and add it to PBB.  It is
265    defined by its ACCESSES, its TYPE, and the number of subscripts
266    NB_SUBSCRIPTS.  */
267
268 void
269 new_poly_dr (poly_bb_p pbb,
270              ppl_Pointset_Powerset_C_Polyhedron_t accesses,
271              enum poly_dr_type type, void *cdr, int nb_subscripts)
272 {
273   poly_dr_p pdr = XNEW (struct poly_dr);
274   static int id = 0;
275
276   PDR_ID (pdr) = id++;
277   PDR_PBB (pdr) = pbb;
278   PDR_ACCESSES (pdr) = accesses;
279   PDR_TYPE (pdr) = type;
280   PDR_CDR (pdr) = cdr;
281   PDR_NB_SUBSCRIPTS (pdr) = nb_subscripts;
282   VEC_safe_push (poly_dr_p, heap, PBB_DRS (pbb), pdr);
283 }
284
285 /* Free polyhedral data reference PDR.  */
286
287 void
288 free_poly_dr (poly_dr_p pdr)
289 {
290   ppl_delete_Pointset_Powerset_C_Polyhedron (PDR_ACCESSES (pdr));
291   XDELETE (pdr);
292 }
293
294 /* Create a new polyhedral black box.  */
295
296 void
297 new_poly_bb (scop_p scop, void *black_box)
298 {
299   poly_bb_p pbb = XNEW (struct poly_bb);
300
301   PBB_DOMAIN (pbb) = NULL;
302   PBB_SCOP (pbb) = scop;
303   pbb_set_black_box (pbb, black_box);
304   PBB_TRANSFORMED (pbb) = NULL;
305   PBB_SAVED (pbb) = NULL;
306   PBB_ORIGINAL (pbb) = NULL;
307   PBB_DRS (pbb) = VEC_alloc (poly_dr_p, heap, 3);
308   VEC_safe_push (poly_bb_p, heap, SCOP_BBS (scop), pbb);
309 }
310
311 /* Free polyhedral black box.  */
312
313 void
314 free_poly_bb (poly_bb_p pbb)
315 {
316   int i;
317   poly_dr_p pdr;
318
319   ppl_delete_Pointset_Powerset_C_Polyhedron (PBB_DOMAIN (pbb));
320
321   if (PBB_TRANSFORMED (pbb))
322     poly_scattering_free (PBB_TRANSFORMED (pbb));
323
324   if (PBB_SAVED (pbb))
325     poly_scattering_free (PBB_SAVED (pbb));
326
327   if (PBB_ORIGINAL (pbb))
328     poly_scattering_free (PBB_ORIGINAL (pbb));
329
330   if (PBB_DRS (pbb))
331     for (i = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb), i, pdr); i++)
332       free_poly_dr (pdr);
333
334   VEC_free (poly_dr_p, heap, PBB_DRS (pbb));
335   XDELETE (pbb);
336 }
337
338 static void
339 print_pdr_access_layout (FILE *file, poly_dr_p pdr)
340 {
341   graphite_dim_t i;
342
343   fprintf (file, "#  eq");
344
345   for (i = 0; i < pdr_dim_iter_domain (pdr); i++)
346     fprintf (file, "     i%d", (int) i);
347
348   for (i = 0; i < pdr_nb_params (pdr); i++)
349     fprintf (file, "     p%d", (int) i);
350
351   fprintf (file, "  alias");
352
353   for (i = 0; i < PDR_NB_SUBSCRIPTS (pdr); i++)
354     fprintf (file, "   sub%d", (int) i);
355
356   fprintf (file, "    cst\n");
357 }
358
359 /* Prints to FILE the polyhedral data reference PDR.  */
360
361 void
362 print_pdr (FILE *file, poly_dr_p pdr)
363 {
364   fprintf (file, "pdr_%d (", PDR_ID (pdr));
365
366   switch (PDR_TYPE (pdr))
367     {
368     case PDR_READ:
369       fprintf (file, "read \n");
370       break;
371
372     case PDR_WRITE:
373       fprintf (file, "write \n");
374       break;
375
376     case PDR_MAY_WRITE:
377       fprintf (file, "may_write \n");
378       break;
379
380     default:
381       gcc_unreachable ();
382     }
383
384   dump_data_reference (file, (data_reference_p) PDR_CDR (pdr));
385
386   fprintf (file, "data accesses (\n");
387   print_pdr_access_layout (file, pdr);
388   ppl_print_powerset_matrix (file, PDR_ACCESSES (pdr));
389   fprintf (file, ")\n");
390
391   fprintf (file, ")\n");
392 }
393
394 /* Prints to STDERR the polyhedral data reference PDR.  */
395
396 void
397 debug_pdr (poly_dr_p pdr)
398 {
399   print_pdr (stderr, pdr);
400 }
401
402 /* Creates a new SCOP containing REGION.  */
403
404 scop_p
405 new_scop (void *region)
406 {
407   scop_p scop = XNEW (struct scop);
408
409   SCOP_DEP_GRAPH (scop) = NULL;
410   SCOP_CONTEXT (scop) = NULL;
411   scop_set_region (scop, region);
412   SCOP_BBS (scop) = VEC_alloc (poly_bb_p, heap, 3);
413   SCOP_ORIGINAL_PDDRS (scop) = htab_create (10, hash_poly_ddr_p,
414                                             eq_poly_ddr_p, free_poly_ddr);
415   return scop;
416 }
417
418 /* Deletes SCOP.  */
419
420 void
421 free_scop (scop_p scop)
422 {
423   int i;
424   poly_bb_p pbb;
425
426   for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++)
427     free_poly_bb (pbb);
428
429   VEC_free (poly_bb_p, heap, SCOP_BBS (scop));
430
431   if (SCOP_CONTEXT (scop))
432     ppl_delete_Pointset_Powerset_C_Polyhedron (SCOP_CONTEXT (scop));
433
434   htab_delete (SCOP_ORIGINAL_PDDRS (scop));
435   XDELETE (scop);
436 }
437
438 /* Print to FILE the domain of PBB.  */
439
440 void
441 print_pbb_domain (FILE *file, poly_bb_p pbb)
442 {
443   graphite_dim_t i;
444   gimple_bb_p gbb = PBB_BLACK_BOX (pbb);
445
446   if (!PBB_DOMAIN (pbb))
447     return;
448
449   fprintf (file, "domains bb_%d (\n", GBB_BB (gbb)->index);
450   fprintf (file, "#  eq");
451
452   for (i = 0; i < pbb_dim_iter_domain (pbb); i++)
453     fprintf (file, "     i%d", (int) i);
454
455   for (i = 0; i < pbb_nb_params (pbb); i++)
456     fprintf (file, "     p%d", (int) i);
457
458   fprintf (file, "    cst\n");
459
460   if (PBB_DOMAIN (pbb))
461     ppl_print_powerset_matrix (file, PBB_DOMAIN (pbb));
462
463   fprintf (file, ")\n");
464 }
465
466 /* Dump the cases of a graphite basic block GBB on FILE.  */
467
468 static void
469 dump_gbb_cases (FILE *file, gimple_bb_p gbb)
470 {
471   int i;
472   gimple stmt;
473   VEC (gimple, heap) *cases;
474
475   if (!gbb)
476     return;
477
478   cases = GBB_CONDITION_CASES (gbb);
479   if (VEC_empty (gimple, cases))
480     return;
481
482   fprintf (file, "cases bb_%d (", GBB_BB (gbb)->index);
483
484   for (i = 0; VEC_iterate (gimple, cases, i, stmt); i++)
485     print_gimple_stmt (file, stmt, 0, 0);
486
487   fprintf (file, ")\n");
488 }
489
490 /* Dump conditions of a graphite basic block GBB on FILE.  */
491
492 static void
493 dump_gbb_conditions (FILE *file, gimple_bb_p gbb)
494 {
495   int i;
496   gimple stmt;
497   VEC (gimple, heap) *conditions;
498
499   if (!gbb)
500     return;
501
502   conditions = GBB_CONDITIONS (gbb);
503   if (VEC_empty (gimple, conditions))
504     return;
505
506   fprintf (file, "conditions bb_%d (", GBB_BB (gbb)->index);
507
508   for (i = 0; VEC_iterate (gimple, conditions, i, stmt); i++)
509     print_gimple_stmt (file, stmt, 0, 0);
510
511   fprintf (file, ")\n");
512 }
513
514 /* Print to FILE all the data references of PBB.  */
515
516 void
517 print_pdrs (FILE *file, poly_bb_p pbb)
518 {
519   int i;
520   poly_dr_p pdr;
521
522   for (i = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb), i, pdr); i++)
523     print_pdr (file, pdr);
524 }
525
526 /* Print to STDERR all the data references of PBB.  */
527
528 void
529 debug_pdrs (poly_bb_p pbb)
530 {
531   print_pdrs (stderr, pbb);
532 }
533
534 /* Print to FILE the domain and scattering function of PBB.  */
535
536 void
537 print_pbb (FILE *file, poly_bb_p pbb)
538 {
539   fprintf (file, "pbb_%d (\n", GBB_BB (PBB_BLACK_BOX (pbb))->index);
540   dump_gbb_conditions (file, PBB_BLACK_BOX (pbb));
541   dump_gbb_cases (file, PBB_BLACK_BOX (pbb));
542   print_pdrs (file, pbb);
543   print_pbb_domain (file, pbb);
544   print_scattering_function (file, pbb);
545   fprintf (file, ")\n");
546 }
547
548 /* Print to FILE the parameters of SCOP.  */
549
550 void
551 print_scop_params (FILE *file, scop_p scop)
552 {
553   int i;
554   tree t;
555
556   fprintf (file, "parameters (\n");
557   for (i = 0; VEC_iterate (tree, SESE_PARAMS (SCOP_REGION (scop)), i, t); i++)
558     {
559       fprintf (file, "p_%d -> ", i);
560       print_generic_expr (file, t, 0);
561       fprintf (file, "\n");
562     }
563   fprintf (file, ")\n");
564 }
565
566 /* Print to FILE the context of SCoP.  */
567 void
568 print_scop_context (FILE *file, scop_p scop)
569 {
570   graphite_dim_t i;
571
572   fprintf (file, "context (\n");
573   fprintf (file, "#  eq");
574
575   for (i = 0; i < scop_nb_params (scop); i++)
576     fprintf (file, "     p%d", (int) i);
577
578   fprintf (file, "    cst\n");
579
580   if (SCOP_CONTEXT (scop))
581     ppl_print_powerset_matrix (file, SCOP_CONTEXT (scop));
582
583   fprintf (file, ")\n");
584 }
585
586 /* Print to FILE the SCOP.  */
587
588 void
589 print_scop (FILE *file, scop_p scop)
590 {
591   int i;
592   poly_bb_p pbb;
593
594   fprintf (file, "scop (\n");
595   print_scop_params (file, scop);
596   print_scop_context (file, scop);
597
598   for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++)
599     print_pbb (file, pbb);
600
601   fprintf (file, ")\n");
602 }
603
604 /* Print to STDERR the domain of PBB.  */
605
606 void
607 debug_pbb_domain (poly_bb_p pbb)
608 {
609   print_pbb_domain (stderr, pbb);
610 }
611
612 /* Print to FILE the domain and scattering function of PBB.  */
613
614 void
615 debug_pbb (poly_bb_p pbb)
616 {
617   print_pbb (stderr, pbb);
618 }
619
620 /* Print to STDERR the context of SCOP.  */
621
622 void
623 debug_scop_context (scop_p scop)
624 {
625   print_scop_context (stderr, scop);
626 }
627
628 /* Print to STDERR the SCOP.  */
629
630 void
631 debug_scop (scop_p scop)
632 {
633   print_scop (stderr, scop);
634 }
635
636 /* Print to STDERR the parameters of SCOP.  */
637
638 void
639 debug_scop_params (scop_p scop)
640 {
641   print_scop_params (stderr, scop);
642 }
643
644
645 /* The dimension in the transformed scattering polyhedron of PBB
646    containing the scattering iterator for the loop at depth LOOP_DEPTH.  */
647
648 ppl_dimension_type
649 psct_scattering_dim_for_loop_depth (poly_bb_p pbb, graphite_dim_t loop_depth)
650 {
651   ppl_const_Constraint_System_t pcs;
652   ppl_Constraint_System_const_iterator_t cit, cend;
653   ppl_const_Constraint_t cstr;
654   ppl_Polyhedron_t ph = PBB_TRANSFORMED_SCATTERING (pbb);
655   ppl_dimension_type iter = psct_iterator_dim (pbb, loop_depth);
656   ppl_Linear_Expression_t expr;
657   ppl_Coefficient_t coef;
658   Value val;
659   graphite_dim_t i;
660
661   value_init (val);
662   ppl_new_Coefficient (&coef);
663   ppl_Polyhedron_get_constraints (ph, &pcs);
664   ppl_new_Constraint_System_const_iterator (&cit);
665   ppl_new_Constraint_System_const_iterator (&cend);
666
667   for (ppl_Constraint_System_begin (pcs, cit),
668          ppl_Constraint_System_end (pcs, cend);
669        !ppl_Constraint_System_const_iterator_equal_test (cit, cend);
670        ppl_Constraint_System_const_iterator_increment (cit))
671     {
672       ppl_Constraint_System_const_iterator_dereference (cit, &cstr);
673       ppl_new_Linear_Expression_from_Constraint (&expr, cstr);
674       ppl_Linear_Expression_coefficient (expr, iter, coef);
675       ppl_Coefficient_to_mpz_t (coef, val);
676
677       if (value_zero_p (val))
678         {
679           ppl_delete_Linear_Expression (expr);
680           continue;
681         }
682
683       for (i = 0; i < pbb_nb_scattering_transform (pbb); i++)
684         {
685           ppl_dimension_type scatter = psct_scattering_dim (pbb, i);
686
687           ppl_Linear_Expression_coefficient (expr, scatter, coef);
688           ppl_Coefficient_to_mpz_t (coef, val);
689
690           if (value_notzero_p (val))
691             {
692               value_clear (val);
693               ppl_delete_Linear_Expression (expr);
694               ppl_delete_Coefficient (coef);
695               ppl_delete_Constraint_System_const_iterator (cit);
696               ppl_delete_Constraint_System_const_iterator (cend);
697
698               return scatter;
699             }
700         }
701     }
702
703   gcc_unreachable ();
704 }
705
706 /* Returns the number of iterations NITER of the loop around PBB at
707    depth LOOP_DEPTH.  */
708
709 void
710 pbb_number_of_iterations (poly_bb_p pbb,
711                           graphite_dim_t loop_depth,
712                           Value niter)
713 {
714   ppl_Linear_Expression_t le;
715   ppl_dimension_type dim;
716
717   ppl_Pointset_Powerset_C_Polyhedron_space_dimension (PBB_DOMAIN (pbb), &dim);
718   ppl_new_Linear_Expression_with_dimension (&le, dim);
719   ppl_set_coef (le, pbb_iterator_dim (pbb, loop_depth), 1);
720   value_set_si (niter, -1);
721   ppl_max_for_le_pointset (PBB_DOMAIN (pbb), le, niter);
722   ppl_delete_Linear_Expression (le);
723 }
724
725 /* Returns the number of iterations NITER of the loop around PBB at
726    time(scattering) dimension TIME_DEPTH.  */
727
728 void
729 pbb_number_of_iterations_at_time (poly_bb_p pbb,
730                                   graphite_dim_t time_depth,
731                                   Value niter)
732 {
733   ppl_Pointset_Powerset_C_Polyhedron_t ext_domain, sctr;
734   ppl_Linear_Expression_t le;
735   ppl_dimension_type dim;
736
737   value_set_si (niter, -1);
738
739   /* Takes together domain and scattering polyhedrons, and composes
740      them into the bigger polyhedron that has the following format:
741      t0..t_{n-1} | l0..l_{nlcl-1} | i0..i_{niter-1} | g0..g_{nparm-1}.
742      t0..t_{n-1} are time dimensions (scattering dimensions)
743      l0..l_{nclc-1} are local variables in scatterin function
744      i0..i_{niter-1} are original iteration variables
745      g0..g_{nparam-1} are global parameters.  */
746
747   ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron
748     (&ext_domain, PBB_DOMAIN (pbb));
749   ppl_insert_dimensions_pointset (ext_domain, 0,
750                                   pbb_nb_scattering_transform (pbb)
751                                   + pbb_nb_local_vars (pbb));
752   ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron (&sctr,
753       PBB_TRANSFORMED_SCATTERING (pbb));
754   ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (sctr, ext_domain);
755
756   ppl_Pointset_Powerset_C_Polyhedron_space_dimension (sctr, &dim);
757   ppl_new_Linear_Expression_with_dimension (&le, dim);
758   ppl_set_coef (le, time_depth, 1);
759   ppl_max_for_le_pointset (sctr, le, niter);
760
761   ppl_delete_Linear_Expression (le);
762   ppl_delete_Pointset_Powerset_C_Polyhedron (sctr);
763   ppl_delete_Pointset_Powerset_C_Polyhedron (ext_domain);
764 }
765
766 #endif
767