OSDN Git Service

Remove redundant checks in graphite_can_represent_scev.
[pf3gnuchains/gcc-fork.git] / gcc / graphite-scop-detection.c
1 /* Detection of Static Control Parts (SCoP) for Graphite.
2    Copyright (C) 2009, 2010 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
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "tm.h"
26 #include "ggc.h"
27 #include "tree.h"
28 #include "rtl.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 "sese.h"
45
46 #ifdef HAVE_cloog
47 #include "ppl_c.h"
48 #include "graphite-ppl.h"
49 #include "graphite.h"
50 #include "graphite-poly.h"
51 #include "graphite-scop-detection.h"
52
53 /* The type of the analyzed basic block.  */
54
55 typedef enum gbb_type {
56   GBB_UNKNOWN,
57   GBB_LOOP_SING_EXIT_HEADER,
58   GBB_LOOP_MULT_EXIT_HEADER,
59   GBB_LOOP_EXIT,
60   GBB_COND_HEADER,
61   GBB_SIMPLE,
62   GBB_LAST
63 } gbb_type;
64
65 /* Detect the type of BB.  Loop headers are only marked, if they are
66    new.  This means their loop_father is different to LAST_LOOP.
67    Otherwise they are treated like any other bb and their type can be
68    any other type.  */
69
70 static gbb_type
71 get_bb_type (basic_block bb, struct loop *last_loop)
72 {
73   VEC (basic_block, heap) *dom;
74   int nb_dom, nb_suc;
75   struct loop *loop = bb->loop_father;
76
77   /* Check, if we entry into a new loop. */
78   if (loop != last_loop)
79     {
80       if (single_exit (loop) != NULL)
81         return GBB_LOOP_SING_EXIT_HEADER;
82       else if (loop->num != 0)
83         return GBB_LOOP_MULT_EXIT_HEADER;
84       else
85         return GBB_COND_HEADER;
86     }
87
88   dom = get_dominated_by (CDI_DOMINATORS, bb);
89   nb_dom = VEC_length (basic_block, dom);
90   VEC_free (basic_block, heap, dom);
91
92   if (nb_dom == 0)
93     return GBB_LAST;
94
95   nb_suc = VEC_length (edge, bb->succs);
96
97   if (nb_dom == 1 && nb_suc == 1)
98     return GBB_SIMPLE;
99
100   return GBB_COND_HEADER;
101 }
102
103 /* A SCoP detection region, defined using bbs as borders.
104
105    All control flow touching this region, comes in passing basic_block
106    ENTRY and leaves passing basic_block EXIT.  By using bbs instead of
107    edges for the borders we are able to represent also regions that do
108    not have a single entry or exit edge.
109
110    But as they have a single entry basic_block and a single exit
111    basic_block, we are able to generate for every sd_region a single
112    entry and exit edge.
113
114    1   2
115     \ /
116      3  <- entry
117      |
118      4
119     / \                 This region contains: {3, 4, 5, 6, 7, 8}
120    5   6
121    |   |
122    7   8
123     \ /
124      9  <- exit  */
125
126
127 typedef struct sd_region_p
128 {
129   /* The entry bb dominates all bbs in the sd_region.  It is part of
130      the region.  */
131   basic_block entry;
132
133   /* The exit bb postdominates all bbs in the sd_region, but is not
134      part of the region.  */
135   basic_block exit;
136 } sd_region;
137
138 DEF_VEC_O(sd_region);
139 DEF_VEC_ALLOC_O(sd_region, heap);
140
141
142 /* Moves the scops from SOURCE to TARGET and clean up SOURCE.  */
143
144 static void
145 move_sd_regions (VEC (sd_region, heap) **source,
146                  VEC (sd_region, heap) **target)
147 {
148   sd_region *s;
149   int i;
150
151   FOR_EACH_VEC_ELT (sd_region, *source, i, s)
152     VEC_safe_push (sd_region, heap, *target, s);
153
154   VEC_free (sd_region, heap, *source);
155 }
156
157 /* Something like "n * m" is not allowed.  */
158
159 static bool
160 graphite_can_represent_init (tree e)
161 {
162   switch (TREE_CODE (e))
163     {
164     case POLYNOMIAL_CHREC:
165       return graphite_can_represent_init (CHREC_LEFT (e))
166         && graphite_can_represent_init (CHREC_RIGHT (e));
167
168     case MULT_EXPR:
169       if (chrec_contains_symbols (TREE_OPERAND (e, 0)))
170         return graphite_can_represent_init (TREE_OPERAND (e, 0))
171           && host_integerp (TREE_OPERAND (e, 1), 0);
172       else
173         return graphite_can_represent_init (TREE_OPERAND (e, 1))
174           && host_integerp (TREE_OPERAND (e, 0), 0);
175
176     case PLUS_EXPR:
177     case POINTER_PLUS_EXPR:
178     case MINUS_EXPR:
179       return graphite_can_represent_init (TREE_OPERAND (e, 0))
180         && graphite_can_represent_init (TREE_OPERAND (e, 1));
181
182     case NEGATE_EXPR:
183     case BIT_NOT_EXPR:
184     CASE_CONVERT:
185     case NON_LVALUE_EXPR:
186       return graphite_can_represent_init (TREE_OPERAND (e, 0));
187
188    default:
189      break;
190     }
191
192   return true;
193 }
194
195 /* Return true when SCEV can be represented in the polyhedral model.
196
197    An expression can be represented, if it can be expressed as an
198    affine expression.  For loops (i, j) and parameters (m, n) all
199    affine expressions are of the form:
200
201    x1 * i + x2 * j + x3 * m + x4 * n + x5 * 1 where x1..x5 element of Z
202
203    1 i + 20 j + (-2) m + 25
204
205    Something like "i * n" or "n * m" is not allowed.
206
207    OUTERMOST_LOOP defines the outermost loop that can variate.  */
208
209 static bool
210 graphite_can_represent_scev (tree scev, int outermost_loop)
211 {
212   if (chrec_contains_undetermined (scev))
213     return false;
214
215   switch (TREE_CODE (scev))
216     {
217     case PLUS_EXPR:
218     case MINUS_EXPR:
219       return graphite_can_represent_scev (TREE_OPERAND (scev, 0), outermost_loop)
220         && graphite_can_represent_scev (TREE_OPERAND (scev, 1), outermost_loop);
221
222     case MULT_EXPR:
223       return !CONVERT_EXPR_CODE_P (TREE_CODE (TREE_OPERAND (scev, 0)))
224         && !CONVERT_EXPR_CODE_P (TREE_CODE (TREE_OPERAND (scev, 1)))
225         && !(chrec_contains_symbols (TREE_OPERAND (scev, 0))
226              && chrec_contains_symbols (TREE_OPERAND (scev, 1)))
227         && graphite_can_represent_init (scev)
228         && graphite_can_represent_scev (TREE_OPERAND (scev, 0), outermost_loop)
229         && graphite_can_represent_scev (TREE_OPERAND (scev, 1), outermost_loop);
230
231     case POLYNOMIAL_CHREC:
232       /* Check for constant strides.  With a non constant stride of
233          'n' we would have a value of 'iv * n'.  Also check that the
234          initial value can represented: for example 'n * m' cannot be
235          represented.  */
236       if (!evolution_function_right_is_integer_cst (scev)
237           || !graphite_can_represent_init (scev))
238         return false;
239
240     default:
241       break;
242     }
243
244   /* Only affine functions can be represented.  */
245   if (!scev_is_linear_expression (scev))
246     return false;
247
248   return true;
249 }
250
251
252 /* Return true when EXPR can be represented in the polyhedral model.
253
254    This means an expression can be represented, if it is linear with
255    respect to the loops and the strides are non parametric.
256    LOOP is the place where the expr will be evaluated and OUTERMOST_LOOP
257    defindes the outermost loop that can variate.  SCOP_ENTRY defines the
258    entry of the region we analyse.  */
259
260 static bool
261 graphite_can_represent_expr (basic_block scop_entry, loop_p loop,
262                              loop_p outermost_loop, tree expr)
263 {
264   tree scev = analyze_scalar_evolution (loop, expr);
265
266   scev = instantiate_scev (scop_entry, loop, scev);
267
268   return graphite_can_represent_scev (scev, outermost_loop->num);
269 }
270
271 /* Return true if the data references of STMT can be represented by
272    Graphite.  */
273
274 static bool
275 stmt_has_simple_data_refs_p (loop_p outermost_loop, gimple stmt)
276 {
277   data_reference_p dr;
278   unsigned i;
279   int j;
280   bool res = true;
281   int loop = outermost_loop->num;
282   VEC (data_reference_p, heap) *drs = VEC_alloc (data_reference_p, heap, 5);
283
284   graphite_find_data_references_in_stmt (outermost_loop, stmt, &drs);
285
286   FOR_EACH_VEC_ELT (data_reference_p, drs, j, dr)
287     for (i = 0; i < DR_NUM_DIMENSIONS (dr); i++)
288       if (!graphite_can_represent_scev (DR_ACCESS_FN (dr, i), loop))
289         {
290           res = false;
291           goto done;
292         }
293
294  done:
295   free_data_refs (drs);
296   return res;
297 }
298
299 /* Return true only when STMT is simple enough for being handled by
300    Graphite.  This depends on SCOP_ENTRY, as the parameters are
301    initialized relatively to this basic block, the linear functions
302    are initialized to OUTERMOST_LOOP and BB is the place where we try
303    to evaluate the STMT.  */
304
305 static bool
306 stmt_simple_for_scop_p (basic_block scop_entry, loop_p outermost_loop,
307                         gimple stmt, basic_block bb)
308 {
309   loop_p loop = bb->loop_father;
310
311   gcc_assert (scop_entry);
312
313   /* GIMPLE_ASM and GIMPLE_CALL may embed arbitrary side effects.
314      Calls have side-effects, except those to const or pure
315      functions.  */
316   if (gimple_has_volatile_ops (stmt)
317       || (gimple_code (stmt) == GIMPLE_CALL
318           && !(gimple_call_flags (stmt) & (ECF_CONST | ECF_PURE)))
319       || (gimple_code (stmt) == GIMPLE_ASM))
320     return false;
321
322   if (is_gimple_debug (stmt))
323     return true;
324
325   if (!stmt_has_simple_data_refs_p (outermost_loop, stmt))
326     return false;
327
328   switch (gimple_code (stmt))
329     {
330     case GIMPLE_RETURN:
331     case GIMPLE_LABEL:
332       return true;
333
334     case GIMPLE_COND:
335       {
336         tree op;
337         ssa_op_iter op_iter;
338         enum tree_code code = gimple_cond_code (stmt);
339
340         /* We can handle all binary comparisons.  Inequalities are
341            also supported as they can be represented with union of
342            polyhedra.  */
343         if (!(code == LT_EXPR
344               || code == GT_EXPR
345               || code == LE_EXPR
346               || code == GE_EXPR
347               || code == EQ_EXPR
348               || code == NE_EXPR))
349           return false;
350
351         FOR_EACH_SSA_TREE_OPERAND (op, stmt, op_iter, SSA_OP_ALL_USES)
352           if (!graphite_can_represent_expr (scop_entry, loop, outermost_loop,
353                                             op)
354               /* We can not handle REAL_TYPE. Failed for pr39260.  */
355               || TREE_CODE (TREE_TYPE (op)) == REAL_TYPE)
356             return false;
357
358         return true;
359       }
360
361     case GIMPLE_ASSIGN:
362     case GIMPLE_CALL:
363       return true;
364
365     default:
366       /* These nodes cut a new scope.  */
367       return false;
368     }
369
370   return false;
371 }
372
373 /* Returns the statement of BB that contains a harmful operation: that
374    can be a function call with side effects, the induction variables
375    are not linear with respect to SCOP_ENTRY, etc.  The current open
376    scop should end before this statement.  The evaluation is limited using
377    OUTERMOST_LOOP as outermost loop that may change.  */
378
379 static gimple
380 harmful_stmt_in_bb (basic_block scop_entry, loop_p outer_loop, basic_block bb)
381 {
382   gimple_stmt_iterator gsi;
383
384   for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
385     if (!stmt_simple_for_scop_p (scop_entry, outer_loop, gsi_stmt (gsi), bb))
386       return gsi_stmt (gsi);
387
388   return NULL;
389 }
390
391 /* Return true when it is not possible to represent LOOP in the
392    polyhedral representation.  This is evaluated taking SCOP_ENTRY and
393    OUTERMOST_LOOP in mind.  */
394
395 static bool
396 graphite_can_represent_loop (basic_block scop_entry, loop_p outermost_loop,
397                              loop_p loop)
398 {
399   tree niter = number_of_latch_executions (loop);
400
401   /* Number of iterations unknown.  */
402   if (chrec_contains_undetermined (niter))
403     return false;
404
405   /* Number of iterations not affine.  */
406   if (!graphite_can_represent_expr (scop_entry, loop, outermost_loop, niter))
407     return false;
408
409   return true;
410 }
411
412 /* Store information needed by scopdet_* functions.  */
413
414 struct scopdet_info
415 {
416   /* Exit of the open scop would stop if the current BB is harmful.  */
417   basic_block exit;
418
419   /* Where the next scop would start if the current BB is harmful.  */
420   basic_block next;
421
422   /* The bb or one of its children contains open loop exits.  That means
423      loop exit nodes that are not surrounded by a loop dominated by bb.  */
424   bool exits;
425
426   /* The bb or one of its children contains only structures we can handle.  */
427   bool difficult;
428 };
429
430 static struct scopdet_info build_scops_1 (basic_block, loop_p,
431                                           VEC (sd_region, heap) **, loop_p);
432
433 /* Calculates BB infos. If bb is difficult we add valid SCoPs dominated by BB
434    to SCOPS.  TYPE is the gbb_type of BB.  */
435
436 static struct scopdet_info
437 scopdet_basic_block_info (basic_block bb, loop_p outermost_loop,
438                           VEC (sd_region, heap) **scops, gbb_type type)
439 {
440   loop_p loop = bb->loop_father;
441   struct scopdet_info result;
442   gimple stmt;
443
444   /* XXX: ENTRY_BLOCK_PTR could be optimized in later steps.  */
445   basic_block entry_block = ENTRY_BLOCK_PTR;
446   stmt = harmful_stmt_in_bb (entry_block, outermost_loop, bb);
447   result.difficult = (stmt != NULL);
448   result.exit = NULL;
449
450   switch (type)
451     {
452     case GBB_LAST:
453       result.next = NULL;
454       result.exits = false;
455
456       /* Mark bbs terminating a SESE region difficult, if they start
457          a condition.  */
458       if (!single_succ_p (bb))
459         result.difficult = true;
460       else
461         result.exit = single_succ (bb);
462
463       break;
464
465     case GBB_SIMPLE:
466       result.next = single_succ (bb);
467       result.exits = false;
468       result.exit = single_succ (bb);
469       break;
470
471     case GBB_LOOP_SING_EXIT_HEADER:
472       {
473         VEC (sd_region, heap) *regions = VEC_alloc (sd_region, heap, 3);
474         struct scopdet_info sinfo;
475         edge exit_e = single_exit (loop);
476
477         sinfo = build_scops_1 (bb, outermost_loop, &regions, loop);
478
479         if (!graphite_can_represent_loop (entry_block, outermost_loop, loop))
480           result.difficult = true;
481
482         result.difficult |= sinfo.difficult;
483
484         /* Try again with another loop level.  */
485         if (result.difficult
486             && loop_depth (outermost_loop) + 1 == loop_depth (loop))
487           {
488             outermost_loop = loop;
489
490             VEC_free (sd_region, heap, regions);
491             regions = VEC_alloc (sd_region, heap, 3);
492
493             sinfo = scopdet_basic_block_info (bb, outermost_loop, scops, type);
494
495             result = sinfo;
496             result.difficult = true;
497
498             if (sinfo.difficult)
499               move_sd_regions (&regions, scops);
500             else
501               {
502                 sd_region open_scop;
503                 open_scop.entry = bb;
504                 open_scop.exit = exit_e->dest;
505                 VEC_safe_push (sd_region, heap, *scops, &open_scop);
506                 VEC_free (sd_region, heap, regions);
507               }
508           }
509         else
510           {
511             result.exit = exit_e->dest;
512             result.next = exit_e->dest;
513
514             /* If we do not dominate result.next, remove it.  It's either
515                the EXIT_BLOCK_PTR, or another bb dominates it and will
516                call the scop detection for this bb.  */
517             if (!dominated_by_p (CDI_DOMINATORS, result.next, bb))
518               result.next = NULL;
519
520             if (exit_e->src->loop_father != loop)
521               result.next = NULL;
522
523             result.exits = false;
524
525             if (result.difficult)
526               move_sd_regions (&regions, scops);
527             else
528               VEC_free (sd_region, heap, regions);
529           }
530
531         break;
532       }
533
534     case GBB_LOOP_MULT_EXIT_HEADER:
535       {
536         /* XXX: For now we just do not join loops with multiple exits.  If the
537            exits lead to the same bb it may be possible to join the loop.  */
538         VEC (sd_region, heap) *regions = VEC_alloc (sd_region, heap, 3);
539         VEC (edge, heap) *exits = get_loop_exit_edges (loop);
540         edge e;
541         int i;
542         build_scops_1 (bb, loop, &regions, loop);
543
544         /* Scan the code dominated by this loop.  This means all bbs, that are
545            are dominated by a bb in this loop, but are not part of this loop.
546
547            The easiest case:
548              - The loop exit destination is dominated by the exit sources.
549
550            TODO: We miss here the more complex cases:
551                   - The exit destinations are dominated by another bb inside
552                     the loop.
553                   - The loop dominates bbs, that are not exit destinations.  */
554         FOR_EACH_VEC_ELT (edge, exits, i, e)
555           if (e->src->loop_father == loop
556               && dominated_by_p (CDI_DOMINATORS, e->dest, e->src))
557             {
558               if (loop_outer (outermost_loop))
559                 outermost_loop = loop_outer (outermost_loop);
560
561               /* Pass loop_outer to recognize e->dest as loop header in
562                  build_scops_1.  */
563               if (e->dest->loop_father->header == e->dest)
564                 build_scops_1 (e->dest, outermost_loop, &regions,
565                                loop_outer (e->dest->loop_father));
566               else
567                 build_scops_1 (e->dest, outermost_loop, &regions,
568                                e->dest->loop_father);
569             }
570
571         result.next = NULL;
572         result.exit = NULL;
573         result.difficult = true;
574         result.exits = false;
575         move_sd_regions (&regions, scops);
576         VEC_free (edge, heap, exits);
577         break;
578       }
579     case GBB_COND_HEADER:
580       {
581         VEC (sd_region, heap) *regions = VEC_alloc (sd_region, heap, 3);
582         struct scopdet_info sinfo;
583         VEC (basic_block, heap) *dominated;
584         int i;
585         basic_block dom_bb;
586         basic_block last_exit = NULL;
587         edge e;
588         result.exits = false;
589
590         /* First check the successors of BB, and check if it is
591            possible to join the different branches.  */
592         FOR_EACH_VEC_ELT (edge, bb->succs, i, e)
593           {
594             /* Ignore loop exits.  They will be handled after the loop
595                body.  */
596             if (loop_exits_to_bb_p (loop, e->dest))
597               {
598                 result.exits = true;
599                 continue;
600               }
601
602             /* Do not follow edges that lead to the end of the
603                conditions block.  For example, in
604
605                |   0
606                |  /|\
607                | 1 2 |
608                | | | |
609                | 3 4 |
610                |  \|/
611                |   6
612
613                the edge from 0 => 6.  Only check if all paths lead to
614                the same node 6.  */
615
616             if (!single_pred_p (e->dest))
617               {
618                 /* Check, if edge leads directly to the end of this
619                    condition.  */
620                 if (!last_exit)
621                   last_exit = e->dest;
622
623                 if (e->dest != last_exit)
624                   result.difficult = true;
625
626                 continue;
627               }
628
629             if (!dominated_by_p (CDI_DOMINATORS, e->dest, bb))
630               {
631                 result.difficult = true;
632                 continue;
633               }
634
635             sinfo = build_scops_1 (e->dest, outermost_loop, &regions, loop);
636
637             result.exits |= sinfo.exits;
638             result.difficult |= sinfo.difficult;
639
640             /* Checks, if all branches end at the same point.
641                If that is true, the condition stays joinable.
642                Have a look at the example above.  */
643             if (sinfo.exit)
644               {
645                 if (!last_exit)
646                   last_exit = sinfo.exit;
647
648                 if (sinfo.exit != last_exit)
649                   result.difficult = true;
650               }
651             else
652               result.difficult = true;
653           }
654
655         if (!last_exit)
656           result.difficult = true;
657
658         /* Join the branches of the condition if possible.  */
659         if (!result.exits && !result.difficult)
660           {
661             /* Only return a next pointer if we dominate this pointer.
662                Otherwise it will be handled by the bb dominating it.  */
663             if (dominated_by_p (CDI_DOMINATORS, last_exit, bb)
664                 && last_exit != bb)
665               result.next = last_exit;
666             else
667               result.next = NULL;
668
669             result.exit = last_exit;
670
671             VEC_free (sd_region, heap, regions);
672             break;
673           }
674
675         /* Scan remaining bbs dominated by BB.  */
676         dominated = get_dominated_by (CDI_DOMINATORS, bb);
677
678         FOR_EACH_VEC_ELT (basic_block, dominated, i, dom_bb)
679           {
680             /* Ignore loop exits: they will be handled after the loop body.  */
681             if (loop_depth (find_common_loop (loop, dom_bb->loop_father))
682                 < loop_depth (loop))
683               {
684                 result.exits = true;
685                 continue;
686               }
687
688             /* Ignore the bbs processed above.  */
689             if (single_pred_p (dom_bb) && single_pred (dom_bb) == bb)
690               continue;
691
692             if (loop_depth (loop) > loop_depth (dom_bb->loop_father))
693               sinfo = build_scops_1 (dom_bb, outermost_loop, &regions,
694                                      loop_outer (loop));
695             else
696               sinfo = build_scops_1 (dom_bb, outermost_loop, &regions, loop);
697
698             result.exits |= sinfo.exits;
699             result.difficult = true;
700             result.exit = NULL;
701           }
702
703         VEC_free (basic_block, heap, dominated);
704
705         result.next = NULL;
706         move_sd_regions (&regions, scops);
707
708         break;
709       }
710
711     default:
712       gcc_unreachable ();
713     }
714
715   return result;
716 }
717
718 /* Starting from CURRENT we walk the dominance tree and add new sd_regions to
719    SCOPS. The analyse if a sd_region can be handled is based on the value
720    of OUTERMOST_LOOP. Only loops inside OUTERMOST loops may change.  LOOP
721    is the loop in which CURRENT is handled.
722
723    TODO: These functions got a little bit big. They definitely should be cleaned
724          up.  */
725
726 static struct scopdet_info
727 build_scops_1 (basic_block current, loop_p outermost_loop,
728                VEC (sd_region, heap) **scops, loop_p loop)
729 {
730   bool in_scop = false;
731   sd_region open_scop;
732   struct scopdet_info sinfo;
733
734   /* Initialize result.  */
735   struct scopdet_info result;
736   result.exits = false;
737   result.difficult = false;
738   result.next = NULL;
739   result.exit = NULL;
740   open_scop.entry = NULL;
741   open_scop.exit = NULL;
742   sinfo.exit = NULL;
743
744   /* Loop over the dominance tree.  If we meet a difficult bb, close
745      the current SCoP.  Loop and condition header start a new layer,
746      and can only be added if all bbs in deeper layers are simple.  */
747   while (current != NULL)
748     {
749       sinfo = scopdet_basic_block_info (current, outermost_loop, scops,
750                                         get_bb_type (current, loop));
751
752       if (!in_scop && !(sinfo.exits || sinfo.difficult))
753         {
754           open_scop.entry = current;
755           open_scop.exit = NULL;
756           in_scop = true;
757         }
758       else if (in_scop && (sinfo.exits || sinfo.difficult))
759         {
760           open_scop.exit = current;
761           VEC_safe_push (sd_region, heap, *scops, &open_scop);
762           in_scop = false;
763         }
764
765       result.difficult |= sinfo.difficult;
766       result.exits |= sinfo.exits;
767
768       current = sinfo.next;
769     }
770
771   /* Try to close open_scop, if we are still in an open SCoP.  */
772   if (in_scop)
773     {
774       open_scop.exit = sinfo.exit;
775       gcc_assert (open_scop.exit);
776       VEC_safe_push (sd_region, heap, *scops, &open_scop);
777     }
778
779   result.exit = sinfo.exit;
780   return result;
781 }
782
783 /* Checks if a bb is contained in REGION.  */
784
785 static bool
786 bb_in_sd_region (basic_block bb, sd_region *region)
787 {
788   return bb_in_region (bb, region->entry, region->exit);
789 }
790
791 /* Returns the single entry edge of REGION, if it does not exits NULL.  */
792
793 static edge
794 find_single_entry_edge (sd_region *region)
795 {
796   edge e;
797   edge_iterator ei;
798   edge entry = NULL;
799
800   FOR_EACH_EDGE (e, ei, region->entry->preds)
801     if (!bb_in_sd_region (e->src, region))
802       {
803         if (entry)
804           {
805             entry = NULL;
806             break;
807           }
808
809         else
810           entry = e;
811       }
812
813   return entry;
814 }
815
816 /* Returns the single exit edge of REGION, if it does not exits NULL.  */
817
818 static edge
819 find_single_exit_edge (sd_region *region)
820 {
821   edge e;
822   edge_iterator ei;
823   edge exit = NULL;
824
825   FOR_EACH_EDGE (e, ei, region->exit->preds)
826     if (bb_in_sd_region (e->src, region))
827       {
828         if (exit)
829           {
830             exit = NULL;
831             break;
832           }
833
834         else
835           exit = e;
836       }
837
838   return exit;
839 }
840
841 /* Create a single entry edge for REGION.  */
842
843 static void
844 create_single_entry_edge (sd_region *region)
845 {
846   if (find_single_entry_edge (region))
847     return;
848
849   /* There are multiple predecessors for bb_3
850
851   |  1  2
852   |  | /
853   |  |/
854   |  3  <- entry
855   |  |\
856   |  | |
857   |  4 ^
858   |  | |
859   |  |/
860   |  5
861
862   There are two edges (1->3, 2->3), that point from outside into the region,
863   and another one (5->3), a loop latch, lead to bb_3.
864
865   We split bb_3.
866
867   |  1  2
868   |  | /
869   |  |/
870   |3.0
871   |  |\     (3.0 -> 3.1) = single entry edge
872   |3.1 |        <- entry
873   |  | |
874   |  | |
875   |  4 ^
876   |  | |
877   |  |/
878   |  5
879
880   If the loop is part of the SCoP, we have to redirect the loop latches.
881
882   |  1  2
883   |  | /
884   |  |/
885   |3.0
886   |  |      (3.0 -> 3.1) = entry edge
887   |3.1          <- entry
888   |  |\
889   |  | |
890   |  4 ^
891   |  | |
892   |  |/
893   |  5  */
894
895   if (region->entry->loop_father->header != region->entry
896       || dominated_by_p (CDI_DOMINATORS,
897                          loop_latch_edge (region->entry->loop_father)->src,
898                          region->exit))
899     {
900       edge forwarder = split_block_after_labels (region->entry);
901       region->entry = forwarder->dest;
902     }
903   else
904     /* This case is never executed, as the loop headers seem always to have a
905        single edge pointing from outside into the loop.  */
906     gcc_unreachable ();
907
908 #ifdef ENABLE_CHECKING
909   gcc_assert (find_single_entry_edge (region));
910 #endif
911 }
912
913 /* Check if the sd_region, mentioned in EDGE, has no exit bb.  */
914
915 static bool
916 sd_region_without_exit (edge e)
917 {
918   sd_region *r = (sd_region *) e->aux;
919
920   if (r)
921     return r->exit == NULL;
922   else
923     return false;
924 }
925
926 /* Create a single exit edge for REGION.  */
927
928 static void
929 create_single_exit_edge (sd_region *region)
930 {
931   edge e;
932   edge_iterator ei;
933   edge forwarder = NULL;
934   basic_block exit;
935
936   /* We create a forwarder bb (5) for all edges leaving this region
937      (3->5, 4->5).  All other edges leading to the same bb, are moved
938      to a new bb (6).  If these edges where part of another region (2->5)
939      we update the region->exit pointer, of this region.
940
941      To identify which edge belongs to which region we depend on the e->aux
942      pointer in every edge.  It points to the region of the edge or to NULL,
943      if the edge is not part of any region.
944
945      1 2 3 4    1->5 no region,                 2->5 region->exit = 5,
946       \| |/     3->5 region->exit = NULL,       4->5 region->exit = NULL
947         5       <- exit
948
949      changes to
950
951      1 2 3 4    1->6 no region,                         2->6 region->exit = 6,
952      | | \/     3->5 no region,                         4->5 no region,
953      | |  5
954       \| /      5->6 region->exit = 6
955         6
956
957      Now there is only a single exit edge (5->6).  */
958   exit = region->exit;
959   region->exit = NULL;
960   forwarder = make_forwarder_block (exit, &sd_region_without_exit, NULL);
961
962   /* Unmark the edges, that are no longer exit edges.  */
963   FOR_EACH_EDGE (e, ei, forwarder->src->preds)
964     if (e->aux)
965       e->aux = NULL;
966
967   /* Mark the new exit edge.  */
968   single_succ_edge (forwarder->src)->aux = region;
969
970   /* Update the exit bb of all regions, where exit edges lead to
971      forwarder->dest.  */
972   FOR_EACH_EDGE (e, ei, forwarder->dest->preds)
973     if (e->aux)
974       ((sd_region *) e->aux)->exit = forwarder->dest;
975
976 #ifdef ENABLE_CHECKING
977   gcc_assert (find_single_exit_edge (region));
978 #endif
979 }
980
981 /* Unmark the exit edges of all REGIONS.
982    See comment in "create_single_exit_edge". */
983
984 static void
985 unmark_exit_edges (VEC (sd_region, heap) *regions)
986 {
987   int i;
988   sd_region *s;
989   edge e;
990   edge_iterator ei;
991
992   FOR_EACH_VEC_ELT (sd_region, regions, i, s)
993     FOR_EACH_EDGE (e, ei, s->exit->preds)
994       e->aux = NULL;
995 }
996
997
998 /* Mark the exit edges of all REGIONS.
999    See comment in "create_single_exit_edge". */
1000
1001 static void
1002 mark_exit_edges (VEC (sd_region, heap) *regions)
1003 {
1004   int i;
1005   sd_region *s;
1006   edge e;
1007   edge_iterator ei;
1008
1009   FOR_EACH_VEC_ELT (sd_region, regions, i, s)
1010     FOR_EACH_EDGE (e, ei, s->exit->preds)
1011       if (bb_in_sd_region (e->src, s))
1012         e->aux = s;
1013 }
1014
1015 /* Create for all scop regions a single entry and a single exit edge.  */
1016
1017 static void
1018 create_sese_edges (VEC (sd_region, heap) *regions)
1019 {
1020   int i;
1021   sd_region *s;
1022
1023   FOR_EACH_VEC_ELT (sd_region, regions, i, s)
1024     create_single_entry_edge (s);
1025
1026   mark_exit_edges (regions);
1027
1028   FOR_EACH_VEC_ELT (sd_region, regions, i, s)
1029     /* Don't handle multiple edges exiting the function.  */
1030     if (!find_single_exit_edge (s)
1031         && s->exit != EXIT_BLOCK_PTR)
1032       create_single_exit_edge (s);
1033
1034   unmark_exit_edges (regions);
1035
1036   fix_loop_structure (NULL);
1037
1038 #ifdef ENABLE_CHECKING
1039   verify_loop_structure ();
1040   verify_dominators (CDI_DOMINATORS);
1041   verify_ssa (false);
1042 #endif
1043 }
1044
1045 /* Create graphite SCoPs from an array of scop detection REGIONS.  */
1046
1047 static void
1048 build_graphite_scops (VEC (sd_region, heap) *regions,
1049                       VEC (scop_p, heap) **scops)
1050 {
1051   int i;
1052   sd_region *s;
1053
1054   FOR_EACH_VEC_ELT (sd_region, regions, i, s)
1055     {
1056       edge entry = find_single_entry_edge (s);
1057       edge exit = find_single_exit_edge (s);
1058       scop_p scop;
1059
1060       if (!exit)
1061         continue;
1062
1063       scop = new_scop (new_sese (entry, exit));
1064       VEC_safe_push (scop_p, heap, *scops, scop);
1065
1066       /* Are there overlapping SCoPs?  */
1067 #ifdef ENABLE_CHECKING
1068         {
1069           int j;
1070           sd_region *s2;
1071
1072           FOR_EACH_VEC_ELT (sd_region, regions, j, s2)
1073             if (s != s2)
1074               gcc_assert (!bb_in_sd_region (s->entry, s2));
1075         }
1076 #endif
1077     }
1078 }
1079
1080 /* Returns true when BB contains only close phi nodes.  */
1081
1082 static bool
1083 contains_only_close_phi_nodes (basic_block bb)
1084 {
1085   gimple_stmt_iterator gsi;
1086
1087   for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
1088     if (gimple_code (gsi_stmt (gsi)) != GIMPLE_LABEL)
1089       return false;
1090
1091   return true;
1092 }
1093
1094 /* Print statistics for SCOP to FILE.  */
1095
1096 static void
1097 print_graphite_scop_statistics (FILE* file, scop_p scop)
1098 {
1099   long n_bbs = 0;
1100   long n_loops = 0;
1101   long n_stmts = 0;
1102   long n_conditions = 0;
1103   long n_p_bbs = 0;
1104   long n_p_loops = 0;
1105   long n_p_stmts = 0;
1106   long n_p_conditions = 0;
1107
1108   basic_block bb;
1109
1110   FOR_ALL_BB (bb)
1111     {
1112       gimple_stmt_iterator psi;
1113       loop_p loop = bb->loop_father;
1114
1115       if (!bb_in_sese_p (bb, SCOP_REGION (scop)))
1116         continue;
1117
1118       n_bbs++;
1119       n_p_bbs += bb->count;
1120
1121       if (VEC_length (edge, bb->succs) > 1)
1122         {
1123           n_conditions++;
1124           n_p_conditions += bb->count;
1125         }
1126
1127       for (psi = gsi_start_bb (bb); !gsi_end_p (psi); gsi_next (&psi))
1128         {
1129           n_stmts++;
1130           n_p_stmts += bb->count;
1131         }
1132
1133       if (loop->header == bb && loop_in_sese_p (loop, SCOP_REGION (scop)))
1134         {
1135           n_loops++;
1136           n_p_loops += bb->count;
1137         }
1138
1139     }
1140
1141   fprintf (file, "\nBefore limit_scops SCoP statistics (");
1142   fprintf (file, "BBS:%ld, ", n_bbs);
1143   fprintf (file, "LOOPS:%ld, ", n_loops);
1144   fprintf (file, "CONDITIONS:%ld, ", n_conditions);
1145   fprintf (file, "STMTS:%ld)\n", n_stmts);
1146   fprintf (file, "\nBefore limit_scops SCoP profiling statistics (");
1147   fprintf (file, "BBS:%ld, ", n_p_bbs);
1148   fprintf (file, "LOOPS:%ld, ", n_p_loops);
1149   fprintf (file, "CONDITIONS:%ld, ", n_p_conditions);
1150   fprintf (file, "STMTS:%ld)\n", n_p_stmts);
1151 }
1152
1153 /* Print statistics for SCOPS to FILE.  */
1154
1155 static void
1156 print_graphite_statistics (FILE* file, VEC (scop_p, heap) *scops)
1157 {
1158   int i;
1159   scop_p scop;
1160
1161   FOR_EACH_VEC_ELT (scop_p, scops, i, scop)
1162     print_graphite_scop_statistics (file, scop);
1163 }
1164
1165 /* We limit all SCoPs to SCoPs, that are completely surrounded by a loop.
1166
1167    Example:
1168
1169    for (i      |
1170      {         |
1171        for (j  |  SCoP 1
1172        for (k  |
1173      }         |
1174
1175    * SCoP frontier, as this line is not surrounded by any loop. *
1176
1177    for (l      |  SCoP 2
1178
1179    This is necessary as scalar evolution and parameter detection need a
1180    outermost loop to initialize parameters correctly.
1181
1182    TODO: FIX scalar evolution and parameter detection to allow more flexible
1183          SCoP frontiers.  */
1184
1185 static void
1186 limit_scops (VEC (scop_p, heap) **scops)
1187 {
1188   VEC (sd_region, heap) *regions = VEC_alloc (sd_region, heap, 3);
1189
1190   int i;
1191   scop_p scop;
1192
1193   FOR_EACH_VEC_ELT (scop_p, *scops, i, scop)
1194     {
1195       int j;
1196       loop_p loop;
1197       sese region = SCOP_REGION (scop);
1198       build_sese_loop_nests (region);
1199
1200       FOR_EACH_VEC_ELT (loop_p, SESE_LOOP_NEST (region), j, loop)
1201         if (!loop_in_sese_p (loop_outer (loop), region)
1202             && single_exit (loop))
1203           {
1204             sd_region open_scop;
1205             open_scop.entry = loop->header;
1206             open_scop.exit = single_exit (loop)->dest;
1207
1208             /* This is a hack on top of the limit_scops hack.  The
1209                limit_scops hack should disappear all together.  */
1210             if (single_succ_p (open_scop.exit)
1211                 && contains_only_close_phi_nodes (open_scop.exit))
1212               open_scop.exit = single_succ_edge (open_scop.exit)->dest;
1213
1214             VEC_safe_push (sd_region, heap, regions, &open_scop);
1215           }
1216     }
1217
1218   free_scops (*scops);
1219   *scops = VEC_alloc (scop_p, heap, 3);
1220
1221   create_sese_edges (regions);
1222   build_graphite_scops (regions, scops);
1223   VEC_free (sd_region, heap, regions);
1224 }
1225
1226 /* Transforms LOOP to the canonical loop closed SSA form.  */
1227
1228 static void
1229 canonicalize_loop_closed_ssa (loop_p loop)
1230 {
1231   edge e = single_exit (loop);
1232   basic_block bb;
1233
1234   if (!e || e->flags & EDGE_ABNORMAL)
1235     return;
1236
1237   bb = e->dest;
1238
1239   if (VEC_length (edge, bb->preds) == 1)
1240     split_block_after_labels (bb);
1241   else
1242     {
1243       gimple_stmt_iterator psi;
1244       basic_block close = split_edge (e);
1245
1246       e = single_succ_edge (close);
1247
1248       for (psi = gsi_start_phis (bb); !gsi_end_p (psi); gsi_next (&psi))
1249         {
1250           gimple phi = gsi_stmt (psi);
1251           unsigned i;
1252
1253           for (i = 0; i < gimple_phi_num_args (phi); i++)
1254             if (gimple_phi_arg_edge (phi, i) == e)
1255               {
1256                 tree res, arg = gimple_phi_arg_def (phi, i);
1257                 use_operand_p use_p;
1258                 gimple close_phi;
1259
1260                 if (TREE_CODE (arg) != SSA_NAME)
1261                   continue;
1262
1263                 close_phi = create_phi_node (arg, close);
1264                 res = create_new_def_for (gimple_phi_result (close_phi),
1265                                           close_phi,
1266                                           gimple_phi_result_ptr (close_phi));
1267                 add_phi_arg (close_phi, arg,
1268                              gimple_phi_arg_edge (close_phi, 0),
1269                              UNKNOWN_LOCATION);
1270                 use_p = gimple_phi_arg_imm_use_ptr (phi, i);
1271                 replace_exp (use_p, res);
1272                 update_stmt (phi);
1273               }
1274         }
1275     }
1276 }
1277
1278 /* Converts the current loop closed SSA form to a canonical form
1279    expected by the Graphite code generation.
1280
1281    The loop closed SSA form has the following invariant: a variable
1282    defined in a loop that is used outside the loop appears only in the
1283    phi nodes in the destination of the loop exit.  These phi nodes are
1284    called close phi nodes.
1285
1286    The canonical loop closed SSA form contains the extra invariants:
1287
1288    - when the loop contains only one exit, the close phi nodes contain
1289    only one argument.  That implies that the basic block that contains
1290    the close phi nodes has only one predecessor, that is a basic block
1291    in the loop.
1292
1293    - the basic block containing the close phi nodes does not contain
1294    other statements.
1295 */
1296
1297 static void
1298 canonicalize_loop_closed_ssa_form (void)
1299 {
1300   loop_iterator li;
1301   loop_p loop;
1302
1303 #ifdef ENABLE_CHECKING
1304   verify_loop_closed_ssa (true);
1305 #endif
1306
1307   FOR_EACH_LOOP (li, loop, 0)
1308     canonicalize_loop_closed_ssa (loop);
1309
1310   rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa);
1311   update_ssa (TODO_update_ssa);
1312
1313 #ifdef ENABLE_CHECKING
1314   verify_loop_closed_ssa (true);
1315 #endif
1316 }
1317
1318 /* Find Static Control Parts (SCoP) in the current function and pushes
1319    them to SCOPS.  */
1320
1321 void
1322 build_scops (VEC (scop_p, heap) **scops)
1323 {
1324   struct loop *loop = current_loops->tree_root;
1325   VEC (sd_region, heap) *regions = VEC_alloc (sd_region, heap, 3);
1326
1327   canonicalize_loop_closed_ssa_form ();
1328   build_scops_1 (single_succ (ENTRY_BLOCK_PTR), ENTRY_BLOCK_PTR->loop_father,
1329                  &regions, loop);
1330   create_sese_edges (regions);
1331   build_graphite_scops (regions, scops);
1332
1333   if (dump_file && (dump_flags & TDF_DETAILS))
1334     print_graphite_statistics (dump_file, *scops);
1335
1336   limit_scops (scops);
1337   VEC_free (sd_region, heap, regions);
1338
1339   if (dump_file && (dump_flags & TDF_DETAILS))
1340     fprintf (dump_file, "\nnumber of SCoPs: %d\n",
1341              VEC_length (scop_p, *scops));
1342 }
1343
1344 /* Pretty print to FILE all the SCoPs in DOT format and mark them with
1345    different colors.  If there are not enough colors, paint the
1346    remaining SCoPs in gray.
1347
1348    Special nodes:
1349    - "*" after the node number denotes the entry of a SCoP,
1350    - "#" after the node number denotes the exit of a SCoP,
1351    - "()" around the node number denotes the entry or the
1352      exit nodes of the SCOP.  These are not part of SCoP.  */
1353
1354 static void
1355 dot_all_scops_1 (FILE *file, VEC (scop_p, heap) *scops)
1356 {
1357   basic_block bb;
1358   edge e;
1359   edge_iterator ei;
1360   scop_p scop;
1361   const char* color;
1362   int i;
1363
1364   /* Disable debugging while printing graph.  */
1365   int tmp_dump_flags = dump_flags;
1366   dump_flags = 0;
1367
1368   fprintf (file, "digraph all {\n");
1369
1370   FOR_ALL_BB (bb)
1371     {
1372       int part_of_scop = false;
1373
1374       /* Use HTML for every bb label.  So we are able to print bbs
1375          which are part of two different SCoPs, with two different
1376          background colors.  */
1377       fprintf (file, "%d [label=<\n  <TABLE BORDER=\"0\" CELLBORDER=\"1\" ",
1378                      bb->index);
1379       fprintf (file, "CELLSPACING=\"0\">\n");
1380
1381       /* Select color for SCoP.  */
1382       FOR_EACH_VEC_ELT (scop_p, scops, i, scop)
1383         {
1384           sese region = SCOP_REGION (scop);
1385           if (bb_in_sese_p (bb, region)
1386               || (SESE_EXIT_BB (region) == bb)
1387               || (SESE_ENTRY_BB (region) == bb))
1388             {
1389               switch (i % 17)
1390                 {
1391                 case 0: /* red */
1392                   color = "#e41a1c";
1393                   break;
1394                 case 1: /* blue */
1395                   color = "#377eb8";
1396                   break;
1397                 case 2: /* green */
1398                   color = "#4daf4a";
1399                   break;
1400                 case 3: /* purple */
1401                   color = "#984ea3";
1402                   break;
1403                 case 4: /* orange */
1404                   color = "#ff7f00";
1405                   break;
1406                 case 5: /* yellow */
1407                   color = "#ffff33";
1408                   break;
1409                 case 6: /* brown */
1410                   color = "#a65628";
1411                   break;
1412                 case 7: /* rose */
1413                   color = "#f781bf";
1414                   break;
1415                 case 8:
1416                   color = "#8dd3c7";
1417                   break;
1418                 case 9:
1419                   color = "#ffffb3";
1420                   break;
1421                 case 10:
1422                   color = "#bebada";
1423                   break;
1424                 case 11:
1425                   color = "#fb8072";
1426                   break;
1427                 case 12:
1428                   color = "#80b1d3";
1429                   break;
1430                 case 13:
1431                   color = "#fdb462";
1432                   break;
1433                 case 14:
1434                   color = "#b3de69";
1435                   break;
1436                 case 15:
1437                   color = "#fccde5";
1438                   break;
1439                 case 16:
1440                   color = "#bc80bd";
1441                   break;
1442                 default: /* gray */
1443                   color = "#999999";
1444                 }
1445
1446               fprintf (file, "    <TR><TD WIDTH=\"50\" BGCOLOR=\"%s\">", color);
1447
1448               if (!bb_in_sese_p (bb, region))
1449                 fprintf (file, " (");
1450
1451               if (bb == SESE_ENTRY_BB (region)
1452                   && bb == SESE_EXIT_BB (region))
1453                 fprintf (file, " %d*# ", bb->index);
1454               else if (bb == SESE_ENTRY_BB (region))
1455                 fprintf (file, " %d* ", bb->index);
1456               else if (bb == SESE_EXIT_BB (region))
1457                 fprintf (file, " %d# ", bb->index);
1458               else
1459                 fprintf (file, " %d ", bb->index);
1460
1461               if (!bb_in_sese_p (bb,region))
1462                 fprintf (file, ")");
1463
1464               fprintf (file, "</TD></TR>\n");
1465               part_of_scop  = true;
1466             }
1467         }
1468
1469       if (!part_of_scop)
1470         {
1471           fprintf (file, "    <TR><TD WIDTH=\"50\" BGCOLOR=\"#ffffff\">");
1472           fprintf (file, " %d </TD></TR>\n", bb->index);
1473         }
1474       fprintf (file, "  </TABLE>>, shape=box, style=\"setlinewidth(0)\"]\n");
1475     }
1476
1477   FOR_ALL_BB (bb)
1478     {
1479       FOR_EACH_EDGE (e, ei, bb->succs)
1480               fprintf (file, "%d -> %d;\n", bb->index, e->dest->index);
1481     }
1482
1483   fputs ("}\n\n", file);
1484
1485   /* Enable debugging again.  */
1486   dump_flags = tmp_dump_flags;
1487 }
1488
1489 /* Display all SCoPs using dotty.  */
1490
1491 DEBUG_FUNCTION void
1492 dot_all_scops (VEC (scop_p, heap) *scops)
1493 {
1494   /* When debugging, enable the following code.  This cannot be used
1495      in production compilers because it calls "system".  */
1496 #if 0
1497   int x;
1498   FILE *stream = fopen ("/tmp/allscops.dot", "w");
1499   gcc_assert (stream);
1500
1501   dot_all_scops_1 (stream, scops);
1502   fclose (stream);
1503
1504   x = system ("dotty /tmp/allscops.dot &");
1505 #else
1506   dot_all_scops_1 (stderr, scops);
1507 #endif
1508 }
1509
1510 /* Display all SCoPs using dotty.  */
1511
1512 DEBUG_FUNCTION void
1513 dot_scop (scop_p scop)
1514 {
1515   VEC (scop_p, heap) *scops = NULL;
1516
1517   if (scop)
1518     VEC_safe_push (scop_p, heap, scops, scop);
1519
1520   /* When debugging, enable the following code.  This cannot be used
1521      in production compilers because it calls "system".  */
1522 #if 0
1523   {
1524     int x;
1525     FILE *stream = fopen ("/tmp/allscops.dot", "w");
1526     gcc_assert (stream);
1527
1528     dot_all_scops_1 (stream, scops);
1529     fclose (stream);
1530     x = system ("dotty /tmp/allscops.dot &");
1531   }
1532 #else
1533   dot_all_scops_1 (stderr, scops);
1534 #endif
1535
1536   VEC_free (scop_p, heap, scops);
1537 }
1538
1539 #endif