PR go/67101
[official-gcc.git] / gcc / graphite-scop-detection.c
blobfb7247e2e77481260f51f5a490075fe6f872a2c2
1 /* Detection of Static Control Parts (SCoP) for Graphite.
2 Copyright (C) 2009-2015 Free Software Foundation, Inc.
3 Contributed by Sebastian Pop <sebastian.pop@amd.com> and
4 Tobias Grosser <grosser@fim.uni-passau.de>.
6 This file is part of GCC.
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.
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.
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/>. */
22 #include "config.h"
24 #ifdef HAVE_isl
25 /* Workaround for GMP 5.1.3 bug, see PR56019. */
26 #include <stddef.h>
28 #include <isl/constraint.h>
29 #include <isl/set.h>
30 #include <isl/map.h>
31 #include <isl/union_map.h>
33 #include "system.h"
34 #include "coretypes.h"
35 #include "backend.h"
36 #include "cfghooks.h"
37 #include "tree.h"
38 #include "gimple.h"
39 #include "ssa.h"
40 #include "fold-const.h"
41 #include "gimple-iterator.h"
42 #include "tree-ssa-loop-manip.h"
43 #include "tree-ssa-loop-niter.h"
44 #include "tree-ssa-loop.h"
45 #include "tree-into-ssa.h"
46 #include "tree-ssa.h"
47 #include "cfgloop.h"
48 #include "tree-data-ref.h"
49 #include "tree-scalar-evolution.h"
50 #include "tree-pass.h"
51 #include "graphite-poly.h"
52 #include "tree-ssa-propagate.h"
53 #include "graphite-scop-detection.h"
54 #include "gimple-pretty-print.h"
56 /* Forward declarations. */
57 static void make_close_phi_nodes_unique (basic_block);
59 /* The type of the analyzed basic block. */
61 typedef enum gbb_type {
62 GBB_UNKNOWN,
63 GBB_LOOP_SING_EXIT_HEADER,
64 GBB_LOOP_MULT_EXIT_HEADER,
65 GBB_LOOP_EXIT,
66 GBB_COND_HEADER,
67 GBB_SIMPLE,
68 GBB_LAST
69 } gbb_type;
71 /* Detect the type of BB. Loop headers are only marked, if they are
72 new. This means their loop_father is different to LAST_LOOP.
73 Otherwise they are treated like any other bb and their type can be
74 any other type. */
76 static gbb_type
77 get_bb_type (basic_block bb, struct loop *last_loop)
79 vec<basic_block> dom;
80 int nb_dom;
81 struct loop *loop = bb->loop_father;
83 /* Check, if we entry into a new loop. */
84 if (loop != last_loop)
86 if (single_exit (loop) != NULL)
87 return GBB_LOOP_SING_EXIT_HEADER;
88 else if (loop->num != 0)
89 return GBB_LOOP_MULT_EXIT_HEADER;
90 else
91 return GBB_COND_HEADER;
94 dom = get_dominated_by (CDI_DOMINATORS, bb);
95 nb_dom = dom.length ();
96 dom.release ();
98 if (nb_dom == 0)
99 return GBB_LAST;
101 if (nb_dom == 1 && single_succ_p (bb))
102 return GBB_SIMPLE;
104 return GBB_COND_HEADER;
107 /* A SCoP detection region, defined using bbs as borders.
109 All control flow touching this region, comes in passing basic_block
110 ENTRY and leaves passing basic_block EXIT. By using bbs instead of
111 edges for the borders we are able to represent also regions that do
112 not have a single entry or exit edge.
114 But as they have a single entry basic_block and a single exit
115 basic_block, we are able to generate for every sd_region a single
116 entry and exit edge.
120 3 <- entry
123 / \ This region contains: {3, 4, 5, 6, 7, 8}
128 9 <- exit */
131 typedef struct sd_region_p
133 /* The entry bb dominates all bbs in the sd_region. It is part of
134 the region. */
135 basic_block entry;
137 /* The exit bb postdominates all bbs in the sd_region, but is not
138 part of the region. */
139 basic_block exit;
140 } sd_region;
144 /* Moves the scops from SOURCE to TARGET and clean up SOURCE. */
146 static void
147 move_sd_regions (vec<sd_region> *source, vec<sd_region> *target)
149 sd_region *s;
150 int i;
152 FOR_EACH_VEC_ELT (*source, i, s)
153 target->safe_push (*s);
155 source->release ();
158 /* Something like "n * m" is not allowed. */
160 static bool
161 graphite_can_represent_init (tree e)
163 switch (TREE_CODE (e))
165 case POLYNOMIAL_CHREC:
166 return graphite_can_represent_init (CHREC_LEFT (e))
167 && graphite_can_represent_init (CHREC_RIGHT (e));
169 case MULT_EXPR:
170 if (chrec_contains_symbols (TREE_OPERAND (e, 0)))
171 return graphite_can_represent_init (TREE_OPERAND (e, 0))
172 && tree_fits_shwi_p (TREE_OPERAND (e, 1));
173 else
174 return graphite_can_represent_init (TREE_OPERAND (e, 1))
175 && tree_fits_shwi_p (TREE_OPERAND (e, 0));
177 case PLUS_EXPR:
178 case POINTER_PLUS_EXPR:
179 case MINUS_EXPR:
180 return graphite_can_represent_init (TREE_OPERAND (e, 0))
181 && graphite_can_represent_init (TREE_OPERAND (e, 1));
183 case NEGATE_EXPR:
184 case BIT_NOT_EXPR:
185 CASE_CONVERT:
186 case NON_LVALUE_EXPR:
187 return graphite_can_represent_init (TREE_OPERAND (e, 0));
189 default:
190 break;
193 return true;
196 /* Return true when SCEV can be represented in the polyhedral model.
198 An expression can be represented, if it can be expressed as an
199 affine expression. For loops (i, j) and parameters (m, n) all
200 affine expressions are of the form:
202 x1 * i + x2 * j + x3 * m + x4 * n + x5 * 1 where x1..x5 element of Z
204 1 i + 20 j + (-2) m + 25
206 Something like "i * n" or "n * m" is not allowed. */
208 static bool
209 graphite_can_represent_scev (tree scev)
211 if (chrec_contains_undetermined (scev))
212 return false;
214 /* We disable the handling of pointer types, because it’s currently not
215 supported by Graphite with the ISL AST generator. SSA_NAME nodes are
216 the only nodes, which are disabled in case they are pointers to object
217 types, but this can be changed. */
219 if (POINTER_TYPE_P (TREE_TYPE (scev)) && TREE_CODE (scev) == SSA_NAME)
220 return false;
222 switch (TREE_CODE (scev))
224 case NEGATE_EXPR:
225 case BIT_NOT_EXPR:
226 CASE_CONVERT:
227 case NON_LVALUE_EXPR:
228 return graphite_can_represent_scev (TREE_OPERAND (scev, 0));
230 case PLUS_EXPR:
231 case POINTER_PLUS_EXPR:
232 case MINUS_EXPR:
233 return graphite_can_represent_scev (TREE_OPERAND (scev, 0))
234 && graphite_can_represent_scev (TREE_OPERAND (scev, 1));
236 case MULT_EXPR:
237 return !CONVERT_EXPR_CODE_P (TREE_CODE (TREE_OPERAND (scev, 0)))
238 && !CONVERT_EXPR_CODE_P (TREE_CODE (TREE_OPERAND (scev, 1)))
239 && !(chrec_contains_symbols (TREE_OPERAND (scev, 0))
240 && chrec_contains_symbols (TREE_OPERAND (scev, 1)))
241 && graphite_can_represent_init (scev)
242 && graphite_can_represent_scev (TREE_OPERAND (scev, 0))
243 && graphite_can_represent_scev (TREE_OPERAND (scev, 1));
245 case POLYNOMIAL_CHREC:
246 /* Check for constant strides. With a non constant stride of
247 'n' we would have a value of 'iv * n'. Also check that the
248 initial value can represented: for example 'n * m' cannot be
249 represented. */
250 if (!evolution_function_right_is_integer_cst (scev)
251 || !graphite_can_represent_init (scev))
252 return false;
253 return graphite_can_represent_scev (CHREC_LEFT (scev));
255 default:
256 break;
259 /* Only affine functions can be represented. */
260 if (tree_contains_chrecs (scev, NULL)
261 || !scev_is_linear_expression (scev))
262 return false;
264 return true;
268 /* Return true when EXPR can be represented in the polyhedral model.
270 This means an expression can be represented, if it is linear with
271 respect to the loops and the strides are non parametric.
272 LOOP is the place where the expr will be evaluated. SCOP_ENTRY defines the
273 entry of the region we analyse. */
275 static bool
276 graphite_can_represent_expr (basic_block scop_entry, loop_p loop,
277 tree expr)
279 tree scev = analyze_scalar_evolution (loop, expr);
281 scev = instantiate_scev (scop_entry, loop, scev);
283 return graphite_can_represent_scev (scev);
286 /* Return true if the data references of STMT can be represented by
287 Graphite. */
289 static bool
290 stmt_has_simple_data_refs_p (loop_p outermost_loop ATTRIBUTE_UNUSED,
291 gimple stmt)
293 data_reference_p dr;
294 int j;
295 bool res = true;
296 vec<data_reference_p> drs = vNULL;
297 loop_p outer;
299 for (outer = loop_containing_stmt (stmt); outer; outer = loop_outer (outer))
301 graphite_find_data_references_in_stmt (outer,
302 loop_containing_stmt (stmt),
303 stmt, &drs);
305 FOR_EACH_VEC_ELT (drs, j, dr)
307 int nb_subscripts = DR_NUM_DIMENSIONS (dr);
308 tree ref = DR_REF (dr);
310 for (int i = nb_subscripts - 1; i >= 0; i--)
312 if (!graphite_can_represent_scev (DR_ACCESS_FN (dr, i))
313 || (TREE_CODE (ref) != ARRAY_REF
314 && TREE_CODE (ref) != MEM_REF
315 && TREE_CODE (ref) != COMPONENT_REF))
317 free_data_refs (drs);
318 return false;
321 ref = TREE_OPERAND (ref, 0);
325 free_data_refs (drs);
326 drs.create (0);
329 free_data_refs (drs);
330 return res;
333 /* Return true only when STMT is simple enough for being handled by
334 Graphite. This depends on SCOP_ENTRY, as the parameters are
335 initialized relatively to this basic block, the linear functions
336 are initialized to OUTERMOST_LOOP and BB is the place where we try
337 to evaluate the STMT. */
339 static bool
340 stmt_simple_for_scop_p (basic_block scop_entry, loop_p outermost_loop,
341 gimple stmt, basic_block bb)
343 loop_p loop = bb->loop_father;
345 gcc_assert (scop_entry);
347 /* GIMPLE_ASM and GIMPLE_CALL may embed arbitrary side effects.
348 Calls have side-effects, except those to const or pure
349 functions. */
350 if (gimple_has_volatile_ops (stmt)
351 || (gimple_code (stmt) == GIMPLE_CALL
352 && !(gimple_call_flags (stmt) & (ECF_CONST | ECF_PURE)))
353 || (gimple_code (stmt) == GIMPLE_ASM))
355 if (dump_file && (dump_flags & TDF_DETAILS))
357 fprintf (dump_file, "[scop-detection-fail] ");
358 fprintf (dump_file, "Graphite cannot handle this stmt:\n");
359 print_gimple_stmt (dump_file, stmt, 0, TDF_VOPS|TDF_MEMSYMS);
362 return false;
365 if (is_gimple_debug (stmt))
366 return true;
368 if (!stmt_has_simple_data_refs_p (outermost_loop, stmt))
370 if (dump_file && (dump_flags & TDF_DETAILS))
372 fprintf (dump_file, "[scop-detection-fail] ");
373 fprintf (dump_file, "Graphite cannot handle data-refs in stmt:\n");
374 print_gimple_stmt (dump_file, stmt, 0, TDF_VOPS|TDF_MEMSYMS);
377 return false;
380 switch (gimple_code (stmt))
382 case GIMPLE_LABEL:
383 return true;
385 case GIMPLE_COND:
387 /* We can handle all binary comparisons. Inequalities are
388 also supported as they can be represented with union of
389 polyhedra. */
390 enum tree_code code = gimple_cond_code (stmt);
391 if (!(code == LT_EXPR
392 || code == GT_EXPR
393 || code == LE_EXPR
394 || code == GE_EXPR
395 || code == EQ_EXPR
396 || code == NE_EXPR))
398 if (dump_file && (dump_flags & TDF_DETAILS))
400 fprintf (dump_file, "[scop-detection-fail] ");
401 fprintf (dump_file, "Graphite cannot handle cond stmt:\n");
402 print_gimple_stmt (dump_file, stmt, 0, TDF_VOPS|TDF_MEMSYMS);
405 return false;
408 for (unsigned i = 0; i < 2; ++i)
410 tree op = gimple_op (stmt, i);
411 if (!graphite_can_represent_expr (scop_entry, loop, op)
412 /* We can not handle REAL_TYPE. Failed for pr39260. */
413 || TREE_CODE (TREE_TYPE (op)) == REAL_TYPE)
415 if (dump_file && (dump_flags & TDF_DETAILS))
417 fprintf (dump_file, "[scop-detection-fail] ");
418 fprintf (dump_file, "Graphite cannot represent stmt:\n");
419 print_gimple_stmt (dump_file, stmt, 0, TDF_VOPS|TDF_MEMSYMS);
422 return false;
426 return true;
429 case GIMPLE_ASSIGN:
430 case GIMPLE_CALL:
431 return true;
433 default:
434 /* These nodes cut a new scope. */
435 if (dump_file && (dump_flags & TDF_DETAILS))
437 fprintf (dump_file, "[scop-detection-fail] ");
438 fprintf (dump_file, "Gimple stmt not handled in Graphite:\n");
439 print_gimple_stmt (dump_file, stmt, 0, TDF_VOPS|TDF_MEMSYMS);
441 return false;
444 return false;
447 /* Returns the statement of BB that contains a harmful operation: that
448 can be a function call with side effects, the induction variables
449 are not linear with respect to SCOP_ENTRY, etc. The current open
450 scop should end before this statement. The evaluation is limited using
451 OUTERMOST_LOOP as outermost loop that may change. */
453 static gimple
454 harmful_stmt_in_bb (basic_block scop_entry, loop_p outer_loop, basic_block bb)
456 gimple_stmt_iterator gsi;
458 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
459 if (!stmt_simple_for_scop_p (scop_entry, outer_loop, gsi_stmt (gsi), bb))
460 return gsi_stmt (gsi);
462 return NULL;
465 /* Return true if LOOP can be represented in the polyhedral
466 representation. This is evaluated taking SCOP_ENTRY and
467 OUTERMOST_LOOP in mind. */
469 static bool
470 graphite_can_represent_loop (basic_block scop_entry, loop_p loop)
472 tree niter;
473 struct tree_niter_desc niter_desc;
475 /* FIXME: For the moment, graphite cannot be used on loops that
476 iterate using induction variables that wrap. */
478 return number_of_iterations_exit (loop, single_exit (loop), &niter_desc, false)
479 && niter_desc.control.no_overflow
480 && (niter = number_of_latch_executions (loop))
481 && !chrec_contains_undetermined (niter)
482 && graphite_can_represent_expr (scop_entry, loop, niter);
485 /* Store information needed by scopdet_* functions. */
487 struct scopdet_info
489 /* Exit of the open scop would stop if the current BB is harmful. */
490 basic_block exit;
492 /* Where the next scop would start if the current BB is harmful. */
493 basic_block next;
495 /* The bb or one of its children contains open loop exits. That means
496 loop exit nodes that are not surrounded by a loop dominated by bb. */
497 bool exits;
499 /* The bb or one of its children contains only structures we can handle. */
500 bool difficult;
503 static struct scopdet_info build_scops_1 (basic_block, loop_p,
504 vec<sd_region> *, loop_p);
506 /* Calculates BB infos. If bb is difficult we add valid SCoPs dominated by BB
507 to SCOPS. TYPE is the gbb_type of BB. */
509 static struct scopdet_info
510 scopdet_basic_block_info (basic_block bb, loop_p outermost_loop,
511 vec<sd_region> *scops, gbb_type type)
513 loop_p loop = bb->loop_father;
514 struct scopdet_info result;
515 gimple stmt;
517 /* XXX: ENTRY_BLOCK_PTR could be optimized in later steps. */
518 basic_block entry_block = ENTRY_BLOCK_PTR_FOR_FN (cfun);
519 stmt = harmful_stmt_in_bb (entry_block, outermost_loop, bb);
520 result.difficult = (stmt != NULL);
521 result.exit = NULL;
523 switch (type)
525 case GBB_LAST:
526 result.next = NULL;
527 result.exits = false;
529 /* Mark bbs terminating a SESE region difficult, if they start
530 a condition or if the block it exits to cannot be split
531 with make_forwarder_block. */
532 if (!single_succ_p (bb)
533 || bb_has_abnormal_pred (single_succ (bb)))
535 if (dump_file && (dump_flags & TDF_DETAILS))
537 fprintf (dump_file, "[scop-detection-fail] ");
538 fprintf (dump_file, "BB %d cannot be part of a scop.\n",
539 bb->index);
542 result.difficult = true;
544 else
545 result.exit = single_succ (bb);
547 break;
549 case GBB_SIMPLE:
550 result.next = single_succ (bb);
551 result.exits = false;
552 result.exit = single_succ (bb);
553 break;
555 case GBB_LOOP_SING_EXIT_HEADER:
557 auto_vec<sd_region, 3> regions;
558 struct scopdet_info sinfo;
559 edge exit_e = single_exit (loop);
561 sinfo = build_scops_1 (bb, outermost_loop, &regions, loop);
563 if (!graphite_can_represent_loop (entry_block, loop))
565 if (dump_file && (dump_flags & TDF_DETAILS))
567 fprintf (dump_file, "[scop-detection-fail] ");
568 fprintf (dump_file, "Graphite cannot represent loop %d.\n",
569 loop->num);
571 result.difficult = true;
574 result.difficult |= sinfo.difficult;
576 /* Try again with another loop level. */
577 if (result.difficult
578 && loop_depth (outermost_loop) + 1 == loop_depth (loop))
580 outermost_loop = loop;
582 regions.release ();
583 regions.create (3);
585 sinfo = scopdet_basic_block_info (bb, outermost_loop, scops, type);
587 result = sinfo;
588 result.difficult = true;
590 if (sinfo.difficult)
591 move_sd_regions (&regions, scops);
592 else
594 sd_region open_scop;
595 open_scop.entry = bb;
596 open_scop.exit = exit_e->dest;
597 scops->safe_push (open_scop);
598 regions.release ();
601 else
603 result.exit = exit_e->dest;
604 result.next = exit_e->dest;
606 /* If we do not dominate result.next, remove it. It's either
607 the exit block, or another bb dominates it and will
608 call the scop detection for this bb. */
609 if (!dominated_by_p (CDI_DOMINATORS, result.next, bb))
610 result.next = NULL;
612 if (exit_e->src->loop_father != loop)
613 result.next = NULL;
615 result.exits = false;
617 if (result.difficult)
618 move_sd_regions (&regions, scops);
619 else
620 regions.release ();
623 break;
626 case GBB_LOOP_MULT_EXIT_HEADER:
628 /* XXX: For now we just do not join loops with multiple exits. If the
629 exits lead to the same bb it may be possible to join the loop. */
630 auto_vec<sd_region, 3> regions;
631 vec<edge> exits = get_loop_exit_edges (loop);
632 edge e;
633 int i;
634 build_scops_1 (bb, loop, &regions, loop);
636 /* Scan the code dominated by this loop. This means all bbs, that are
637 are dominated by a bb in this loop, but are not part of this loop.
639 The easiest case:
640 - The loop exit destination is dominated by the exit sources.
642 TODO: We miss here the more complex cases:
643 - The exit destinations are dominated by another bb inside
644 the loop.
645 - The loop dominates bbs, that are not exit destinations. */
646 FOR_EACH_VEC_ELT (exits, i, e)
647 if (e->src->loop_father == loop
648 && dominated_by_p (CDI_DOMINATORS, e->dest, e->src))
650 if (loop_outer (outermost_loop))
651 outermost_loop = loop_outer (outermost_loop);
653 /* Pass loop_outer to recognize e->dest as loop header in
654 build_scops_1. */
655 if (e->dest->loop_father->header == e->dest)
656 build_scops_1 (e->dest, outermost_loop, &regions,
657 loop_outer (e->dest->loop_father));
658 else
659 build_scops_1 (e->dest, outermost_loop, &regions,
660 e->dest->loop_father);
663 result.next = NULL;
664 result.exit = NULL;
665 result.difficult = true;
666 result.exits = false;
667 move_sd_regions (&regions, scops);
668 exits.release ();
669 break;
671 case GBB_COND_HEADER:
673 auto_vec<sd_region, 3> regions;
674 struct scopdet_info sinfo;
675 vec<basic_block> dominated;
676 int i;
677 basic_block dom_bb;
678 basic_block last_exit = NULL;
679 edge e;
680 result.exits = false;
682 /* First check the successors of BB, and check if it is
683 possible to join the different branches. */
684 FOR_EACH_VEC_SAFE_ELT (bb->succs, i, e)
686 /* Ignore loop exits. They will be handled after the loop
687 body. */
688 if (loop_exits_to_bb_p (loop, e->dest))
690 result.exits = true;
691 continue;
694 /* Do not follow edges that lead to the end of the
695 conditions block. For example, in
698 | /|\
699 | 1 2 |
700 | | | |
701 | 3 4 |
702 | \|/
705 the edge from 0 => 6. Only check if all paths lead to
706 the same node 6. */
708 if (!single_pred_p (e->dest))
710 /* Check, if edge leads directly to the end of this
711 condition. */
712 if (!last_exit)
713 last_exit = e->dest;
715 if (e->dest != last_exit)
716 result.difficult = true;
718 continue;
721 if (!dominated_by_p (CDI_DOMINATORS, e->dest, bb))
723 result.difficult = true;
724 continue;
727 sinfo = build_scops_1 (e->dest, outermost_loop, &regions, loop);
729 result.exits |= sinfo.exits;
730 result.difficult |= sinfo.difficult;
732 /* Checks, if all branches end at the same point.
733 If that is true, the condition stays joinable.
734 Have a look at the example above. */
735 if (sinfo.exit)
737 if (!last_exit)
738 last_exit = sinfo.exit;
740 if (sinfo.exit != last_exit)
741 result.difficult = true;
743 else
744 result.difficult = true;
747 if (!last_exit)
748 result.difficult = true;
750 /* Join the branches of the condition if possible. */
751 if (!result.exits && !result.difficult)
753 /* Only return a next pointer if we dominate this pointer.
754 Otherwise it will be handled by the bb dominating it. */
755 if (dominated_by_p (CDI_DOMINATORS, last_exit, bb)
756 && last_exit != bb)
757 result.next = last_exit;
758 else
759 result.next = NULL;
761 result.exit = last_exit;
763 regions.release ();
764 break;
767 /* Scan remaining bbs dominated by BB. */
768 dominated = get_dominated_by (CDI_DOMINATORS, bb);
770 FOR_EACH_VEC_ELT (dominated, i, dom_bb)
772 /* Ignore loop exits: they will be handled after the loop body. */
773 if (loop_depth (find_common_loop (loop, dom_bb->loop_father))
774 < loop_depth (loop))
776 result.exits = true;
777 continue;
780 /* Ignore the bbs processed above. */
781 if (single_pred_p (dom_bb) && single_pred (dom_bb) == bb)
782 continue;
784 if (loop_depth (loop) > loop_depth (dom_bb->loop_father))
785 sinfo = build_scops_1 (dom_bb, outermost_loop, &regions,
786 loop_outer (loop));
787 else
788 sinfo = build_scops_1 (dom_bb, outermost_loop, &regions, loop);
790 result.exits |= sinfo.exits;
791 result.difficult = true;
792 result.exit = NULL;
795 dominated.release ();
797 result.next = NULL;
798 move_sd_regions (&regions, scops);
800 break;
803 default:
804 gcc_unreachable ();
807 return result;
810 /* Starting from CURRENT we walk the dominance tree and add new sd_regions to
811 SCOPS. The analyse if a sd_region can be handled is based on the value
812 of OUTERMOST_LOOP. Only loops inside OUTERMOST loops may change. LOOP
813 is the loop in which CURRENT is handled.
815 TODO: These functions got a little bit big. They definitely should be cleaned
816 up. */
818 static struct scopdet_info
819 build_scops_1 (basic_block current, loop_p outermost_loop,
820 vec<sd_region> *scops, loop_p loop)
822 bool in_scop = false;
823 sd_region open_scop;
824 struct scopdet_info sinfo;
826 /* Initialize result. */
827 struct scopdet_info result;
828 result.exits = false;
829 result.difficult = false;
830 result.next = NULL;
831 result.exit = NULL;
832 open_scop.entry = NULL;
833 open_scop.exit = NULL;
834 sinfo.exit = NULL;
836 /* Loop over the dominance tree. If we meet a difficult bb, close
837 the current SCoP. Loop and condition header start a new layer,
838 and can only be added if all bbs in deeper layers are simple. */
839 while (current != NULL)
841 sinfo = scopdet_basic_block_info (current, outermost_loop, scops,
842 get_bb_type (current, loop));
844 if (!in_scop && !(sinfo.exits || sinfo.difficult))
846 open_scop.entry = current;
847 open_scop.exit = NULL;
848 in_scop = true;
850 else if (in_scop && (sinfo.exits || sinfo.difficult))
852 open_scop.exit = current;
853 scops->safe_push (open_scop);
854 in_scop = false;
857 result.difficult |= sinfo.difficult;
858 result.exits |= sinfo.exits;
860 current = sinfo.next;
863 /* Try to close open_scop, if we are still in an open SCoP. */
864 if (in_scop)
866 open_scop.exit = sinfo.exit;
867 gcc_assert (open_scop.exit);
868 if (open_scop.entry != open_scop.exit)
869 scops->safe_push (open_scop);
870 else
872 sinfo.difficult = true;
873 sinfo.exits = false;
874 sinfo.exit = NULL;
878 result.exit = sinfo.exit;
879 return result;
882 /* Checks if a bb is contained in REGION. */
884 static bool
885 bb_in_sd_region (basic_block bb, sd_region *region)
887 return bb_in_region (bb, region->entry, region->exit);
890 /* Returns the single entry edge of REGION, if it does not exits NULL. */
892 static edge
893 find_single_entry_edge (sd_region *region)
895 edge e;
896 edge_iterator ei;
897 edge entry = NULL;
899 FOR_EACH_EDGE (e, ei, region->entry->preds)
900 if (!bb_in_sd_region (e->src, region))
902 if (entry)
904 entry = NULL;
905 break;
908 else
909 entry = e;
912 return entry;
915 /* Returns the single exit edge of REGION, if it does not exits NULL. */
917 static edge
918 find_single_exit_edge (sd_region *region)
920 edge e;
921 edge_iterator ei;
922 edge exit = NULL;
924 FOR_EACH_EDGE (e, ei, region->exit->preds)
925 if (bb_in_sd_region (e->src, region))
927 if (exit)
929 exit = NULL;
930 break;
933 else
934 exit = e;
937 return exit;
940 /* Create a single entry edge for REGION. */
942 static void
943 create_single_entry_edge (sd_region *region)
945 if (find_single_entry_edge (region))
946 return;
948 /* There are multiple predecessors for bb_3
950 | 1 2
951 | | /
952 | |/
953 | 3 <- entry
954 | |\
955 | | |
956 | 4 ^
957 | | |
958 | |/
961 There are two edges (1->3, 2->3), that point from outside into the region,
962 and another one (5->3), a loop latch, lead to bb_3.
964 We split bb_3.
966 | 1 2
967 | | /
968 | |/
969 |3.0
970 | |\ (3.0 -> 3.1) = single entry edge
971 |3.1 | <- entry
972 | | |
973 | | |
974 | 4 ^
975 | | |
976 | |/
979 If the loop is part of the SCoP, we have to redirect the loop latches.
981 | 1 2
982 | | /
983 | |/
984 |3.0
985 | | (3.0 -> 3.1) = entry edge
986 |3.1 <- entry
987 | |\
988 | | |
989 | 4 ^
990 | | |
991 | |/
992 | 5 */
994 if (region->entry->loop_father->header != region->entry
995 || dominated_by_p (CDI_DOMINATORS,
996 loop_latch_edge (region->entry->loop_father)->src,
997 region->exit))
999 edge forwarder = split_block_after_labels (region->entry);
1000 region->entry = forwarder->dest;
1002 else
1003 /* This case is never executed, as the loop headers seem always to have a
1004 single edge pointing from outside into the loop. */
1005 gcc_unreachable ();
1007 gcc_checking_assert (find_single_entry_edge (region));
1010 /* Check if the sd_region, mentioned in EDGE, has no exit bb. */
1012 static bool
1013 sd_region_without_exit (edge e)
1015 sd_region *r = (sd_region *) e->aux;
1017 if (r)
1018 return r->exit == NULL;
1019 else
1020 return false;
1023 /* Create a single exit edge for REGION. */
1025 static void
1026 create_single_exit_edge (sd_region *region)
1028 edge e;
1029 edge_iterator ei;
1030 edge forwarder = NULL;
1031 basic_block exit;
1033 /* We create a forwarder bb (5) for all edges leaving this region
1034 (3->5, 4->5). All other edges leading to the same bb, are moved
1035 to a new bb (6). If these edges where part of another region (2->5)
1036 we update the region->exit pointer, of this region.
1038 To identify which edge belongs to which region we depend on the e->aux
1039 pointer in every edge. It points to the region of the edge or to NULL,
1040 if the edge is not part of any region.
1042 1 2 3 4 1->5 no region, 2->5 region->exit = 5,
1043 \| |/ 3->5 region->exit = NULL, 4->5 region->exit = NULL
1044 5 <- exit
1046 changes to
1048 1 2 3 4 1->6 no region, 2->6 region->exit = 6,
1049 | | \/ 3->5 no region, 4->5 no region,
1050 | | 5
1051 \| / 5->6 region->exit = 6
1054 Now there is only a single exit edge (5->6). */
1055 exit = region->exit;
1056 region->exit = NULL;
1057 forwarder = make_forwarder_block (exit, &sd_region_without_exit, NULL);
1059 /* Unmark the edges, that are no longer exit edges. */
1060 FOR_EACH_EDGE (e, ei, forwarder->src->preds)
1061 if (e->aux)
1062 e->aux = NULL;
1064 /* Mark the new exit edge. */
1065 single_succ_edge (forwarder->src)->aux = region;
1067 /* Update the exit bb of all regions, where exit edges lead to
1068 forwarder->dest. */
1069 FOR_EACH_EDGE (e, ei, forwarder->dest->preds)
1070 if (e->aux)
1071 ((sd_region *) e->aux)->exit = forwarder->dest;
1073 gcc_checking_assert (find_single_exit_edge (region));
1076 /* Unmark the exit edges of all REGIONS.
1077 See comment in "create_single_exit_edge". */
1079 static void
1080 unmark_exit_edges (vec<sd_region> regions)
1082 int i;
1083 sd_region *s;
1084 edge e;
1085 edge_iterator ei;
1087 FOR_EACH_VEC_ELT (regions, i, s)
1088 FOR_EACH_EDGE (e, ei, s->exit->preds)
1089 e->aux = NULL;
1093 /* Mark the exit edges of all REGIONS.
1094 See comment in "create_single_exit_edge". */
1096 static void
1097 mark_exit_edges (vec<sd_region> regions)
1099 int i;
1100 sd_region *s;
1101 edge e;
1102 edge_iterator ei;
1104 FOR_EACH_VEC_ELT (regions, i, s)
1105 FOR_EACH_EDGE (e, ei, s->exit->preds)
1106 if (bb_in_sd_region (e->src, s))
1107 e->aux = s;
1110 /* Create for all scop regions a single entry and a single exit edge. */
1112 static void
1113 create_sese_edges (vec<sd_region> regions)
1115 int i;
1116 sd_region *s;
1118 FOR_EACH_VEC_ELT (regions, i, s)
1119 create_single_entry_edge (s);
1121 mark_exit_edges (regions);
1123 FOR_EACH_VEC_ELT (regions, i, s)
1124 /* Don't handle multiple edges exiting the function. */
1125 if (!find_single_exit_edge (s)
1126 && s->exit != EXIT_BLOCK_PTR_FOR_FN (cfun))
1127 create_single_exit_edge (s);
1129 unmark_exit_edges (regions);
1131 calculate_dominance_info (CDI_DOMINATORS);
1132 fix_loop_structure (NULL);
1134 #ifdef ENABLE_CHECKING
1135 verify_loop_structure ();
1136 verify_ssa (false, true);
1137 #endif
1140 /* Create graphite SCoPs from an array of scop detection REGIONS. */
1142 static void
1143 build_graphite_scops (vec<sd_region> regions,
1144 vec<scop_p> *scops)
1146 int i;
1147 sd_region *s;
1149 FOR_EACH_VEC_ELT (regions, i, s)
1151 edge entry = find_single_entry_edge (s);
1152 edge exit = find_single_exit_edge (s);
1153 scop_p scop;
1155 if (!exit)
1156 continue;
1158 scop = new_scop (new_sese (entry, exit));
1159 scops->safe_push (scop);
1161 /* Are there overlapping SCoPs? */
1162 #ifdef ENABLE_CHECKING
1164 int j;
1165 sd_region *s2;
1167 FOR_EACH_VEC_ELT (regions, j, s2)
1168 if (s != s2)
1169 gcc_assert (!bb_in_sd_region (s->entry, s2));
1171 #endif
1175 /* Returns true when BB contains only close phi nodes. */
1177 static bool
1178 contains_only_close_phi_nodes (basic_block bb)
1180 gimple_stmt_iterator gsi;
1182 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
1183 if (gimple_code (gsi_stmt (gsi)) != GIMPLE_LABEL)
1184 return false;
1186 return true;
1189 /* Print statistics for SCOP to FILE. */
1191 static void
1192 print_graphite_scop_statistics (FILE* file, scop_p scop)
1194 long n_bbs = 0;
1195 long n_loops = 0;
1196 long n_stmts = 0;
1197 long n_conditions = 0;
1198 long n_p_bbs = 0;
1199 long n_p_loops = 0;
1200 long n_p_stmts = 0;
1201 long n_p_conditions = 0;
1203 basic_block bb;
1205 FOR_ALL_BB_FN (bb, cfun)
1207 gimple_stmt_iterator psi;
1208 loop_p loop = bb->loop_father;
1210 if (!bb_in_sese_p (bb, SCOP_REGION (scop)))
1211 continue;
1213 n_bbs++;
1214 n_p_bbs += bb->count;
1216 if (EDGE_COUNT (bb->succs) > 1)
1218 n_conditions++;
1219 n_p_conditions += bb->count;
1222 for (psi = gsi_start_bb (bb); !gsi_end_p (psi); gsi_next (&psi))
1224 n_stmts++;
1225 n_p_stmts += bb->count;
1228 if (loop->header == bb && loop_in_sese_p (loop, SCOP_REGION (scop)))
1230 n_loops++;
1231 n_p_loops += bb->count;
1236 fprintf (file, "\nBefore limit_scops SCoP statistics (");
1237 fprintf (file, "BBS:%ld, ", n_bbs);
1238 fprintf (file, "LOOPS:%ld, ", n_loops);
1239 fprintf (file, "CONDITIONS:%ld, ", n_conditions);
1240 fprintf (file, "STMTS:%ld)\n", n_stmts);
1241 fprintf (file, "\nBefore limit_scops SCoP profiling statistics (");
1242 fprintf (file, "BBS:%ld, ", n_p_bbs);
1243 fprintf (file, "LOOPS:%ld, ", n_p_loops);
1244 fprintf (file, "CONDITIONS:%ld, ", n_p_conditions);
1245 fprintf (file, "STMTS:%ld)\n", n_p_stmts);
1248 /* Print statistics for SCOPS to FILE. */
1250 static void
1251 print_graphite_statistics (FILE* file, vec<scop_p> scops)
1253 int i;
1254 scop_p scop;
1256 FOR_EACH_VEC_ELT (scops, i, scop)
1257 print_graphite_scop_statistics (file, scop);
1260 /* We limit all SCoPs to SCoPs, that are completely surrounded by a loop.
1262 Example:
1264 for (i |
1266 for (j | SCoP 1
1267 for (k |
1270 * SCoP frontier, as this line is not surrounded by any loop. *
1272 for (l | SCoP 2
1274 This is necessary as scalar evolution and parameter detection need a
1275 outermost loop to initialize parameters correctly.
1277 TODO: FIX scalar evolution and parameter detection to allow more flexible
1278 SCoP frontiers. */
1280 static void
1281 limit_scops (vec<scop_p> *scops)
1283 auto_vec<sd_region, 3> regions;
1285 int i;
1286 scop_p scop;
1288 FOR_EACH_VEC_ELT (*scops, i, scop)
1290 int j;
1291 loop_p loop;
1292 sese region = SCOP_REGION (scop);
1293 build_sese_loop_nests (region);
1295 FOR_EACH_VEC_ELT (SESE_LOOP_NEST (region), j, loop)
1296 if (!loop_in_sese_p (loop_outer (loop), region)
1297 && single_exit (loop))
1299 sd_region open_scop;
1300 open_scop.entry = loop->header;
1301 open_scop.exit = single_exit (loop)->dest;
1303 /* This is a hack on top of the limit_scops hack. The
1304 limit_scops hack should disappear all together. */
1305 if (single_succ_p (open_scop.exit)
1306 && contains_only_close_phi_nodes (open_scop.exit))
1307 open_scop.exit = single_succ_edge (open_scop.exit)->dest;
1309 regions.safe_push (open_scop);
1313 free_scops (*scops);
1314 scops->create (3);
1316 create_sese_edges (regions);
1317 build_graphite_scops (regions, scops);
1320 /* Returns true when P1 and P2 are close phis with the same
1321 argument. */
1323 static inline bool
1324 same_close_phi_node (gphi *p1, gphi *p2)
1326 return operand_equal_p (gimple_phi_arg_def (p1, 0),
1327 gimple_phi_arg_def (p2, 0), 0);
1330 /* Remove the close phi node at GSI and replace its rhs with the rhs
1331 of PHI. */
1333 static void
1334 remove_duplicate_close_phi (gphi *phi, gphi_iterator *gsi)
1336 gimple use_stmt;
1337 use_operand_p use_p;
1338 imm_use_iterator imm_iter;
1339 tree res = gimple_phi_result (phi);
1340 tree def = gimple_phi_result (gsi->phi ());
1342 gcc_assert (same_close_phi_node (phi, gsi->phi ()));
1344 FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, def)
1346 FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter)
1347 SET_USE (use_p, res);
1349 update_stmt (use_stmt);
1351 /* It is possible that we just created a duplicate close-phi
1352 for an already-processed containing loop. Check for this
1353 case and clean it up. */
1354 if (gimple_code (use_stmt) == GIMPLE_PHI
1355 && gimple_phi_num_args (use_stmt) == 1)
1356 make_close_phi_nodes_unique (gimple_bb (use_stmt));
1359 remove_phi_node (gsi, true);
1362 /* Removes all the close phi duplicates from BB. */
1364 static void
1365 make_close_phi_nodes_unique (basic_block bb)
1367 gphi_iterator psi;
1369 for (psi = gsi_start_phis (bb); !gsi_end_p (psi); gsi_next (&psi))
1371 gphi_iterator gsi = psi;
1372 gphi *phi = psi.phi ();
1374 /* At this point, PHI should be a close phi in normal form. */
1375 gcc_assert (gimple_phi_num_args (phi) == 1);
1377 /* Iterate over the next phis and remove duplicates. */
1378 gsi_next (&gsi);
1379 while (!gsi_end_p (gsi))
1380 if (same_close_phi_node (phi, gsi.phi ()))
1381 remove_duplicate_close_phi (phi, &gsi);
1382 else
1383 gsi_next (&gsi);
1387 /* Transforms LOOP to the canonical loop closed SSA form. */
1389 static void
1390 canonicalize_loop_closed_ssa (loop_p loop)
1392 edge e = single_exit (loop);
1393 basic_block bb;
1395 if (!e || e->flags & EDGE_ABNORMAL)
1396 return;
1398 bb = e->dest;
1400 if (single_pred_p (bb))
1402 e = split_block_after_labels (bb);
1403 make_close_phi_nodes_unique (e->src);
1405 else
1407 gphi_iterator psi;
1408 basic_block close = split_edge (e);
1410 e = single_succ_edge (close);
1412 for (psi = gsi_start_phis (bb); !gsi_end_p (psi); gsi_next (&psi))
1414 gphi *phi = psi.phi ();
1415 unsigned i;
1417 for (i = 0; i < gimple_phi_num_args (phi); i++)
1418 if (gimple_phi_arg_edge (phi, i) == e)
1420 tree res, arg = gimple_phi_arg_def (phi, i);
1421 use_operand_p use_p;
1422 gphi *close_phi;
1424 if (TREE_CODE (arg) != SSA_NAME)
1425 continue;
1427 close_phi = create_phi_node (NULL_TREE, close);
1428 res = create_new_def_for (arg, close_phi,
1429 gimple_phi_result_ptr (close_phi));
1430 add_phi_arg (close_phi, arg,
1431 gimple_phi_arg_edge (close_phi, 0),
1432 UNKNOWN_LOCATION);
1433 use_p = gimple_phi_arg_imm_use_ptr (phi, i);
1434 replace_exp (use_p, res);
1435 update_stmt (phi);
1439 make_close_phi_nodes_unique (close);
1442 /* The code above does not properly handle changes in the post dominance
1443 information (yet). */
1444 free_dominance_info (CDI_POST_DOMINATORS);
1447 /* Converts the current loop closed SSA form to a canonical form
1448 expected by the Graphite code generation.
1450 The loop closed SSA form has the following invariant: a variable
1451 defined in a loop that is used outside the loop appears only in the
1452 phi nodes in the destination of the loop exit. These phi nodes are
1453 called close phi nodes.
1455 The canonical loop closed SSA form contains the extra invariants:
1457 - when the loop contains only one exit, the close phi nodes contain
1458 only one argument. That implies that the basic block that contains
1459 the close phi nodes has only one predecessor, that is a basic block
1460 in the loop.
1462 - the basic block containing the close phi nodes does not contain
1463 other statements.
1465 - there exist only one phi node per definition in the loop.
1468 static void
1469 canonicalize_loop_closed_ssa_form (void)
1471 loop_p loop;
1473 #ifdef ENABLE_CHECKING
1474 verify_loop_closed_ssa (true);
1475 #endif
1477 FOR_EACH_LOOP (loop, 0)
1478 canonicalize_loop_closed_ssa (loop);
1480 rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa);
1481 update_ssa (TODO_update_ssa);
1483 #ifdef ENABLE_CHECKING
1484 verify_loop_closed_ssa (true);
1485 #endif
1488 /* Find Static Control Parts (SCoP) in the current function and pushes
1489 them to SCOPS. */
1491 void
1492 build_scops (vec<scop_p> *scops)
1494 struct loop *loop = current_loops->tree_root;
1495 auto_vec<sd_region, 3> regions;
1497 canonicalize_loop_closed_ssa_form ();
1498 build_scops_1 (single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun)),
1499 ENTRY_BLOCK_PTR_FOR_FN (cfun)->loop_father,
1500 &regions, loop);
1501 create_sese_edges (regions);
1502 build_graphite_scops (regions, scops);
1504 if (dump_file && (dump_flags & TDF_DETAILS))
1505 print_graphite_statistics (dump_file, *scops);
1507 limit_scops (scops);
1508 regions.release ();
1510 if (dump_file && (dump_flags & TDF_DETAILS))
1511 fprintf (dump_file, "\nnumber of SCoPs: %d\n",
1512 scops ? scops->length () : 0);
1515 /* Pretty print to FILE all the SCoPs in DOT format and mark them with
1516 different colors. If there are not enough colors, paint the
1517 remaining SCoPs in gray.
1519 Special nodes:
1520 - "*" after the node number denotes the entry of a SCoP,
1521 - "#" after the node number denotes the exit of a SCoP,
1522 - "()" around the node number denotes the entry or the
1523 exit nodes of the SCOP. These are not part of SCoP. */
1525 static void
1526 dot_all_scops_1 (FILE *file, vec<scop_p> scops)
1528 basic_block bb;
1529 edge e;
1530 edge_iterator ei;
1531 scop_p scop;
1532 const char* color;
1533 int i;
1535 /* Disable debugging while printing graph. */
1536 int tmp_dump_flags = dump_flags;
1537 dump_flags = 0;
1539 fprintf (file, "digraph all {\n");
1541 FOR_ALL_BB_FN (bb, cfun)
1543 int part_of_scop = false;
1545 /* Use HTML for every bb label. So we are able to print bbs
1546 which are part of two different SCoPs, with two different
1547 background colors. */
1548 fprintf (file, "%d [label=<\n <TABLE BORDER=\"0\" CELLBORDER=\"1\" ",
1549 bb->index);
1550 fprintf (file, "CELLSPACING=\"0\">\n");
1552 /* Select color for SCoP. */
1553 FOR_EACH_VEC_ELT (scops, i, scop)
1555 sese region = SCOP_REGION (scop);
1556 if (bb_in_sese_p (bb, region)
1557 || (SESE_EXIT_BB (region) == bb)
1558 || (SESE_ENTRY_BB (region) == bb))
1560 switch (i % 17)
1562 case 0: /* red */
1563 color = "#e41a1c";
1564 break;
1565 case 1: /* blue */
1566 color = "#377eb8";
1567 break;
1568 case 2: /* green */
1569 color = "#4daf4a";
1570 break;
1571 case 3: /* purple */
1572 color = "#984ea3";
1573 break;
1574 case 4: /* orange */
1575 color = "#ff7f00";
1576 break;
1577 case 5: /* yellow */
1578 color = "#ffff33";
1579 break;
1580 case 6: /* brown */
1581 color = "#a65628";
1582 break;
1583 case 7: /* rose */
1584 color = "#f781bf";
1585 break;
1586 case 8:
1587 color = "#8dd3c7";
1588 break;
1589 case 9:
1590 color = "#ffffb3";
1591 break;
1592 case 10:
1593 color = "#bebada";
1594 break;
1595 case 11:
1596 color = "#fb8072";
1597 break;
1598 case 12:
1599 color = "#80b1d3";
1600 break;
1601 case 13:
1602 color = "#fdb462";
1603 break;
1604 case 14:
1605 color = "#b3de69";
1606 break;
1607 case 15:
1608 color = "#fccde5";
1609 break;
1610 case 16:
1611 color = "#bc80bd";
1612 break;
1613 default: /* gray */
1614 color = "#999999";
1617 fprintf (file, " <TR><TD WIDTH=\"50\" BGCOLOR=\"%s\">", color);
1619 if (!bb_in_sese_p (bb, region))
1620 fprintf (file, " (");
1622 if (bb == SESE_ENTRY_BB (region)
1623 && bb == SESE_EXIT_BB (region))
1624 fprintf (file, " %d*# ", bb->index);
1625 else if (bb == SESE_ENTRY_BB (region))
1626 fprintf (file, " %d* ", bb->index);
1627 else if (bb == SESE_EXIT_BB (region))
1628 fprintf (file, " %d# ", bb->index);
1629 else
1630 fprintf (file, " %d ", bb->index);
1632 if (!bb_in_sese_p (bb,region))
1633 fprintf (file, ")");
1635 fprintf (file, "</TD></TR>\n");
1636 part_of_scop = true;
1640 if (!part_of_scop)
1642 fprintf (file, " <TR><TD WIDTH=\"50\" BGCOLOR=\"#ffffff\">");
1643 fprintf (file, " %d </TD></TR>\n", bb->index);
1645 fprintf (file, " </TABLE>>, shape=box, style=\"setlinewidth(0)\"]\n");
1648 FOR_ALL_BB_FN (bb, cfun)
1650 FOR_EACH_EDGE (e, ei, bb->succs)
1651 fprintf (file, "%d -> %d;\n", bb->index, e->dest->index);
1654 fputs ("}\n\n", file);
1656 /* Enable debugging again. */
1657 dump_flags = tmp_dump_flags;
1660 /* Display all SCoPs using dotty. */
1662 DEBUG_FUNCTION void
1663 dot_all_scops (vec<scop_p> scops)
1665 /* When debugging, enable the following code. This cannot be used
1666 in production compilers because it calls "system". */
1667 #if 0
1668 int x;
1669 FILE *stream = fopen ("/tmp/allscops.dot", "w");
1670 gcc_assert (stream);
1672 dot_all_scops_1 (stream, scops);
1673 fclose (stream);
1675 x = system ("dotty /tmp/allscops.dot &");
1676 #else
1677 dot_all_scops_1 (stderr, scops);
1678 #endif
1681 /* Display all SCoPs using dotty. */
1683 DEBUG_FUNCTION void
1684 dot_scop (scop_p scop)
1686 auto_vec<scop_p, 1> scops;
1688 if (scop)
1689 scops.safe_push (scop);
1691 /* When debugging, enable the following code. This cannot be used
1692 in production compilers because it calls "system". */
1693 #if 0
1695 int x;
1696 FILE *stream = fopen ("/tmp/allscops.dot", "w");
1697 gcc_assert (stream);
1699 dot_all_scops_1 (stream, scops);
1700 fclose (stream);
1701 x = system ("dotty /tmp/allscops.dot &");
1703 #else
1704 dot_all_scops_1 (stderr, scops);
1705 #endif
1708 #endif /* HAVE_isl */