annotate gcc/graphite.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /* Gimple Represented as Polyhedra.
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2 Copyright (C) 2006-2018 Free Software Foundation, Inc.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 Contributed by Sebastian Pop <sebastian.pop@inria.fr>.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 This file is part of GCC.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 GCC is free software; you can redistribute it and/or modify
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 it under the terms of the GNU General Public License as published by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 the Free Software Foundation; either version 3, or (at your option)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 any later version.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 GCC is distributed in the hope that it will be useful,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 GNU General Public License for more details.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 along with GCC; see the file COPYING3. If not see
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 /* This pass converts GIMPLE to GRAPHITE, performs some loop
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 transformations and then converts the resulting representation back
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
23 to GIMPLE.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 An early description of this pass can be found in the GCC Summit'06
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 paper "GRAPHITE: Polyhedral Analyses and Optimizations for GCC".
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 The wiki page http://gcc.gnu.org/wiki/Graphite contains pointers to
111
kono
parents: 67
diff changeset
28 the related work. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29
111
kono
parents: 67
diff changeset
30 #define USES_ISL
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 #include "config.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 #include "system.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 #include "coretypes.h"
111
kono
parents: 67
diff changeset
35 #include "backend.h"
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
36 #include "diagnostic-core.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 #include "cfgloop.h"
111
kono
parents: 67
diff changeset
38 #include "tree-pass.h"
kono
parents: 67
diff changeset
39 #include "params.h"
kono
parents: 67
diff changeset
40 #include "pretty-print.h"
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
41 #include "cfganal.h"
111
kono
parents: 67
diff changeset
42
kono
parents: 67
diff changeset
43 #ifdef HAVE_isl
kono
parents: 67
diff changeset
44 #include "cfghooks.h"
kono
parents: 67
diff changeset
45 #include "tree.h"
kono
parents: 67
diff changeset
46 #include "gimple.h"
kono
parents: 67
diff changeset
47 #include "ssa.h"
kono
parents: 67
diff changeset
48 #include "fold-const.h"
kono
parents: 67
diff changeset
49 #include "gimple-iterator.h"
kono
parents: 67
diff changeset
50 #include "tree-cfg.h"
kono
parents: 67
diff changeset
51 #include "tree-ssa-loop.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 #include "tree-data-ref.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 #include "tree-scalar-evolution.h"
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
54 #include "dbgcnt.h"
111
kono
parents: 67
diff changeset
55 #include "tree-parloops.h"
kono
parents: 67
diff changeset
56 #include "tree-cfgcleanup.h"
kono
parents: 67
diff changeset
57 #include "tree-vectorizer.h"
kono
parents: 67
diff changeset
58 #include "tree-ssa-loop-manip.h"
kono
parents: 67
diff changeset
59 #include "tree-ssa.h"
kono
parents: 67
diff changeset
60 #include "tree-into-ssa.h"
kono
parents: 67
diff changeset
61 #include "graphite.h"
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
62
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
63 /* Print global statistics to FILE. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 static void
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
66 print_global_statistics (FILE* file)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 {
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
68 long n_bbs = 0;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
69 long n_loops = 0;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
70 long n_stmts = 0;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
71 long n_conditions = 0;
111
kono
parents: 67
diff changeset
72 profile_count n_p_bbs = profile_count::zero ();
kono
parents: 67
diff changeset
73 profile_count n_p_loops = profile_count::zero ();
kono
parents: 67
diff changeset
74 profile_count n_p_stmts = profile_count::zero ();
kono
parents: 67
diff changeset
75 profile_count n_p_conditions = profile_count::zero ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
77 basic_block bb;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78
111
kono
parents: 67
diff changeset
79 FOR_ALL_BB_FN (bb, cfun)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 {
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
81 gimple_stmt_iterator psi;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
83 n_bbs++;
111
kono
parents: 67
diff changeset
84 if (bb->count.initialized_p ())
kono
parents: 67
diff changeset
85 n_p_bbs += bb->count;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
87 /* Ignore artificial surrounding loop. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
88 if (bb == bb->loop_father->header
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
89 && bb->index != 0)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
90 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
91 n_loops++;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
92 n_p_loops += bb->count;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
93 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
94
111
kono
parents: 67
diff changeset
95 if (EDGE_COUNT (bb->succs) > 1)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
96 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
97 n_conditions++;
111
kono
parents: 67
diff changeset
98 if (bb->count.initialized_p ())
kono
parents: 67
diff changeset
99 n_p_conditions += bb->count;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
100 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
102 for (psi = gsi_start_bb (bb); !gsi_end_p (psi); gsi_next (&psi))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 {
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
104 n_stmts++;
111
kono
parents: 67
diff changeset
105 if (bb->count.initialized_p ())
kono
parents: 67
diff changeset
106 n_p_stmts += bb->count;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
109
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
110 fprintf (file, "\nGlobal statistics (");
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
111 fprintf (file, "BBS:%ld, ", n_bbs);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
112 fprintf (file, "LOOPS:%ld, ", n_loops);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
113 fprintf (file, "CONDITIONS:%ld, ", n_conditions);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
114 fprintf (file, "STMTS:%ld)\n", n_stmts);
111
kono
parents: 67
diff changeset
115 fprintf (file, "Global profiling statistics (");
kono
parents: 67
diff changeset
116 fprintf (file, "BBS:");
kono
parents: 67
diff changeset
117 n_p_bbs.dump (file);
kono
parents: 67
diff changeset
118 fprintf (file, ", LOOPS:");
kono
parents: 67
diff changeset
119 n_p_loops.dump (file);
kono
parents: 67
diff changeset
120 fprintf (file, ", CONDITIONS:");
kono
parents: 67
diff changeset
121 n_p_conditions.dump (file);
kono
parents: 67
diff changeset
122 fprintf (file, ", STMTS:");
kono
parents: 67
diff changeset
123 n_p_stmts.dump (file);
kono
parents: 67
diff changeset
124 fprintf (file, ")\n\n");
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
126
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
127 /* Print statistics for SCOP to FILE. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
128
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
129 static void
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
130 print_graphite_scop_statistics (FILE* file, scop_p scop)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 {
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
132 long n_bbs = 0;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
133 long n_loops = 0;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
134 long n_stmts = 0;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
135 long n_conditions = 0;
111
kono
parents: 67
diff changeset
136 profile_count n_p_bbs = profile_count::zero ();
kono
parents: 67
diff changeset
137 profile_count n_p_loops = profile_count::zero ();
kono
parents: 67
diff changeset
138 profile_count n_p_stmts = profile_count::zero ();
kono
parents: 67
diff changeset
139 profile_count n_p_conditions = profile_count::zero ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
140
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 basic_block bb;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
142
111
kono
parents: 67
diff changeset
143 FOR_ALL_BB_FN (bb, cfun)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 {
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
145 gimple_stmt_iterator psi;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
146 loop_p loop = bb->loop_father;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
147
111
kono
parents: 67
diff changeset
148 if (!bb_in_sese_p (bb, scop->scop_info->region))
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
149 continue;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
150
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
151 n_bbs++;
111
kono
parents: 67
diff changeset
152 if (bb->count.initialized_p ())
kono
parents: 67
diff changeset
153 n_p_bbs += bb->count;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
154
111
kono
parents: 67
diff changeset
155 if (EDGE_COUNT (bb->succs) > 1)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
156 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
157 n_conditions++;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
158 n_p_conditions += bb->count;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
159 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
160
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
161 for (psi = gsi_start_bb (bb); !gsi_end_p (psi); gsi_next (&psi))
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
162 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
163 n_stmts++;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
164 n_p_stmts += bb->count;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
165 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
166
111
kono
parents: 67
diff changeset
167 if (loop->header == bb && loop_in_sese_p (loop, scop->scop_info->region))
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
168 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
169 n_loops++;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
170 n_p_loops += bb->count;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
171 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
172 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
173
111
kono
parents: 67
diff changeset
174 fprintf (file, "\nFunction Name: %s\n", current_function_name ());
kono
parents: 67
diff changeset
175
kono
parents: 67
diff changeset
176 edge scop_begin = scop->scop_info->region.entry;
kono
parents: 67
diff changeset
177 edge scop_end = scop->scop_info->region.exit;
kono
parents: 67
diff changeset
178
kono
parents: 67
diff changeset
179 fprintf (file, "\nSCoP (entry_edge (bb_%d, bb_%d), ",
kono
parents: 67
diff changeset
180 scop_begin->src->index, scop_begin->dest->index);
kono
parents: 67
diff changeset
181 fprintf (file, "exit_edge (bb_%d, bb_%d))",
kono
parents: 67
diff changeset
182 scop_end->src->index, scop_end->dest->index);
kono
parents: 67
diff changeset
183
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
184 fprintf (file, "\nSCoP statistics (");
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
185 fprintf (file, "BBS:%ld, ", n_bbs);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
186 fprintf (file, "LOOPS:%ld, ", n_loops);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
187 fprintf (file, "CONDITIONS:%ld, ", n_conditions);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
188 fprintf (file, "STMTS:%ld)\n", n_stmts);
111
kono
parents: 67
diff changeset
189 fprintf (file, "SCoP profiling statistics (");
kono
parents: 67
diff changeset
190 fprintf (file, "BBS:");
kono
parents: 67
diff changeset
191 n_p_bbs.dump (file);
kono
parents: 67
diff changeset
192 fprintf (file, ", LOOPS:");
kono
parents: 67
diff changeset
193 n_p_loops.dump (file);
kono
parents: 67
diff changeset
194 fprintf (file, ", CONDITIONS:");
kono
parents: 67
diff changeset
195 n_p_conditions.dump (file);
kono
parents: 67
diff changeset
196 fprintf (file, ", STMTS:");
kono
parents: 67
diff changeset
197 n_p_stmts.dump (file);
kono
parents: 67
diff changeset
198 fprintf (file, ")\n\n");
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
199 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
200
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
201 /* Print statistics for SCOPS to FILE. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
202
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
203 static void
111
kono
parents: 67
diff changeset
204 print_graphite_statistics (FILE* file, vec<scop_p> scops)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
205 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
206 int i;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
207 scop_p scop;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
208
111
kono
parents: 67
diff changeset
209 FOR_EACH_VEC_ELT (scops, i, scop)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
210 print_graphite_scop_statistics (file, scop);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
211 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
212
111
kono
parents: 67
diff changeset
213 /* Deletes all scops in SCOPS. */
kono
parents: 67
diff changeset
214
kono
parents: 67
diff changeset
215 static void
kono
parents: 67
diff changeset
216 free_scops (vec<scop_p> scops)
kono
parents: 67
diff changeset
217 {
kono
parents: 67
diff changeset
218 int i;
kono
parents: 67
diff changeset
219 scop_p scop;
kono
parents: 67
diff changeset
220
kono
parents: 67
diff changeset
221 FOR_EACH_VEC_ELT (scops, i, scop)
kono
parents: 67
diff changeset
222 free_scop (scop);
kono
parents: 67
diff changeset
223
kono
parents: 67
diff changeset
224 scops.release ();
kono
parents: 67
diff changeset
225 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
226
111
kono
parents: 67
diff changeset
227 /* Transforms LOOP to the canonical loop closed SSA form. */
kono
parents: 67
diff changeset
228
kono
parents: 67
diff changeset
229 static void
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
230 canonicalize_loop_closed_ssa (loop_p loop, edge e)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
231 {
111
kono
parents: 67
diff changeset
232 basic_block bb;
kono
parents: 67
diff changeset
233 gphi_iterator psi;
kono
parents: 67
diff changeset
234
kono
parents: 67
diff changeset
235 bb = e->dest;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
236
111
kono
parents: 67
diff changeset
237 /* Make the loop-close PHI node BB contain only PHIs and have a
kono
parents: 67
diff changeset
238 single predecessor. */
kono
parents: 67
diff changeset
239 if (single_pred_p (bb))
kono
parents: 67
diff changeset
240 {
kono
parents: 67
diff changeset
241 e = split_block_after_labels (bb);
kono
parents: 67
diff changeset
242 bb = e->src;
kono
parents: 67
diff changeset
243 }
kono
parents: 67
diff changeset
244 else
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 {
111
kono
parents: 67
diff changeset
246 basic_block close = split_edge (e);
kono
parents: 67
diff changeset
247 e = single_succ_edge (close);
kono
parents: 67
diff changeset
248 for (psi = gsi_start_phis (bb); !gsi_end_p (psi); gsi_next (&psi))
kono
parents: 67
diff changeset
249 {
kono
parents: 67
diff changeset
250 gphi *phi = psi.phi ();
kono
parents: 67
diff changeset
251 use_operand_p use_p = PHI_ARG_DEF_PTR_FROM_EDGE (phi, e);
kono
parents: 67
diff changeset
252 tree arg = USE_FROM_PTR (use_p);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
253
111
kono
parents: 67
diff changeset
254 /* Only add close phi nodes for SSA_NAMEs defined in LOOP. */
kono
parents: 67
diff changeset
255 if (TREE_CODE (arg) != SSA_NAME
kono
parents: 67
diff changeset
256 || SSA_NAME_IS_DEFAULT_DEF (arg)
kono
parents: 67
diff changeset
257 || ! flow_bb_inside_loop_p (loop,
kono
parents: 67
diff changeset
258 gimple_bb (SSA_NAME_DEF_STMT (arg))))
kono
parents: 67
diff changeset
259 continue;
kono
parents: 67
diff changeset
260
kono
parents: 67
diff changeset
261 tree res = copy_ssa_name (arg);
kono
parents: 67
diff changeset
262 gphi *close_phi = create_phi_node (res, close);
kono
parents: 67
diff changeset
263 add_phi_arg (close_phi, arg, gimple_phi_arg_edge (close_phi, 0),
kono
parents: 67
diff changeset
264 UNKNOWN_LOCATION);
kono
parents: 67
diff changeset
265 SET_USE (use_p, res);
kono
parents: 67
diff changeset
266 }
kono
parents: 67
diff changeset
267 bb = close;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
268 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
269
111
kono
parents: 67
diff changeset
270 /* Eliminate duplicates. This relies on processing loops from
kono
parents: 67
diff changeset
271 innermost to outer. */
kono
parents: 67
diff changeset
272 for (psi = gsi_start_phis (bb); !gsi_end_p (psi); gsi_next (&psi))
kono
parents: 67
diff changeset
273 {
kono
parents: 67
diff changeset
274 gphi_iterator gsi = psi;
kono
parents: 67
diff changeset
275 gphi *phi = psi.phi ();
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
276
111
kono
parents: 67
diff changeset
277 /* At this point, PHI should be a close phi in normal form. */
kono
parents: 67
diff changeset
278 gcc_assert (gimple_phi_num_args (phi) == 1);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
279
111
kono
parents: 67
diff changeset
280 /* Iterate over the next phis and remove duplicates. */
kono
parents: 67
diff changeset
281 gsi_next (&gsi);
kono
parents: 67
diff changeset
282 while (!gsi_end_p (gsi))
kono
parents: 67
diff changeset
283 if (gimple_phi_arg_def (phi, 0) == gimple_phi_arg_def (gsi.phi (), 0))
kono
parents: 67
diff changeset
284 {
kono
parents: 67
diff changeset
285 replace_uses_by (gimple_phi_result (gsi.phi ()),
kono
parents: 67
diff changeset
286 gimple_phi_result (phi));
kono
parents: 67
diff changeset
287 remove_phi_node (&gsi, true);
kono
parents: 67
diff changeset
288 }
kono
parents: 67
diff changeset
289 else
kono
parents: 67
diff changeset
290 gsi_next (&gsi);
kono
parents: 67
diff changeset
291 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
292 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
293
111
kono
parents: 67
diff changeset
294 /* Converts the current loop closed SSA form to a canonical form
kono
parents: 67
diff changeset
295 expected by the Graphite code generation.
kono
parents: 67
diff changeset
296
kono
parents: 67
diff changeset
297 The loop closed SSA form has the following invariant: a variable
kono
parents: 67
diff changeset
298 defined in a loop that is used outside the loop appears only in the
kono
parents: 67
diff changeset
299 phi nodes in the destination of the loop exit. These phi nodes are
kono
parents: 67
diff changeset
300 called close phi nodes.
kono
parents: 67
diff changeset
301
kono
parents: 67
diff changeset
302 The canonical loop closed SSA form contains the extra invariants:
kono
parents: 67
diff changeset
303
kono
parents: 67
diff changeset
304 - when the loop contains only one exit, the close phi nodes contain
kono
parents: 67
diff changeset
305 only one argument. That implies that the basic block that contains
kono
parents: 67
diff changeset
306 the close phi nodes has only one predecessor, that is a basic block
kono
parents: 67
diff changeset
307 in the loop.
kono
parents: 67
diff changeset
308
kono
parents: 67
diff changeset
309 - the basic block containing the close phi nodes does not contain
kono
parents: 67
diff changeset
310 other statements.
kono
parents: 67
diff changeset
311
kono
parents: 67
diff changeset
312 - there exist only one phi node per definition in the loop.
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
313
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
314 In addition to that we also make sure that loop exit edges are
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
315 first in the successor edge vector. This is to make RPO order
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
316 as computed by pre_and_rev_post_order_compute be consistent with
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
317 what initial schedule generation expects.
111
kono
parents: 67
diff changeset
318 */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
319
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
320 static void
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
321 canonicalize_loop_form (void)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
322 {
111
kono
parents: 67
diff changeset
323 loop_p loop;
kono
parents: 67
diff changeset
324 FOR_EACH_LOOP (loop, LI_FROM_INNERMOST)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
325 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
326 edge e = single_exit (loop);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
327 if (!e || (e->flags & (EDGE_COMPLEX|EDGE_FAKE)))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
328 continue;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
329
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
330 canonicalize_loop_closed_ssa (loop, e);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
331
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
332 /* If the exit is not first in the edge vector make it so. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
333 if (e != EDGE_SUCC (e->src, 0))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
334 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
335 unsigned ei;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
336 for (ei = 0; EDGE_SUCC (e->src, ei) != e; ++ei)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
337 ;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
338 std::swap (EDGE_SUCC (e->src, ei), EDGE_SUCC (e->src, 0));
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
339 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
340 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
341
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
342 /* We can end up releasing duplicate exit PHIs and also introduce
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
343 additional copies so the cached information isn't correct anymore. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
344 scev_reset ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
345
111
kono
parents: 67
diff changeset
346 checking_verify_loop_closed_ssa (true);
kono
parents: 67
diff changeset
347 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
348
111
kono
parents: 67
diff changeset
349 isl_ctx *the_isl_ctx;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
350
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
351 /* Perform a set of linear transforms on the loops of the current
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
352 function. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
353
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
354 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
355 graphite_transform_loops (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
356 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
357 int i;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
358 scop_p scop;
111
kono
parents: 67
diff changeset
359 bool changed = false;
kono
parents: 67
diff changeset
360 vec<scop_p> scops = vNULL;
kono
parents: 67
diff changeset
361 isl_ctx *ctx;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
362
111
kono
parents: 67
diff changeset
363 /* If a function is parallel it was most probably already run through graphite
kono
parents: 67
diff changeset
364 once. No need to run again. */
kono
parents: 67
diff changeset
365 if (parallelized_function_p (cfun->decl))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
366 return;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
367
111
kono
parents: 67
diff changeset
368 calculate_dominance_info (CDI_DOMINATORS);
kono
parents: 67
diff changeset
369
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
370 /* We rely on post-dominators during merging of SESE regions so those
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
371 have to be meaningful. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
372 connect_infinite_loops_to_exit ();
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
373
111
kono
parents: 67
diff changeset
374 ctx = isl_ctx_alloc ();
kono
parents: 67
diff changeset
375 isl_options_set_on_error (ctx, ISL_ON_ERROR_ABORT);
kono
parents: 67
diff changeset
376 the_isl_ctx = ctx;
kono
parents: 67
diff changeset
377
kono
parents: 67
diff changeset
378 sort_sibling_loops (cfun);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
379 canonicalize_loop_form ();
111
kono
parents: 67
diff changeset
380
kono
parents: 67
diff changeset
381 /* Print the loop structure. */
kono
parents: 67
diff changeset
382 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents: 67
diff changeset
383 {
kono
parents: 67
diff changeset
384 print_loops (dump_file, 2);
kono
parents: 67
diff changeset
385 print_loops (dump_file, 3);
kono
parents: 67
diff changeset
386 }
kono
parents: 67
diff changeset
387
kono
parents: 67
diff changeset
388 calculate_dominance_info (CDI_POST_DOMINATORS);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
389 build_scops (&scops);
111
kono
parents: 67
diff changeset
390 free_dominance_info (CDI_POST_DOMINATORS);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
391
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
392 /* Remove the fake exits before transform given they are not reflected
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
393 in loop structures we end up verifying. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
394 remove_fake_exit_edges ();
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
395
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
396 if (dump_file && (dump_flags & TDF_DETAILS))
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
397 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
398 print_graphite_statistics (dump_file, scops);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
399 print_global_statistics (dump_file);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
400 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
401
111
kono
parents: 67
diff changeset
402 FOR_EACH_VEC_ELT (scops, i, scop)
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
403 if (dbg_cnt (graphite_scop))
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
404 {
111
kono
parents: 67
diff changeset
405 scop->isl_context = ctx;
kono
parents: 67
diff changeset
406 if (!build_poly_scop (scop))
kono
parents: 67
diff changeset
407 continue;
kono
parents: 67
diff changeset
408
kono
parents: 67
diff changeset
409 if (!apply_poly_transforms (scop))
kono
parents: 67
diff changeset
410 continue;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
411
111
kono
parents: 67
diff changeset
412 changed = true;
kono
parents: 67
diff changeset
413 if (graphite_regenerate_ast_isl (scop))
kono
parents: 67
diff changeset
414 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
415 dump_user_location_t loc = find_loop_location
111
kono
parents: 67
diff changeset
416 (scops[i]->scop_info->region.entry->dest->loop_father);
kono
parents: 67
diff changeset
417 dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
kono
parents: 67
diff changeset
418 "loop nest optimized\n");
kono
parents: 67
diff changeset
419 }
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
420 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
421
111
kono
parents: 67
diff changeset
422 if (changed)
kono
parents: 67
diff changeset
423 {
kono
parents: 67
diff changeset
424 mark_virtual_operands_for_renaming (cfun);
kono
parents: 67
diff changeset
425 update_ssa (TODO_update_ssa);
kono
parents: 67
diff changeset
426 checking_verify_ssa (true, true);
kono
parents: 67
diff changeset
427 rewrite_into_loop_closed_ssa (NULL, 0);
kono
parents: 67
diff changeset
428 scev_reset ();
kono
parents: 67
diff changeset
429 checking_verify_loop_structure ();
kono
parents: 67
diff changeset
430 }
kono
parents: 67
diff changeset
431
kono
parents: 67
diff changeset
432 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents: 67
diff changeset
433 {
kono
parents: 67
diff changeset
434 loop_p loop;
kono
parents: 67
diff changeset
435 int num_no_dependency = 0;
kono
parents: 67
diff changeset
436
kono
parents: 67
diff changeset
437 FOR_EACH_LOOP (loop, 0)
kono
parents: 67
diff changeset
438 if (loop->can_be_parallel)
kono
parents: 67
diff changeset
439 num_no_dependency++;
kono
parents: 67
diff changeset
440
kono
parents: 67
diff changeset
441 fprintf (dump_file, "%d loops carried no dependency.\n",
kono
parents: 67
diff changeset
442 num_no_dependency);
kono
parents: 67
diff changeset
443 }
kono
parents: 67
diff changeset
444
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
445 free_scops (scops);
111
kono
parents: 67
diff changeset
446 the_isl_ctx = NULL;
kono
parents: 67
diff changeset
447 isl_ctx_free (ctx);
kono
parents: 67
diff changeset
448
kono
parents: 67
diff changeset
449 if (changed)
kono
parents: 67
diff changeset
450 {
kono
parents: 67
diff changeset
451 cleanup_tree_cfg ();
kono
parents: 67
diff changeset
452 profile_status_for_fn (cfun) = PROFILE_ABSENT;
kono
parents: 67
diff changeset
453 release_recorded_exits (cfun);
kono
parents: 67
diff changeset
454 tree_estimate_probability (false);
kono
parents: 67
diff changeset
455 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
456 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
457
111
kono
parents: 67
diff changeset
458 #else /* If isl is not available: #ifndef HAVE_isl. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
459
111
kono
parents: 67
diff changeset
460 static void
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
461 graphite_transform_loops (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
462 {
111
kono
parents: 67
diff changeset
463 sorry ("Graphite loop optimizations cannot be used (isl is not available).");
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
464 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
465
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
466 #endif
111
kono
parents: 67
diff changeset
467
kono
parents: 67
diff changeset
468
kono
parents: 67
diff changeset
469 static unsigned int
kono
parents: 67
diff changeset
470 graphite_transforms (struct function *fun)
kono
parents: 67
diff changeset
471 {
kono
parents: 67
diff changeset
472 if (number_of_loops (fun) <= 1)
kono
parents: 67
diff changeset
473 return 0;
kono
parents: 67
diff changeset
474
kono
parents: 67
diff changeset
475 graphite_transform_loops ();
kono
parents: 67
diff changeset
476
kono
parents: 67
diff changeset
477 return 0;
kono
parents: 67
diff changeset
478 }
kono
parents: 67
diff changeset
479
kono
parents: 67
diff changeset
480 static bool
kono
parents: 67
diff changeset
481 gate_graphite_transforms (void)
kono
parents: 67
diff changeset
482 {
kono
parents: 67
diff changeset
483 /* Enable -fgraphite pass if any one of the graphite optimization flags
kono
parents: 67
diff changeset
484 is turned on. */
kono
parents: 67
diff changeset
485 if (flag_graphite_identity
kono
parents: 67
diff changeset
486 || flag_loop_parallelize_all
kono
parents: 67
diff changeset
487 || flag_loop_nest_optimize)
kono
parents: 67
diff changeset
488 flag_graphite = 1;
kono
parents: 67
diff changeset
489
kono
parents: 67
diff changeset
490 return flag_graphite != 0;
kono
parents: 67
diff changeset
491 }
kono
parents: 67
diff changeset
492
kono
parents: 67
diff changeset
493 namespace {
kono
parents: 67
diff changeset
494
kono
parents: 67
diff changeset
495 const pass_data pass_data_graphite =
kono
parents: 67
diff changeset
496 {
kono
parents: 67
diff changeset
497 GIMPLE_PASS, /* type */
kono
parents: 67
diff changeset
498 "graphite0", /* name */
kono
parents: 67
diff changeset
499 OPTGROUP_LOOP, /* optinfo_flags */
kono
parents: 67
diff changeset
500 TV_GRAPHITE, /* tv_id */
kono
parents: 67
diff changeset
501 ( PROP_cfg | PROP_ssa ), /* properties_required */
kono
parents: 67
diff changeset
502 0, /* properties_provided */
kono
parents: 67
diff changeset
503 0, /* properties_destroyed */
kono
parents: 67
diff changeset
504 0, /* todo_flags_start */
kono
parents: 67
diff changeset
505 0, /* todo_flags_finish */
kono
parents: 67
diff changeset
506 };
kono
parents: 67
diff changeset
507
kono
parents: 67
diff changeset
508 class pass_graphite : public gimple_opt_pass
kono
parents: 67
diff changeset
509 {
kono
parents: 67
diff changeset
510 public:
kono
parents: 67
diff changeset
511 pass_graphite (gcc::context *ctxt)
kono
parents: 67
diff changeset
512 : gimple_opt_pass (pass_data_graphite, ctxt)
kono
parents: 67
diff changeset
513 {}
kono
parents: 67
diff changeset
514
kono
parents: 67
diff changeset
515 /* opt_pass methods: */
kono
parents: 67
diff changeset
516 virtual bool gate (function *) { return gate_graphite_transforms (); }
kono
parents: 67
diff changeset
517
kono
parents: 67
diff changeset
518 }; // class pass_graphite
kono
parents: 67
diff changeset
519
kono
parents: 67
diff changeset
520 } // anon namespace
kono
parents: 67
diff changeset
521
kono
parents: 67
diff changeset
522 gimple_opt_pass *
kono
parents: 67
diff changeset
523 make_pass_graphite (gcc::context *ctxt)
kono
parents: 67
diff changeset
524 {
kono
parents: 67
diff changeset
525 return new pass_graphite (ctxt);
kono
parents: 67
diff changeset
526 }
kono
parents: 67
diff changeset
527
kono
parents: 67
diff changeset
528 namespace {
kono
parents: 67
diff changeset
529
kono
parents: 67
diff changeset
530 const pass_data pass_data_graphite_transforms =
kono
parents: 67
diff changeset
531 {
kono
parents: 67
diff changeset
532 GIMPLE_PASS, /* type */
kono
parents: 67
diff changeset
533 "graphite", /* name */
kono
parents: 67
diff changeset
534 OPTGROUP_LOOP, /* optinfo_flags */
kono
parents: 67
diff changeset
535 TV_GRAPHITE_TRANSFORMS, /* tv_id */
kono
parents: 67
diff changeset
536 ( PROP_cfg | PROP_ssa ), /* properties_required */
kono
parents: 67
diff changeset
537 0, /* properties_provided */
kono
parents: 67
diff changeset
538 0, /* properties_destroyed */
kono
parents: 67
diff changeset
539 0, /* todo_flags_start */
kono
parents: 67
diff changeset
540 0, /* todo_flags_finish */
kono
parents: 67
diff changeset
541 };
kono
parents: 67
diff changeset
542
kono
parents: 67
diff changeset
543 class pass_graphite_transforms : public gimple_opt_pass
kono
parents: 67
diff changeset
544 {
kono
parents: 67
diff changeset
545 public:
kono
parents: 67
diff changeset
546 pass_graphite_transforms (gcc::context *ctxt)
kono
parents: 67
diff changeset
547 : gimple_opt_pass (pass_data_graphite_transforms, ctxt)
kono
parents: 67
diff changeset
548 {}
kono
parents: 67
diff changeset
549
kono
parents: 67
diff changeset
550 /* opt_pass methods: */
kono
parents: 67
diff changeset
551 virtual bool gate (function *) { return gate_graphite_transforms (); }
kono
parents: 67
diff changeset
552 virtual unsigned int execute (function *fun) { return graphite_transforms (fun); }
kono
parents: 67
diff changeset
553
kono
parents: 67
diff changeset
554 }; // class pass_graphite_transforms
kono
parents: 67
diff changeset
555
kono
parents: 67
diff changeset
556 } // anon namespace
kono
parents: 67
diff changeset
557
kono
parents: 67
diff changeset
558 gimple_opt_pass *
kono
parents: 67
diff changeset
559 make_pass_graphite_transforms (gcc::context *ctxt)
kono
parents: 67
diff changeset
560 {
kono
parents: 67
diff changeset
561 return new pass_graphite_transforms (ctxt);
kono
parents: 67
diff changeset
562 }
kono
parents: 67
diff changeset
563
kono
parents: 67
diff changeset
564