1 /* Loop optimizer initialization routines.
2 Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING. If not, write to the Free
18 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 #include "coretypes.h"
26 #include "hard-reg-set.h"
27 #include "basic-block.h"
29 #include "cfglayout.h"
31 /* Initialize loop optimizer. */
34 loop_optimizer_init (FILE *dumpfile
)
36 struct loops
*loops
= xcalloc (1, sizeof (struct loops
));
39 /* Avoid annoying special cases of edges going to exit
41 for (e
= EXIT_BLOCK_PTR
->pred
; e
; e
= e
->pred_next
)
42 if ((e
->flags
& EDGE_FALLTHRU
) && e
->src
->succ
->succ_next
)
47 if (flow_loops_find (loops
, LOOP_TREE
) <= 1)
50 flow_loops_free (loops
);
51 free_dominance_info (CDI_DOMINATORS
);
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
;
63 /* Create pre-headers. */
64 create_preheaders (loops
, CP_SIMPLE_PREHEADERS
);
66 /* Force all latches to have only single successor. */
67 force_single_succ_latches (loops
);
69 /* Mark irreducible loops. */
70 mark_irreducible_loops (loops
);
73 flow_loops_dump (loops
, dumpfile
, NULL
, 1);
75 #ifdef ENABLE_CHECKING
76 verify_dominators (CDI_DOMINATORS
);
77 verify_loop_structure (loops
);
83 /* Finalize loop optimizer. */
85 loop_optimizer_finalize (struct loops
*loops
, FILE *dumpfile
)
92 for (i
= 1; i
< loops
->num
; i
++)
94 free_simple_loop_desc (loops
->parray
[i
]);
97 flow_loops_dump (loops
, dumpfile
, NULL
, 1);
100 flow_loops_free (loops
);
101 free_dominance_info (CDI_DOMINATORS
);
105 #ifdef ENABLE_CHECKING