]> gcc.gnu.org Git - gcc.git/blame - gcc/loop-init.c
invoke.texi: Apply missed hunk from 2004-03-03 change.
[gcc.git] / gcc / loop-init.c
CommitLineData
617b465c 1/* Loop optimizer initialization routines.
aa335b76 2 Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
617b465c
ZD
3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
8Software Foundation; either version 2, or (at your option) any later
9version.
10
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
15
16You should have received a copy of the GNU General Public License
17along with GCC; see the file COPYING. If not, write to the Free
18Software Foundation, 59 Temple Place - Suite 330, Boston, MA
1902111-1307, USA. */
20
21#include "config.h"
22#include "system.h"
23#include "coretypes.h"
24#include "tm.h"
25#include "rtl.h"
26#include "hard-reg-set.h"
27#include "basic-block.h"
28#include "cfgloop.h"
29#include "cfglayout.h"
617b465c
ZD
30
31/* Initialize loop optimizer. */
32
33struct loops *
0c20a65f 34loop_optimizer_init (FILE *dumpfile)
617b465c
ZD
35{
36 struct loops *loops = xcalloc (1, sizeof (struct loops));
37 edge e;
38
39 /* Avoid annoying special cases of edges going to exit
40 block. */
41 for (e = EXIT_BLOCK_PTR->pred; e; e = e->pred_next)
42 if ((e->flags & EDGE_FALLTHRU) && e->src->succ->succ_next)
43 split_edge (e);
44
45 /* Find the loops. */
46
47 if (flow_loops_find (loops, LOOP_TREE) <= 1)
48 {
49 /* No loops. */
50 flow_loops_free (loops);
d47cc544 51 free_dominance_info (CDI_DOMINATORS);
617b465c 52 free (loops);
d47cc544 53
617b465c
ZD
54 return NULL;
55 }
56
57 /* Not going to update these. */
58 free (loops->cfg.rc_order);
59 loops->cfg.rc_order = NULL;
60 free (loops->cfg.dfs_order);
61 loops->cfg.dfs_order = NULL;
62
617b465c 63 /* Create pre-headers. */
bc35512f 64 create_preheaders (loops, CP_SIMPLE_PREHEADERS);
617b465c
ZD
65
66 /* Force all latches to have only single successor. */
67 force_single_succ_latches (loops);
68
69 /* Mark irreducible loops. */
70 mark_irreducible_loops (loops);
71
72 /* Dump loops. */
73 flow_loops_dump (loops, dumpfile, NULL, 1);
74
75#ifdef ENABLE_CHECKING
d47cc544 76 verify_dominators (CDI_DOMINATORS);
617b465c
ZD
77 verify_loop_structure (loops);
78#endif
79
80 return loops;
81}
82
83/* Finalize loop optimizer. */
84void
0c20a65f 85loop_optimizer_finalize (struct loops *loops, FILE *dumpfile)
617b465c 86{
50654f6c 87 unsigned i;
617b465c 88
50654f6c
ZD
89 if (!loops)
90 return;
91
92 for (i = 1; i < loops->num; i++)
93 if (loops->parray[i])
94 free_simple_loop_desc (loops->parray[i]);
617b465c
ZD
95
96 /* Another dump. */
97 flow_loops_dump (loops, dumpfile, NULL, 1);
98
99 /* Clean up. */
100 flow_loops_free (loops);
d47cc544 101 free_dominance_info (CDI_DOMINATORS);
617b465c 102 free (loops);
0c20a65f 103
617b465c
ZD
104 /* Checking. */
105#ifdef ENABLE_CHECKING
106 verify_flow_info ();
107#endif
108}
This page took 0.439612 seconds and 5 git commands to generate.