Reintroduce necessary CLooG accessors to graphite. Masked by CLOOG_ORG.
[official-gcc/graphite-test-results.git] / gcc / graphite-clast-to-gimple.c
blobc518e76ece0cb5209d8330f55f47496244a1fb9c
1 /* Translation of CLAST (CLooG AST) to Gimple.
2 Copyright (C) 2009, 2010 Free Software Foundation, Inc.
3 Contributed by Sebastian Pop <sebastian.pop@amd.com>.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <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 "basic-block.h"
29 #include "diagnostic.h"
30 #include "tree-flow.h"
31 #include "toplev.h"
32 #include "tree-dump.h"
33 #include "timevar.h"
34 #include "cfgloop.h"
35 #include "tree-chrec.h"
36 #include "tree-data-ref.h"
37 #include "tree-scalar-evolution.h"
38 #include "tree-pass.h"
39 #include "domwalk.h"
40 #include "value-prof.h"
41 #include "pointer-set.h"
42 #include "gimple.h"
43 #include "langhooks.h"
44 #include "sese.h"
46 #ifdef HAVE_cloog
47 #include "cloog/cloog.h"
48 #include "ppl_c.h"
49 #include "graphite-cloog-util.h"
50 #include "graphite-ppl.h"
51 #include "graphite.h"
52 #include "graphite-poly.h"
53 #include "graphite-scop-detection.h"
54 #include "graphite-clast-to-gimple.h"
55 #include "graphite-dependences.h"
56 #include "graphite-cloog-compat.h"
58 /* This flag is set when an error occurred during the translation of
59 CLAST to Gimple. */
60 static bool gloog_error;
62 /* Verifies properties that GRAPHITE should maintain during translation. */
64 static inline void
65 graphite_verify (void)
67 #ifdef ENABLE_CHECKING
68 verify_loop_structure ();
69 verify_dominators (CDI_DOMINATORS);
70 verify_dominators (CDI_POST_DOMINATORS);
71 verify_loop_closed_ssa (true);
72 #endif
75 /* Stores the INDEX in a vector for a given clast NAME. */
77 typedef struct clast_name_index {
78 int index;
79 const char *name;
80 } *clast_name_index_p;
82 /* Returns a pointer to a new element of type clast_name_index_p built
83 from NAME and INDEX. */
85 static inline clast_name_index_p
86 new_clast_name_index (const char *name, int index)
88 clast_name_index_p res = XNEW (struct clast_name_index);
90 res->name = name;
91 res->index = index;
92 return res;
95 /* For a given clast NAME, returns -1 if it does not correspond to any
96 parameter, or otherwise, returns the index in the PARAMS or
97 SCATTERING_DIMENSIONS vector. */
99 static inline int
100 clast_name_to_index (const char *name, htab_t index_table)
102 struct clast_name_index tmp;
103 PTR *slot;
105 tmp.name = name;
106 slot = htab_find_slot (index_table, &tmp, NO_INSERT);
108 if (slot && *slot)
109 return ((struct clast_name_index *) *slot)->index;
111 return -1;
114 /* Records in INDEX_TABLE the INDEX for NAME. */
116 static inline void
117 save_clast_name_index (htab_t index_table, const char *name, int index)
119 struct clast_name_index tmp;
120 PTR *slot;
122 tmp.name = name;
123 slot = htab_find_slot (index_table, &tmp, INSERT);
125 if (slot)
127 if (*slot)
128 free (*slot);
130 *slot = new_clast_name_index (name, index);
134 /* Computes a hash function for database element ELT. */
136 static inline hashval_t
137 clast_name_index_elt_info (const void *elt)
139 return htab_hash_pointer (((const struct clast_name_index *) elt)->name);
142 /* Compares database elements E1 and E2. */
144 static inline int
145 eq_clast_name_indexes (const void *e1, const void *e2)
147 const struct clast_name_index *elt1 = (const struct clast_name_index *) e1;
148 const struct clast_name_index *elt2 = (const struct clast_name_index *) e2;
150 return (elt1->name == elt2->name);
153 /* For a given scattering dimension, return the new induction variable
154 associated to it. */
156 static inline tree
157 newivs_to_depth_to_newiv (VEC (tree, heap) *newivs, int depth)
159 return VEC_index (tree, newivs, depth);
164 /* Returns the tree variable from the name NAME that was given in
165 Cloog representation. */
167 static tree
168 clast_name_to_gcc (const char *name, sese region, VEC (tree, heap) *newivs,
169 htab_t newivs_index, htab_t params_index)
171 int index;
172 VEC (tree, heap) *params = SESE_PARAMS (region);
174 if (params && params_index)
176 index = clast_name_to_index (name, params_index);
178 if (index >= 0)
179 return VEC_index (tree, params, index);
182 gcc_assert (newivs && newivs_index);
183 index = clast_name_to_index (name, newivs_index);
184 gcc_assert (index >= 0);
186 return newivs_to_depth_to_newiv (newivs, index);
189 /* Returns the signed maximal precision type for expressions TYPE1 and TYPE2. */
191 static tree
192 max_signed_precision_type (tree type1, tree type2)
194 int p1 = TYPE_PRECISION (type1);
195 int p2 = TYPE_PRECISION (type2);
196 int precision;
197 tree type;
199 if (p1 > p2)
200 precision = TYPE_UNSIGNED (type1) ? p1 * 2 : p1;
201 else
202 precision = TYPE_UNSIGNED (type2) ? p2 * 2 : p2;
204 type = lang_hooks.types.type_for_size (precision, false);
206 if (!type)
208 gloog_error = true;
209 return integer_type_node;
211 return type;
214 /* Returns the maximal precision type for expressions TYPE1 and TYPE2. */
216 static tree
217 max_precision_type (tree type1, tree type2)
219 if (POINTER_TYPE_P (type1))
220 return type1;
222 if (POINTER_TYPE_P (type2))
223 return type2;
225 if (!TYPE_UNSIGNED (type1)
226 || !TYPE_UNSIGNED (type2))
227 return max_signed_precision_type (type1, type2);
229 return TYPE_PRECISION (type1) > TYPE_PRECISION (type2) ? type1 : type2;
232 static tree
233 clast_to_gcc_expression (tree, struct clast_expr *, sese, VEC (tree, heap) *,
234 htab_t, htab_t);
236 /* Converts a Cloog reduction expression R with reduction operation OP
237 to a GCC expression tree of type TYPE. */
239 static tree
240 clast_to_gcc_expression_red (tree type, enum tree_code op,
241 struct clast_reduction *r,
242 sese region, VEC (tree, heap) *newivs,
243 htab_t newivs_index, htab_t params_index)
245 int i;
246 tree res = clast_to_gcc_expression (type, r->elts[0], region, newivs,
247 newivs_index, params_index);
248 tree operand_type = (op == POINTER_PLUS_EXPR) ? sizetype : type;
250 for (i = 1; i < r->n; i++)
252 tree t = clast_to_gcc_expression (operand_type, r->elts[i], region,
253 newivs, newivs_index, params_index);
254 res = fold_build2 (op, type, res, t);
257 return res;
260 /* Converts a Cloog AST expression E back to a GCC expression tree of
261 type TYPE. */
263 static tree
264 clast_to_gcc_expression (tree type, struct clast_expr *e,
265 sese region, VEC (tree, heap) *newivs,
266 htab_t newivs_index, htab_t params_index)
268 switch (e->type)
270 case expr_term:
272 struct clast_term *t = (struct clast_term *) e;
274 if (t->var)
276 if (mpz_cmp_si (t->val, 1) == 0)
278 tree name = clast_name_to_gcc (t->var, region, newivs,
279 newivs_index, params_index);
281 if (POINTER_TYPE_P (TREE_TYPE (name)) != POINTER_TYPE_P (type))
282 name = fold_convert (sizetype, name);
284 name = fold_convert (type, name);
285 return name;
288 else if (mpz_cmp_si (t->val, -1) == 0)
290 tree name = clast_name_to_gcc (t->var, region, newivs,
291 newivs_index, params_index);
293 if (POINTER_TYPE_P (TREE_TYPE (name)) != POINTER_TYPE_P (type))
294 name = fold_convert (sizetype, name);
296 name = fold_convert (type, name);
298 return fold_build1 (NEGATE_EXPR, type, name);
300 else
302 tree name = clast_name_to_gcc (t->var, region, newivs,
303 newivs_index, params_index);
304 tree cst = gmp_cst_to_tree (type, t->val);
306 if (POINTER_TYPE_P (TREE_TYPE (name)) != POINTER_TYPE_P (type))
307 name = fold_convert (sizetype, name);
309 name = fold_convert (type, name);
311 if (!POINTER_TYPE_P (type))
312 return fold_build2 (MULT_EXPR, type, cst, name);
314 gloog_error = true;
315 return cst;
318 else
319 return gmp_cst_to_tree (type, t->val);
322 case expr_red:
324 struct clast_reduction *r = (struct clast_reduction *) e;
326 switch (r->type)
328 case clast_red_sum:
329 return clast_to_gcc_expression_red
330 (type, POINTER_TYPE_P (type) ? POINTER_PLUS_EXPR : PLUS_EXPR,
331 r, region, newivs, newivs_index, params_index);
333 case clast_red_min:
334 return clast_to_gcc_expression_red (type, MIN_EXPR, r, region,
335 newivs, newivs_index,
336 params_index);
338 case clast_red_max:
339 return clast_to_gcc_expression_red (type, MAX_EXPR, r, region,
340 newivs, newivs_index,
341 params_index);
343 default:
344 gcc_unreachable ();
346 break;
349 case expr_bin:
351 struct clast_binary *b = (struct clast_binary *) e;
352 struct clast_expr *lhs = (struct clast_expr *) b->LHS;
353 tree tl = clast_to_gcc_expression (type, lhs, region, newivs,
354 newivs_index, params_index);
355 tree tr = gmp_cst_to_tree (type, b->RHS);
357 switch (b->type)
359 case clast_bin_fdiv:
360 return fold_build2 (FLOOR_DIV_EXPR, type, tl, tr);
362 case clast_bin_cdiv:
363 return fold_build2 (CEIL_DIV_EXPR, type, tl, tr);
365 case clast_bin_div:
366 return fold_build2 (EXACT_DIV_EXPR, type, tl, tr);
368 case clast_bin_mod:
369 return fold_build2 (TRUNC_MOD_EXPR, type, tl, tr);
371 default:
372 gcc_unreachable ();
376 default:
377 gcc_unreachable ();
380 return NULL_TREE;
383 /* Return the precision needed to represent the value VAL. */
385 static int
386 precision_for_value (mpz_t val)
388 mpz_t x, y, two;
389 int precision;
391 mpz_init (x);
392 mpz_init (y);
393 mpz_init (two);
394 mpz_set_si (x, 2);
395 mpz_set (y, val);
396 mpz_set_si (two, 2);
397 precision = 1;
399 if (mpz_sgn (y) < 0)
400 mpz_neg (y, y);
402 while (mpz_cmp (y, x) > 0)
404 mpz_mul (x, x, two);
405 precision++;
408 mpz_clear (x);
409 mpz_clear (y);
410 mpz_clear (two);
412 return precision;
415 /* Return the precision needed to represent the values between LOW and
416 UP. */
418 static int
419 precision_for_interval (mpz_t low, mpz_t up)
421 mpz_t diff;
422 int precision;
424 gcc_assert (mpz_cmp (low, up) <= 0);
426 mpz_init (diff);
427 mpz_sub (diff, up, low);
428 precision = precision_for_value (diff);
429 mpz_clear (diff);
431 return precision;
434 /* Return a type that could represent the integer value VAL. */
436 static tree
437 gcc_type_for_interval (mpz_t low, mpz_t up)
439 bool unsigned_p = true;
440 int precision, prec_up, prec_int;
441 tree type;
442 enum machine_mode mode;
444 gcc_assert (mpz_cmp (low, up) <= 0);
446 if (mpz_sgn (low) < 0)
447 unsigned_p = false;
449 prec_up = precision_for_value (up);
450 prec_int = precision_for_interval (low, up);
451 precision = MAX (prec_up, prec_int);
453 if (precision > BITS_PER_WORD)
455 gloog_error = true;
456 return integer_type_node;
459 mode = smallest_mode_for_size (precision, MODE_INT);
460 precision = GET_MODE_PRECISION (mode);
461 type = build_nonstandard_integer_type (precision, unsigned_p);
463 if (!type)
465 gloog_error = true;
466 return integer_type_node;
469 return type;
472 /* Return a type that could represent the integer value VAL, or
473 otherwise return NULL_TREE. */
475 static tree
476 gcc_type_for_value (mpz_t val)
478 return gcc_type_for_interval (val, val);
481 /* Return the type for the clast_term T used in STMT. */
483 static tree
484 gcc_type_for_clast_term (struct clast_term *t,
485 sese region, VEC (tree, heap) *newivs,
486 htab_t newivs_index, htab_t params_index)
488 gcc_assert (t->expr.type == expr_term);
490 if (!t->var)
491 return gcc_type_for_value (t->val);
493 return TREE_TYPE (clast_name_to_gcc (t->var, region, newivs,
494 newivs_index, params_index));
497 static tree
498 gcc_type_for_clast_expr (struct clast_expr *, sese,
499 VEC (tree, heap) *, htab_t, htab_t);
501 /* Return the type for the clast_reduction R used in STMT. */
503 static tree
504 gcc_type_for_clast_red (struct clast_reduction *r, sese region,
505 VEC (tree, heap) *newivs,
506 htab_t newivs_index, htab_t params_index)
508 int i;
509 tree type = NULL_TREE;
511 if (r->n == 1)
512 return gcc_type_for_clast_expr (r->elts[0], region, newivs,
513 newivs_index, params_index);
515 switch (r->type)
517 case clast_red_sum:
518 case clast_red_min:
519 case clast_red_max:
520 type = gcc_type_for_clast_expr (r->elts[0], region, newivs,
521 newivs_index, params_index);
522 for (i = 1; i < r->n; i++)
523 type = max_precision_type (type, gcc_type_for_clast_expr
524 (r->elts[i], region, newivs,
525 newivs_index, params_index));
527 return type;
529 default:
530 break;
533 gcc_unreachable ();
534 return NULL_TREE;
537 /* Return the type for the clast_binary B used in STMT. */
539 static tree
540 gcc_type_for_clast_bin (struct clast_binary *b,
541 sese region, VEC (tree, heap) *newivs,
542 htab_t newivs_index, htab_t params_index)
544 tree l = gcc_type_for_clast_expr ((struct clast_expr *) b->LHS, region,
545 newivs, newivs_index, params_index);
546 tree r = gcc_type_for_value (b->RHS);
547 return max_signed_precision_type (l, r);
550 /* Returns the type for the CLAST expression E when used in statement
551 STMT. */
553 static tree
554 gcc_type_for_clast_expr (struct clast_expr *e,
555 sese region, VEC (tree, heap) *newivs,
556 htab_t newivs_index, htab_t params_index)
558 switch (e->type)
560 case expr_term:
561 return gcc_type_for_clast_term ((struct clast_term *) e, region,
562 newivs, newivs_index, params_index);
564 case expr_red:
565 return gcc_type_for_clast_red ((struct clast_reduction *) e, region,
566 newivs, newivs_index, params_index);
568 case expr_bin:
569 return gcc_type_for_clast_bin ((struct clast_binary *) e, region,
570 newivs, newivs_index, params_index);
572 default:
573 gcc_unreachable ();
576 return NULL_TREE;
579 /* Returns the type for the equation CLEQ. */
581 static tree
582 gcc_type_for_clast_eq (struct clast_equation *cleq,
583 sese region, VEC (tree, heap) *newivs,
584 htab_t newivs_index, htab_t params_index)
586 tree l = gcc_type_for_clast_expr (cleq->LHS, region, newivs,
587 newivs_index, params_index);
588 tree r = gcc_type_for_clast_expr (cleq->RHS, region, newivs,
589 newivs_index, params_index);
590 return max_precision_type (l, r);
593 /* Translates a clast equation CLEQ to a tree. */
595 static tree
596 graphite_translate_clast_equation (sese region,
597 struct clast_equation *cleq,
598 VEC (tree, heap) *newivs,
599 htab_t newivs_index, htab_t params_index)
601 enum tree_code comp;
602 tree type = gcc_type_for_clast_eq (cleq, region, newivs, newivs_index,
603 params_index);
604 tree lhs = clast_to_gcc_expression (type, cleq->LHS, region, newivs,
605 newivs_index, params_index);
606 tree rhs = clast_to_gcc_expression (type, cleq->RHS, region, newivs,
607 newivs_index, params_index);
609 if (cleq->sign == 0)
610 comp = EQ_EXPR;
612 else if (cleq->sign > 0)
613 comp = GE_EXPR;
615 else
616 comp = LE_EXPR;
618 return fold_build2 (comp, boolean_type_node, lhs, rhs);
621 /* Creates the test for the condition in STMT. */
623 static tree
624 graphite_create_guard_cond_expr (sese region, struct clast_guard *stmt,
625 VEC (tree, heap) *newivs,
626 htab_t newivs_index, htab_t params_index)
628 tree cond = NULL;
629 int i;
631 for (i = 0; i < stmt->n; i++)
633 tree eq = graphite_translate_clast_equation (region, &stmt->eq[i],
634 newivs, newivs_index,
635 params_index);
637 if (cond)
638 cond = fold_build2 (TRUTH_AND_EXPR, TREE_TYPE (eq), cond, eq);
639 else
640 cond = eq;
643 return cond;
646 /* Creates a new if region corresponding to Cloog's guard. */
648 static edge
649 graphite_create_new_guard (sese region, edge entry_edge,
650 struct clast_guard *stmt,
651 VEC (tree, heap) *newivs,
652 htab_t newivs_index, htab_t params_index)
654 tree cond_expr = graphite_create_guard_cond_expr (region, stmt, newivs,
655 newivs_index, params_index);
656 edge exit_edge = create_empty_if_region_on_edge (entry_edge, cond_expr);
657 return exit_edge;
660 /* Compute the lower bound LOW and upper bound UP for the induction
661 variable at LEVEL for the statement PBB, based on the transformed
662 scattering of PBB: T|I|G|Cst, with T the scattering transform, I
663 the iteration domain, and G the context parameters. */
665 static void
666 compute_bounds_for_level (poly_bb_p pbb, int level, mpz_t low, mpz_t up)
668 ppl_Pointset_Powerset_C_Polyhedron_t ps;
669 ppl_Linear_Expression_t le;
671 combine_context_id_scat (&ps, pbb, false);
673 /* Prepare the linear expression corresponding to the level that we
674 want to maximize/minimize. */
676 ppl_dimension_type dim = pbb_nb_scattering_transform (pbb)
677 + pbb_dim_iter_domain (pbb) + pbb_nb_params (pbb);
679 ppl_new_Linear_Expression_with_dimension (&le, dim);
680 ppl_set_coef (le, 2 * level + 1, 1);
683 ppl_max_for_le_pointset (ps, le, up);
684 ppl_min_for_le_pointset (ps, le, low);
687 /* Compute the type for the induction variable at LEVEL for the
688 statement PBB, based on the transformed schedule of PBB. */
690 static tree
691 compute_type_for_level (poly_bb_p pbb, int level)
693 mpz_t low, up;
694 tree type;
696 mpz_init (low);
697 mpz_init (up);
699 compute_bounds_for_level (pbb, level, low, up);
700 type = gcc_type_for_interval (low, up);
702 mpz_clear (low);
703 mpz_clear (up);
704 return type;
707 /* Walks a CLAST and returns the first statement in the body of a
708 loop. */
710 static struct clast_user_stmt *
711 clast_get_body_of_loop (struct clast_stmt *stmt)
713 if (!stmt
714 || CLAST_STMT_IS_A (stmt, stmt_user))
715 return (struct clast_user_stmt *) stmt;
717 if (CLAST_STMT_IS_A (stmt, stmt_for))
718 return clast_get_body_of_loop (((struct clast_for *) stmt)->body);
720 if (CLAST_STMT_IS_A (stmt, stmt_guard))
721 return clast_get_body_of_loop (((struct clast_guard *) stmt)->then);
723 if (CLAST_STMT_IS_A (stmt, stmt_block))
724 return clast_get_body_of_loop (((struct clast_block *) stmt)->body);
726 gcc_unreachable ();
729 /* Returns the type for the induction variable for the loop translated
730 from STMT_FOR. */
732 static tree
733 gcc_type_for_iv_of_clast_loop (struct clast_for *stmt_for, int level,
734 tree lb_type, tree ub_type)
736 struct clast_stmt *stmt = (struct clast_stmt *) stmt_for;
737 struct clast_user_stmt *body = clast_get_body_of_loop (stmt);
738 CloogStatement *cs = body->statement;
739 poly_bb_p pbb = (poly_bb_p) cloog_statement_usr (cs);
741 return max_signed_precision_type (lb_type, max_precision_type
742 (ub_type, compute_type_for_level
743 (pbb, level - 1)));
746 /* Creates a new LOOP corresponding to Cloog's STMT. Inserts an
747 induction variable for the new LOOP. New LOOP is attached to CFG
748 starting at ENTRY_EDGE. LOOP is inserted into the loop tree and
749 becomes the child loop of the OUTER_LOOP. NEWIVS_INDEX binds
750 CLooG's scattering name to the induction variable created for the
751 loop of STMT. The new induction variable is inserted in the NEWIVS
752 vector. */
754 static struct loop *
755 graphite_create_new_loop (sese region, edge entry_edge,
756 struct clast_for *stmt,
757 loop_p outer, VEC (tree, heap) **newivs,
758 htab_t newivs_index, htab_t params_index, int level)
760 tree lb_type = gcc_type_for_clast_expr (stmt->LB, region, *newivs,
761 newivs_index, params_index);
762 tree ub_type = gcc_type_for_clast_expr (stmt->UB, region, *newivs,
763 newivs_index, params_index);
764 tree type = gcc_type_for_iv_of_clast_loop (stmt, level, lb_type, ub_type);
765 tree lb = clast_to_gcc_expression (type, stmt->LB, region, *newivs,
766 newivs_index, params_index);
767 tree ub = clast_to_gcc_expression (type, stmt->UB, region, *newivs,
768 newivs_index, params_index);
769 tree stride = gmp_cst_to_tree (type, stmt->stride);
770 tree ivvar = create_tmp_var (type, "graphite_IV");
771 tree iv, iv_after_increment;
772 loop_p loop = create_empty_loop_on_edge
773 (entry_edge, lb, stride, ub, ivvar, &iv, &iv_after_increment,
774 outer ? outer : entry_edge->src->loop_father);
776 add_referenced_var (ivvar);
778 save_clast_name_index (newivs_index, stmt->iterator,
779 VEC_length (tree, *newivs));
780 VEC_safe_push (tree, heap, *newivs, iv);
781 return loop;
784 /* Inserts in iv_map a tuple (OLD_LOOP->num, NEW_NAME) for the
785 induction variables of the loops around GBB in SESE. */
787 static void
788 build_iv_mapping (VEC (tree, heap) *iv_map, sese region,
789 VEC (tree, heap) *newivs, htab_t newivs_index,
790 struct clast_user_stmt *user_stmt,
791 htab_t params_index)
793 struct clast_stmt *t;
794 int depth = 0;
795 CloogStatement *cs = user_stmt->statement;
796 poly_bb_p pbb = (poly_bb_p) cloog_statement_usr (cs);
797 gimple_bb_p gbb = PBB_BLACK_BOX (pbb);
799 for (t = user_stmt->substitutions; t; t = t->next, depth++)
801 struct clast_expr *expr = (struct clast_expr *)
802 ((struct clast_assignment *)t)->RHS;
803 tree type = gcc_type_for_clast_expr (expr, region, newivs,
804 newivs_index, params_index);
805 tree new_name = clast_to_gcc_expression (type, expr, region, newivs,
806 newivs_index, params_index);
807 loop_p old_loop = gbb_loop_at_index (gbb, region, depth);
809 VEC_replace (tree, iv_map, old_loop->num, new_name);
813 /* Construct bb_pbb_def with BB and PBB. */
815 static bb_pbb_def *
816 new_bb_pbb_def (basic_block bb, poly_bb_p pbb)
818 bb_pbb_def *bb_pbb_p;
820 bb_pbb_p = XNEW (bb_pbb_def);
821 bb_pbb_p->bb = bb;
822 bb_pbb_p->pbb = pbb;
824 return bb_pbb_p;
827 /* Mark BB with it's relevant PBB via hashing table BB_PBB_MAPPING. */
829 static void
830 mark_bb_with_pbb (poly_bb_p pbb, basic_block bb, htab_t bb_pbb_mapping)
832 bb_pbb_def tmp;
833 PTR *x;
835 tmp.bb = bb;
836 x = htab_find_slot (bb_pbb_mapping, &tmp, INSERT);
838 if (x && !*x)
839 *x = new_bb_pbb_def (bb, pbb);
842 /* Find BB's related poly_bb_p in hash table BB_PBB_MAPPING. */
844 static poly_bb_p
845 find_pbb_via_hash (htab_t bb_pbb_mapping, basic_block bb)
847 bb_pbb_def tmp;
848 PTR *slot;
850 tmp.bb = bb;
851 slot = htab_find_slot (bb_pbb_mapping, &tmp, NO_INSERT);
853 if (slot && *slot)
854 return ((bb_pbb_def *) *slot)->pbb;
856 return NULL;
859 /* Check data dependency in LOOP at scattering level LEVEL.
860 BB_PBB_MAPPING is a basic_block and it's related poly_bb_p
861 mapping. */
863 static bool
864 dependency_in_loop_p (loop_p loop, htab_t bb_pbb_mapping, int level)
866 unsigned i,j;
867 basic_block *bbs = get_loop_body_in_dom_order (loop);
869 for (i = 0; i < loop->num_nodes; i++)
871 poly_bb_p pbb1 = find_pbb_via_hash (bb_pbb_mapping, bbs[i]);
873 if (pbb1 == NULL)
874 continue;
876 for (j = 0; j < loop->num_nodes; j++)
878 poly_bb_p pbb2 = find_pbb_via_hash (bb_pbb_mapping, bbs[j]);
880 if (pbb2 == NULL)
881 continue;
883 if (dependency_between_pbbs_p (pbb1, pbb2, level))
885 free (bbs);
886 return true;
891 free (bbs);
893 return false;
896 /* Translates a clast user statement STMT to gimple.
898 - REGION is the sese region we used to generate the scop.
899 - NEXT_E is the edge where new generated code should be attached.
900 - CONTEXT_LOOP is the loop in which the generated code will be placed
901 - BB_PBB_MAPPING is is a basic_block and it's related poly_bb_p mapping.
902 - PARAMS_INDEX connects the cloog parameters with the gimple parameters in
903 the sese region. */
904 static edge
905 translate_clast_user (sese region, struct clast_user_stmt *stmt, edge next_e,
906 VEC (tree, heap) **newivs,
907 htab_t newivs_index, htab_t bb_pbb_mapping,
908 htab_t params_index)
910 int i, nb_loops;
911 basic_block new_bb;
912 poly_bb_p pbb = (poly_bb_p) cloog_statement_usr (stmt->statement);
913 gimple_bb_p gbb = PBB_BLACK_BOX (pbb);
914 VEC (tree, heap) *iv_map;
916 if (GBB_BB (gbb) == ENTRY_BLOCK_PTR)
917 return next_e;
919 nb_loops = number_of_loops ();
920 iv_map = VEC_alloc (tree, heap, nb_loops);
921 for (i = 0; i < nb_loops; i++)
922 VEC_quick_push (tree, iv_map, NULL_TREE);
924 build_iv_mapping (iv_map, region, *newivs, newivs_index, stmt, params_index);
925 next_e = copy_bb_and_scalar_dependences (GBB_BB (gbb), region,
926 next_e, iv_map);
927 VEC_free (tree, heap, iv_map);
929 new_bb = next_e->src;
930 mark_bb_with_pbb (pbb, new_bb, bb_pbb_mapping);
931 update_ssa (TODO_update_ssa);
933 return next_e;
936 /* Creates a new if region protecting the loop to be executed, if the execution
937 count is zero (lb > ub). */
938 static edge
939 graphite_create_new_loop_guard (sese region, edge entry_edge,
940 struct clast_for *stmt,
941 VEC (tree, heap) *newivs,
942 htab_t newivs_index, htab_t params_index)
944 tree cond_expr;
945 edge exit_edge;
946 tree lb_type = gcc_type_for_clast_expr (stmt->LB, region, newivs,
947 newivs_index, params_index);
948 tree ub_type = gcc_type_for_clast_expr (stmt->UB, region, newivs,
949 newivs_index, params_index);
950 tree type = max_precision_type (lb_type, ub_type);
951 tree lb = clast_to_gcc_expression (type, stmt->LB, region, newivs,
952 newivs_index, params_index);
953 tree ub = clast_to_gcc_expression (type, stmt->UB, region, newivs,
954 newivs_index, params_index);
955 tree ub_one;
957 /* Adding +1 and using LT_EXPR helps with loop latches that have a
958 loop iteration count of "PARAMETER - 1". For PARAMETER == 0 this becomes
959 2^{32|64}, and the condition lb <= ub is true, even if we do not want this.
960 However lb < ub + 1 is false, as expected. */
961 if (POINTER_TYPE_P (type))
962 ub_one = fold_build2 (POINTER_PLUS_EXPR, type, ub, size_one_node);
963 else
964 ub_one = fold_build2 (PLUS_EXPR, type, ub,
965 fold_convert (type, integer_one_node));
967 /* When ub + 1 wraps around, use lb <= ub. */
968 if (integer_zerop (ub_one))
969 cond_expr = fold_build2 (LE_EXPR, boolean_type_node, lb, ub);
970 else
971 cond_expr = fold_build2 (LT_EXPR, boolean_type_node, lb, ub_one);
973 exit_edge = create_empty_if_region_on_edge (entry_edge, cond_expr);
975 return exit_edge;
978 static edge
979 translate_clast (sese, loop_p, struct clast_stmt *, edge,
980 VEC (tree, heap) **, htab_t, htab_t, int, htab_t);
982 /* Create the loop for a clast for statement.
984 - REGION is the sese region we used to generate the scop.
985 - NEXT_E is the edge where new generated code should be attached.
986 - BB_PBB_MAPPING is is a basic_block and it's related poly_bb_p mapping.
987 - PARAMS_INDEX connects the cloog parameters with the gimple parameters in
988 the sese region. */
989 static edge
990 translate_clast_for_loop (sese region, loop_p context_loop,
991 struct clast_for *stmt, edge next_e,
992 VEC (tree, heap) **newivs,
993 htab_t newivs_index, htab_t bb_pbb_mapping,
994 int level, htab_t params_index)
996 struct loop *loop = graphite_create_new_loop (region, next_e, stmt,
997 context_loop, newivs,
998 newivs_index, params_index,
999 level);
1000 edge last_e = single_exit (loop);
1001 edge to_body = single_succ_edge (loop->header);
1002 basic_block after = to_body->dest;
1004 /* Create a basic block for loop close phi nodes. */
1005 last_e = single_succ_edge (split_edge (last_e));
1007 /* Translate the body of the loop. */
1008 next_e = translate_clast (region, loop, stmt->body, to_body,
1009 newivs, newivs_index, bb_pbb_mapping, level + 1,
1010 params_index);
1011 redirect_edge_succ_nodup (next_e, after);
1012 set_immediate_dominator (CDI_DOMINATORS, next_e->dest, next_e->src);
1014 if (flag_loop_parallelize_all
1015 && !dependency_in_loop_p (loop, bb_pbb_mapping,
1016 get_scattering_level (level)))
1017 loop->can_be_parallel = true;
1019 return last_e;
1022 /* Translates a clast for statement STMT to gimple. First a guard is created
1023 protecting the loop, if it is executed zero times. In this guard we create
1024 the real loop structure.
1026 - REGION is the sese region we used to generate the scop.
1027 - NEXT_E is the edge where new generated code should be attached.
1028 - BB_PBB_MAPPING is is a basic_block and it's related poly_bb_p mapping.
1029 - PARAMS_INDEX connects the cloog parameters with the gimple parameters in
1030 the sese region. */
1031 static edge
1032 translate_clast_for (sese region, loop_p context_loop, struct clast_for *stmt,
1033 edge next_e, VEC (tree, heap) **newivs,
1034 htab_t newivs_index, htab_t bb_pbb_mapping, int level,
1035 htab_t params_index)
1037 edge last_e = graphite_create_new_loop_guard (region, next_e, stmt, *newivs,
1038 newivs_index, params_index);
1039 edge true_e = get_true_edge_from_guard_bb (next_e->dest);
1041 translate_clast_for_loop (region, context_loop, stmt, true_e, newivs,
1042 newivs_index, bb_pbb_mapping, level,
1043 params_index);
1044 return last_e;
1047 /* Translates a clast guard statement STMT to gimple.
1049 - REGION is the sese region we used to generate the scop.
1050 - NEXT_E is the edge where new generated code should be attached.
1051 - CONTEXT_LOOP is the loop in which the generated code will be placed
1052 - BB_PBB_MAPPING is is a basic_block and it's related poly_bb_p mapping.
1053 - PARAMS_INDEX connects the cloog parameters with the gimple parameters in
1054 the sese region. */
1055 static edge
1056 translate_clast_guard (sese region, loop_p context_loop,
1057 struct clast_guard *stmt, edge next_e,
1058 VEC (tree, heap) **newivs,
1059 htab_t newivs_index, htab_t bb_pbb_mapping, int level,
1060 htab_t params_index)
1062 edge last_e = graphite_create_new_guard (region, next_e, stmt, *newivs,
1063 newivs_index, params_index);
1064 edge true_e = get_true_edge_from_guard_bb (next_e->dest);
1066 translate_clast (region, context_loop, stmt->then, true_e,
1067 newivs, newivs_index, bb_pbb_mapping,
1068 level, params_index);
1069 return last_e;
1072 /* Translates a CLAST statement STMT to GCC representation in the
1073 context of a SESE.
1075 - NEXT_E is the edge where new generated code should be attached.
1076 - CONTEXT_LOOP is the loop in which the generated code will be placed
1077 - BB_PBB_MAPPING is is a basic_block and it's related poly_bb_p mapping. */
1078 static edge
1079 translate_clast (sese region, loop_p context_loop, struct clast_stmt *stmt,
1080 edge next_e, VEC (tree, heap) **newivs,
1081 htab_t newivs_index, htab_t bb_pbb_mapping, int level,
1082 htab_t params_index)
1084 if (!stmt)
1085 return next_e;
1087 if (CLAST_STMT_IS_A (stmt, stmt_root))
1088 ; /* Do nothing. */
1090 else if (CLAST_STMT_IS_A (stmt, stmt_user))
1091 next_e = translate_clast_user (region, (struct clast_user_stmt *) stmt,
1092 next_e, newivs, newivs_index,
1093 bb_pbb_mapping, params_index);
1095 else if (CLAST_STMT_IS_A (stmt, stmt_for))
1096 next_e = translate_clast_for (region, context_loop,
1097 (struct clast_for *) stmt, next_e,
1098 newivs, newivs_index,
1099 bb_pbb_mapping, level, params_index);
1101 else if (CLAST_STMT_IS_A (stmt, stmt_guard))
1102 next_e = translate_clast_guard (region, context_loop,
1103 (struct clast_guard *) stmt, next_e,
1104 newivs, newivs_index,
1105 bb_pbb_mapping, level, params_index);
1107 else if (CLAST_STMT_IS_A (stmt, stmt_block))
1108 next_e = translate_clast (region, context_loop,
1109 ((struct clast_block *) stmt)->body,
1110 next_e, newivs, newivs_index,
1111 bb_pbb_mapping, level, params_index);
1112 else
1113 gcc_unreachable();
1115 recompute_all_dominators ();
1116 graphite_verify ();
1118 return translate_clast (region, context_loop, stmt->next, next_e,
1119 newivs, newivs_index,
1120 bb_pbb_mapping, level, params_index);
1123 /* Free the SCATTERING domain list. */
1125 static void
1126 free_scattering (CloogDomainList *scattering)
1128 while (scattering)
1130 CloogDomain *dom = cloog_domain (scattering);
1131 CloogDomainList *next = cloog_next_domain (scattering);
1133 cloog_domain_free (dom);
1134 free (scattering);
1135 scattering = next;
1139 /* Initialize Cloog's parameter names from the names used in GIMPLE.
1140 Initialize Cloog's iterator names, using 'graphite_iterator_%d'
1141 from 0 to scop_nb_loops (scop). */
1143 static void
1144 initialize_cloog_names (scop_p scop, CloogProgram *prog)
1146 sese region = SCOP_REGION (scop);
1147 int i;
1148 int nb_iterators = scop_max_loop_depth (scop);
1149 int nb_scattering = cloog_program_nb_scattdims (prog);
1150 int nb_parameters = VEC_length (tree, SESE_PARAMS (region));
1151 char **iterators = XNEWVEC (char *, nb_iterators * 2);
1152 char **scattering = XNEWVEC (char *, nb_scattering);
1153 char **parameters= XNEWVEC (char *, nb_parameters);
1155 cloog_program_set_names (prog, cloog_names_malloc ());
1157 for (i = 0; i < nb_parameters; i++)
1159 tree param = VEC_index (tree, SESE_PARAMS(region), i);
1160 const char *name = get_name (param);
1161 int len;
1163 if (!name)
1164 name = "T";
1166 len = strlen (name);
1167 len += 17;
1168 parameters[i] = XNEWVEC (char, len + 1);
1169 snprintf (parameters[i], len, "%s_%d", name, SSA_NAME_VERSION (param));
1172 cloog_names_set_nb_parameters (cloog_program_names (prog), nb_parameters);
1173 cloog_names_set_parameters (cloog_program_names (prog), parameters);
1175 for (i = 0; i < nb_iterators; i++)
1177 int len = 4 + 16;
1178 iterators[i] = XNEWVEC (char, len);
1179 snprintf (iterators[i], len, "git_%d", i);
1182 cloog_names_set_nb_iterators (cloog_program_names (prog),
1183 nb_iterators);
1184 cloog_names_set_iterators (cloog_program_names (prog),
1185 iterators);
1187 for (i = 0; i < nb_scattering; i++)
1189 int len = 5 + 16;
1190 scattering[i] = XNEWVEC (char, len);
1191 snprintf (scattering[i], len, "scat_%d", i);
1194 cloog_names_set_nb_scattering (cloog_program_names (prog),
1195 nb_scattering);
1196 cloog_names_set_scattering (cloog_program_names (prog),
1197 scattering);
1200 /* Build cloog program for SCoP. */
1202 static void
1203 build_cloog_prog (scop_p scop, CloogProgram *prog)
1205 int i;
1206 int max_nb_loops = scop_max_loop_depth (scop);
1207 poly_bb_p pbb;
1208 CloogLoop *loop_list = NULL;
1209 CloogBlockList *block_list = NULL;
1210 CloogDomainList *scattering = NULL;
1211 int nbs = 2 * max_nb_loops + 1;
1212 int *scaldims;
1214 cloog_program_set_context
1215 (prog, new_Cloog_Domain_from_ppl_Pointset_Powerset (SCOP_CONTEXT (scop)));
1216 nbs = unify_scattering_dimensions (scop);
1217 scaldims = (int *) xmalloc (nbs * (sizeof (int)));
1218 cloog_program_set_nb_scattdims (prog, nbs);
1219 initialize_cloog_names (scop, prog);
1221 for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++)
1223 CloogStatement *stmt;
1224 CloogBlock *block;
1226 /* Dead code elimination: when the domain of a PBB is empty,
1227 don't generate code for the PBB. */
1228 if (ppl_Pointset_Powerset_C_Polyhedron_is_empty (PBB_DOMAIN (pbb)))
1229 continue;
1231 /* Build the new statement and its block. */
1232 stmt = cloog_statement_alloc (pbb_index (pbb));
1233 block = cloog_block_alloc (stmt, 0, NULL, pbb_dim_iter_domain (pbb));
1234 cloog_statement_set_usr (stmt, pbb);
1236 /* Build loop list. */
1238 CloogLoop *new_loop_list = cloog_loop_malloc ();
1239 cloog_loop_set_next (new_loop_list, loop_list);
1240 cloog_loop_set_domain
1241 (new_loop_list,
1242 new_Cloog_Domain_from_ppl_Pointset_Powerset (PBB_DOMAIN (pbb)));
1243 cloog_loop_set_block (new_loop_list, block);
1244 loop_list = new_loop_list;
1247 /* Build block list. */
1249 CloogBlockList *new_block_list = cloog_block_list_malloc ();
1251 cloog_block_list_set_next (new_block_list, block_list);
1252 cloog_block_list_set_block (new_block_list, block);
1253 block_list = new_block_list;
1256 /* Build scattering list. */
1258 /* XXX: Replace with cloog_domain_list_alloc(), when available. */
1259 CloogDomainList *new_scattering
1260 = (CloogDomainList *) xmalloc (sizeof (CloogDomainList));
1261 ppl_Polyhedron_t scat;
1262 CloogDomain *dom;
1264 scat = PBB_TRANSFORMED_SCATTERING (pbb);
1265 dom = new_Cloog_Domain_from_ppl_Polyhedron (scat);
1267 cloog_set_next_domain (new_scattering, scattering);
1268 cloog_set_domain (new_scattering, dom);
1269 scattering = new_scattering;
1273 cloog_program_set_loop (prog, loop_list);
1274 cloog_program_set_blocklist (prog, block_list);
1276 for (i = 0; i < nbs; i++)
1277 scaldims[i] = 0 ;
1279 cloog_program_set_scaldims (prog, scaldims);
1281 /* Extract scalar dimensions to simplify the code generation problem. */
1282 cloog_program_extract_scalars (prog, scattering);
1284 /* Apply scattering. */
1285 cloog_program_scatter (prog, scattering);
1286 free_scattering (scattering);
1288 /* Iterators corresponding to scalar dimensions have to be extracted. */
1289 cloog_names_scalarize (cloog_program_names (prog), nbs,
1290 cloog_program_scaldims (prog));
1292 /* Free blocklist. */
1294 CloogBlockList *next = cloog_program_blocklist (prog);
1296 while (next)
1298 CloogBlockList *toDelete = next;
1299 next = cloog_block_list_next (next);
1300 cloog_block_list_set_next (toDelete, NULL);
1301 cloog_block_list_set_block (toDelete, NULL);
1302 cloog_block_list_free (toDelete);
1304 cloog_program_set_blocklist (prog, NULL);
1308 /* Return the options that will be used in GLOOG. */
1310 static CloogOptions *
1311 set_cloog_options (void)
1313 CloogOptions *options = cloog_options_malloc ();
1315 /* Change cloog output language to C. If we do use FORTRAN instead, cloog
1316 will stop e.g. with "ERROR: unbounded loops not allowed in FORTRAN.", if
1317 we pass an incomplete program to cloog. */
1318 options->language = LANGUAGE_C;
1320 /* Enable complex equality spreading: removes dummy statements
1321 (assignments) in the generated code which repeats the
1322 substitution equations for statements. This is useless for
1323 GLooG. */
1324 options->esp = 1;
1326 /* Enable C pretty-printing mode: normalizes the substitution
1327 equations for statements. */
1328 options->cpp = 1;
1330 /* Allow cloog to build strides with a stride width different to one.
1331 This example has stride = 4:
1333 for (i = 0; i < 20; i += 4)
1334 A */
1335 options->strides = 1;
1337 /* Disable optimizations and make cloog generate source code closer to the
1338 input. This is useful for debugging, but later we want the optimized
1339 code.
1341 XXX: We can not disable optimizations, as loop blocking is not working
1342 without them. */
1343 if (!flag_graphite_cloog_opts)
1345 options->f = -1;
1346 options->l = INT_MAX;
1349 return options;
1352 /* Prints STMT to STDERR. */
1354 void
1355 print_clast_stmt (FILE *file, struct clast_stmt *stmt)
1357 CloogOptions *options = set_cloog_options ();
1359 pprint (file, stmt, 0, options);
1360 cloog_options_free (options);
1363 /* Prints STMT to STDERR. */
1365 DEBUG_FUNCTION void
1366 debug_clast_stmt (struct clast_stmt *stmt)
1368 print_clast_stmt (stderr, stmt);
1371 /* Translate SCOP to a CLooG program and clast. These two
1372 representations should be freed together: a clast cannot be used
1373 without a program. */
1375 cloog_prog_clast
1376 scop_to_clast (scop_p scop)
1378 CloogOptions *options = set_cloog_options ();
1379 cloog_prog_clast pc;
1381 /* Connect new cloog prog generation to graphite. */
1382 pc.prog = cloog_program_malloc ();
1383 build_cloog_prog (scop, pc.prog);
1384 pc.prog = cloog_program_generate (pc.prog, options);
1385 pc.stmt = cloog_clast_create (pc.prog, options);
1387 cloog_options_free (options);
1388 return pc;
1391 /* Prints to FILE the code generated by CLooG for SCOP. */
1393 void
1394 print_generated_program (FILE *file, scop_p scop)
1396 CloogOptions *options = set_cloog_options ();
1397 cloog_prog_clast pc = scop_to_clast (scop);
1399 fprintf (file, " (prog: \n");
1400 cloog_program_print (file, pc.prog);
1401 fprintf (file, " )\n");
1403 fprintf (file, " (clast: \n");
1404 pprint (file, pc.stmt, 0, options);
1405 fprintf (file, " )\n");
1407 cloog_options_free (options);
1408 cloog_clast_free (pc.stmt);
1409 cloog_program_free (pc.prog);
1412 /* Prints to STDERR the code generated by CLooG for SCOP. */
1414 DEBUG_FUNCTION void
1415 debug_generated_program (scop_p scop)
1417 print_generated_program (stderr, scop);
1420 /* Add CLooG names to parameter index. The index is used to translate
1421 back from CLooG names to GCC trees. */
1423 static void
1424 create_params_index (htab_t index_table, CloogProgram *prog) {
1425 CloogNames* names = cloog_program_names (prog);
1426 int nb_parameters = cloog_names_nb_parameters (names);
1427 char **parameters = cloog_names_parameters (names);
1428 int i;
1430 for (i = 0; i < nb_parameters; i++)
1431 save_clast_name_index (index_table, parameters[i], i);
1434 /* GIMPLE Loop Generator: generates loops from STMT in GIMPLE form for
1435 the given SCOP. Return true if code generation succeeded.
1436 BB_PBB_MAPPING is a basic_block and it's related poly_bb_p mapping.
1439 bool
1440 gloog (scop_p scop, htab_t bb_pbb_mapping)
1442 VEC (tree, heap) *newivs = VEC_alloc (tree, heap, 10);
1443 loop_p context_loop;
1444 sese region = SCOP_REGION (scop);
1445 ifsese if_region = NULL;
1446 htab_t newivs_index, params_index;
1447 cloog_prog_clast pc;
1449 timevar_push (TV_GRAPHITE_CODE_GEN);
1450 gloog_error = false;
1452 pc = scop_to_clast (scop);
1454 if (dump_file && (dump_flags & TDF_DETAILS))
1456 fprintf (dump_file, "\nCLAST generated by CLooG: \n");
1457 print_clast_stmt (dump_file, pc.stmt);
1458 fprintf (dump_file, "\n");
1461 recompute_all_dominators ();
1462 graphite_verify ();
1464 if_region = move_sese_in_condition (region);
1465 sese_insert_phis_for_liveouts (region,
1466 if_region->region->exit->src,
1467 if_region->false_region->exit,
1468 if_region->true_region->exit);
1469 recompute_all_dominators ();
1470 graphite_verify ();
1472 context_loop = SESE_ENTRY (region)->src->loop_father;
1473 newivs_index = htab_create (10, clast_name_index_elt_info,
1474 eq_clast_name_indexes, free);
1475 params_index = htab_create (10, clast_name_index_elt_info,
1476 eq_clast_name_indexes, free);
1478 create_params_index (params_index, pc.prog);
1480 translate_clast (region, context_loop, pc.stmt,
1481 if_region->true_region->entry,
1482 &newivs, newivs_index,
1483 bb_pbb_mapping, 1, params_index);
1484 graphite_verify ();
1485 scev_reset_htab ();
1486 recompute_all_dominators ();
1487 graphite_verify ();
1489 if (gloog_error)
1490 set_ifsese_condition (if_region, integer_zero_node);
1492 free (if_region->true_region);
1493 free (if_region->region);
1494 free (if_region);
1496 htab_delete (newivs_index);
1497 htab_delete (params_index);
1498 VEC_free (tree, heap, newivs);
1499 cloog_clast_free (pc.stmt);
1500 cloog_program_free (pc.prog);
1501 timevar_pop (TV_GRAPHITE_CODE_GEN);
1503 if (dump_file && (dump_flags & TDF_DETAILS))
1505 loop_p loop;
1506 loop_iterator li;
1507 int num_no_dependency = 0;
1509 FOR_EACH_LOOP (li, loop, 0)
1510 if (loop->can_be_parallel)
1511 num_no_dependency++;
1513 fprintf (dump_file, "\n%d loops carried no dependency.\n",
1514 num_no_dependency);
1517 return !gloog_error;
1520 #endif