annotate gcc/graphite.c @ 16:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents f6334be47118
children 84e7813d76e9
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.
16
kono
parents: 14
diff changeset
2 Copyright (C) 2006-2017 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
9
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
16
kono
parents: 14
diff changeset
28 the related work. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29
16
kono
parents: 14
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"
16
kono
parents: 14
diff changeset
35 #include "backend.h"
14
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
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"
16
kono
parents: 14
diff changeset
38 #include "tree-pass.h"
kono
parents: 14
diff changeset
39 #include "params.h"
kono
parents: 14
diff changeset
40 #include "pretty-print.h"
kono
parents: 14
diff changeset
41
kono
parents: 14
diff changeset
42 #ifdef HAVE_isl
kono
parents: 14
diff changeset
43 #include "cfghooks.h"
kono
parents: 14
diff changeset
44 #include "tree.h"
kono
parents: 14
diff changeset
45 #include "gimple.h"
kono
parents: 14
diff changeset
46 #include "ssa.h"
kono
parents: 14
diff changeset
47 #include "fold-const.h"
kono
parents: 14
diff changeset
48 #include "gimple-iterator.h"
kono
parents: 14
diff changeset
49 #include "tree-cfg.h"
kono
parents: 14
diff changeset
50 #include "tree-ssa-loop.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 #include "tree-data-ref.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 #include "tree-scalar-evolution.h"
14
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
53 #include "dbgcnt.h"
16
kono
parents: 14
diff changeset
54 #include "tree-parloops.h"
kono
parents: 14
diff changeset
55 #include "tree-cfgcleanup.h"
kono
parents: 14
diff changeset
56 #include "tree-vectorizer.h"
kono
parents: 14
diff changeset
57 #include "tree-ssa-loop-manip.h"
kono
parents: 14
diff changeset
58 #include "tree-ssa.h"
kono
parents: 14
diff changeset
59 #include "tree-into-ssa.h"
kono
parents: 14
diff changeset
60 #include "graphite.h"
14
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
61
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
62 /* Print global statistics to FILE. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 static void
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
65 print_global_statistics (FILE* file)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 {
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
67 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
68 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
69 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
70 long n_conditions = 0;
16
kono
parents: 14
diff changeset
71 profile_count n_p_bbs = profile_count::zero ();
kono
parents: 14
diff changeset
72 profile_count n_p_loops = profile_count::zero ();
kono
parents: 14
diff changeset
73 profile_count n_p_stmts = profile_count::zero ();
kono
parents: 14
diff changeset
74 profile_count n_p_conditions = profile_count::zero ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
76 basic_block bb;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77
16
kono
parents: 14
diff changeset
78 FOR_ALL_BB_FN (bb, cfun)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 {
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
80 gimple_stmt_iterator psi;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
82 n_bbs++;
16
kono
parents: 14
diff changeset
83 if (bb->count.initialized_p ())
kono
parents: 14
diff changeset
84 n_p_bbs += bb->count;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
86 /* 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
87 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
88 && 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
89 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
90 n_loops++;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
91 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
92 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
93
16
kono
parents: 14
diff changeset
94 if (EDGE_COUNT (bb->succs) > 1)
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
95 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
96 n_conditions++;
16
kono
parents: 14
diff changeset
97 if (bb->count.initialized_p ())
kono
parents: 14
diff changeset
98 n_p_conditions += bb->count;
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
99 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
101 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
102 {
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
103 n_stmts++;
16
kono
parents: 14
diff changeset
104 if (bb->count.initialized_p ())
kono
parents: 14
diff changeset
105 n_p_stmts += bb->count;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 }
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
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
109 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
110 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
111 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
112 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
113 fprintf (file, "STMTS:%ld)\n", n_stmts);
16
kono
parents: 14
diff changeset
114 fprintf (file, "Global profiling statistics (");
kono
parents: 14
diff changeset
115 fprintf (file, "BBS:");
kono
parents: 14
diff changeset
116 n_p_bbs.dump (file);
kono
parents: 14
diff changeset
117 fprintf (file, ", LOOPS:");
kono
parents: 14
diff changeset
118 n_p_loops.dump (file);
kono
parents: 14
diff changeset
119 fprintf (file, ", CONDITIONS:");
kono
parents: 14
diff changeset
120 n_p_conditions.dump (file);
kono
parents: 14
diff changeset
121 fprintf (file, ", STMTS:");
kono
parents: 14
diff changeset
122 n_p_stmts.dump (file);
kono
parents: 14
diff changeset
123 fprintf (file, ")\n\n");
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
125
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
126 /* Print statistics for SCOP to FILE. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
127
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 static void
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
129 print_graphite_scop_statistics (FILE* file, scop_p scop)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 {
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
131 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
132 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
133 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
134 long n_conditions = 0;
16
kono
parents: 14
diff changeset
135 profile_count n_p_bbs = profile_count::zero ();
kono
parents: 14
diff changeset
136 profile_count n_p_loops = profile_count::zero ();
kono
parents: 14
diff changeset
137 profile_count n_p_stmts = profile_count::zero ();
kono
parents: 14
diff changeset
138 profile_count n_p_conditions = profile_count::zero ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
139
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
140 basic_block bb;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
141
16
kono
parents: 14
diff changeset
142 FOR_ALL_BB_FN (bb, cfun)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 {
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
144 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
145 loop_p loop = bb->loop_father;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
146
16
kono
parents: 14
diff changeset
147 if (!bb_in_sese_p (bb, scop->scop_info->region))
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
148 continue;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
149
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
150 n_bbs++;
16
kono
parents: 14
diff changeset
151 if (bb->count.initialized_p ())
kono
parents: 14
diff changeset
152 n_p_bbs += bb->count;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
153
16
kono
parents: 14
diff changeset
154 if (EDGE_COUNT (bb->succs) > 1)
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
155 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
156 n_conditions++;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
157 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
158 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
159
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
160 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
161 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
162 n_stmts++;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
163 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
164 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
165
16
kono
parents: 14
diff changeset
166 if (loop->header == bb && loop_in_sese_p (loop, scop->scop_info->region))
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
167 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
168 n_loops++;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
169 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
170 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
172
16
kono
parents: 14
diff changeset
173 fprintf (file, "\nFunction Name: %s\n", current_function_name ());
kono
parents: 14
diff changeset
174
kono
parents: 14
diff changeset
175 edge scop_begin = scop->scop_info->region.entry;
kono
parents: 14
diff changeset
176 edge scop_end = scop->scop_info->region.exit;
kono
parents: 14
diff changeset
177
kono
parents: 14
diff changeset
178 fprintf (file, "\nSCoP (entry_edge (bb_%d, bb_%d), ",
kono
parents: 14
diff changeset
179 scop_begin->src->index, scop_begin->dest->index);
kono
parents: 14
diff changeset
180 fprintf (file, "exit_edge (bb_%d, bb_%d))",
kono
parents: 14
diff changeset
181 scop_end->src->index, scop_end->dest->index);
kono
parents: 14
diff changeset
182
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
183 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
184 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
185 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
186 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
187 fprintf (file, "STMTS:%ld)\n", n_stmts);
16
kono
parents: 14
diff changeset
188 fprintf (file, "SCoP profiling statistics (");
kono
parents: 14
diff changeset
189 fprintf (file, "BBS:");
kono
parents: 14
diff changeset
190 n_p_bbs.dump (file);
kono
parents: 14
diff changeset
191 fprintf (file, ", LOOPS:");
kono
parents: 14
diff changeset
192 n_p_loops.dump (file);
kono
parents: 14
diff changeset
193 fprintf (file, ", CONDITIONS:");
kono
parents: 14
diff changeset
194 n_p_conditions.dump (file);
kono
parents: 14
diff changeset
195 fprintf (file, ", STMTS:");
kono
parents: 14
diff changeset
196 n_p_stmts.dump (file);
kono
parents: 14
diff changeset
197 fprintf (file, ")\n\n");
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
198 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
199
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
200 /* Print statistics for SCOPS to FILE. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
201
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
202 static void
16
kono
parents: 14
diff changeset
203 print_graphite_statistics (FILE* file, vec<scop_p> scops)
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
204 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
205 int i;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
206 scop_p scop;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
207
16
kono
parents: 14
diff changeset
208 FOR_EACH_VEC_ELT (scops, i, scop)
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
209 print_graphite_scop_statistics (file, scop);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
210 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
211
16
kono
parents: 14
diff changeset
212 /* Deletes all scops in SCOPS. */
kono
parents: 14
diff changeset
213
kono
parents: 14
diff changeset
214 static void
kono
parents: 14
diff changeset
215 free_scops (vec<scop_p> scops)
kono
parents: 14
diff changeset
216 {
kono
parents: 14
diff changeset
217 int i;
kono
parents: 14
diff changeset
218 scop_p scop;
kono
parents: 14
diff changeset
219
kono
parents: 14
diff changeset
220 FOR_EACH_VEC_ELT (scops, i, scop)
kono
parents: 14
diff changeset
221 free_scop (scop);
kono
parents: 14
diff changeset
222
kono
parents: 14
diff changeset
223 scops.release ();
kono
parents: 14
diff changeset
224 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
225
16
kono
parents: 14
diff changeset
226 /* Transforms LOOP to the canonical loop closed SSA form. */
kono
parents: 14
diff changeset
227
kono
parents: 14
diff changeset
228 static void
kono
parents: 14
diff changeset
229 canonicalize_loop_closed_ssa (loop_p loop)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
230 {
16
kono
parents: 14
diff changeset
231 edge e = single_exit (loop);
kono
parents: 14
diff changeset
232 basic_block bb;
kono
parents: 14
diff changeset
233 gphi_iterator psi;
kono
parents: 14
diff changeset
234
kono
parents: 14
diff changeset
235 if (!e || (e->flags & EDGE_COMPLEX))
kono
parents: 14
diff changeset
236 return;
kono
parents: 14
diff changeset
237
kono
parents: 14
diff changeset
238 bb = e->dest;
14
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
239
16
kono
parents: 14
diff changeset
240 /* Make the loop-close PHI node BB contain only PHIs and have a
kono
parents: 14
diff changeset
241 single predecessor. */
kono
parents: 14
diff changeset
242 if (single_pred_p (bb))
kono
parents: 14
diff changeset
243 {
kono
parents: 14
diff changeset
244 e = split_block_after_labels (bb);
kono
parents: 14
diff changeset
245 bb = e->src;
kono
parents: 14
diff changeset
246 }
kono
parents: 14
diff changeset
247 else
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
248 {
16
kono
parents: 14
diff changeset
249 basic_block close = split_edge (e);
kono
parents: 14
diff changeset
250 e = single_succ_edge (close);
kono
parents: 14
diff changeset
251 for (psi = gsi_start_phis (bb); !gsi_end_p (psi); gsi_next (&psi))
kono
parents: 14
diff changeset
252 {
kono
parents: 14
diff changeset
253 gphi *phi = psi.phi ();
kono
parents: 14
diff changeset
254 use_operand_p use_p = PHI_ARG_DEF_PTR_FROM_EDGE (phi, e);
kono
parents: 14
diff changeset
255 tree arg = USE_FROM_PTR (use_p);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
256
16
kono
parents: 14
diff changeset
257 /* Only add close phi nodes for SSA_NAMEs defined in LOOP. */
kono
parents: 14
diff changeset
258 if (TREE_CODE (arg) != SSA_NAME
kono
parents: 14
diff changeset
259 || SSA_NAME_IS_DEFAULT_DEF (arg)
kono
parents: 14
diff changeset
260 || ! flow_bb_inside_loop_p (loop,
kono
parents: 14
diff changeset
261 gimple_bb (SSA_NAME_DEF_STMT (arg))))
kono
parents: 14
diff changeset
262 continue;
kono
parents: 14
diff changeset
263
kono
parents: 14
diff changeset
264 tree res = copy_ssa_name (arg);
kono
parents: 14
diff changeset
265 gphi *close_phi = create_phi_node (res, close);
kono
parents: 14
diff changeset
266 add_phi_arg (close_phi, arg, gimple_phi_arg_edge (close_phi, 0),
kono
parents: 14
diff changeset
267 UNKNOWN_LOCATION);
kono
parents: 14
diff changeset
268 SET_USE (use_p, res);
kono
parents: 14
diff changeset
269 }
kono
parents: 14
diff changeset
270 bb = close;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
271 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
272
16
kono
parents: 14
diff changeset
273 /* Eliminate duplicates. This relies on processing loops from
kono
parents: 14
diff changeset
274 innermost to outer. */
kono
parents: 14
diff changeset
275 for (psi = gsi_start_phis (bb); !gsi_end_p (psi); gsi_next (&psi))
kono
parents: 14
diff changeset
276 {
kono
parents: 14
diff changeset
277 gphi_iterator gsi = psi;
kono
parents: 14
diff changeset
278 gphi *phi = psi.phi ();
14
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
279
16
kono
parents: 14
diff changeset
280 /* At this point, PHI should be a close phi in normal form. */
kono
parents: 14
diff changeset
281 gcc_assert (gimple_phi_num_args (phi) == 1);
14
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
282
16
kono
parents: 14
diff changeset
283 /* Iterate over the next phis and remove duplicates. */
kono
parents: 14
diff changeset
284 gsi_next (&gsi);
kono
parents: 14
diff changeset
285 while (!gsi_end_p (gsi))
kono
parents: 14
diff changeset
286 if (gimple_phi_arg_def (phi, 0) == gimple_phi_arg_def (gsi.phi (), 0))
kono
parents: 14
diff changeset
287 {
kono
parents: 14
diff changeset
288 replace_uses_by (gimple_phi_result (gsi.phi ()),
kono
parents: 14
diff changeset
289 gimple_phi_result (phi));
kono
parents: 14
diff changeset
290 remove_phi_node (&gsi, true);
kono
parents: 14
diff changeset
291 }
kono
parents: 14
diff changeset
292 else
kono
parents: 14
diff changeset
293 gsi_next (&gsi);
kono
parents: 14
diff changeset
294 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
295 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
296
16
kono
parents: 14
diff changeset
297 /* Converts the current loop closed SSA form to a canonical form
kono
parents: 14
diff changeset
298 expected by the Graphite code generation.
kono
parents: 14
diff changeset
299
kono
parents: 14
diff changeset
300 The loop closed SSA form has the following invariant: a variable
kono
parents: 14
diff changeset
301 defined in a loop that is used outside the loop appears only in the
kono
parents: 14
diff changeset
302 phi nodes in the destination of the loop exit. These phi nodes are
kono
parents: 14
diff changeset
303 called close phi nodes.
kono
parents: 14
diff changeset
304
kono
parents: 14
diff changeset
305 The canonical loop closed SSA form contains the extra invariants:
kono
parents: 14
diff changeset
306
kono
parents: 14
diff changeset
307 - when the loop contains only one exit, the close phi nodes contain
kono
parents: 14
diff changeset
308 only one argument. That implies that the basic block that contains
kono
parents: 14
diff changeset
309 the close phi nodes has only one predecessor, that is a basic block
kono
parents: 14
diff changeset
310 in the loop.
kono
parents: 14
diff changeset
311
kono
parents: 14
diff changeset
312 - the basic block containing the close phi nodes does not contain
kono
parents: 14
diff changeset
313 other statements.
kono
parents: 14
diff changeset
314
kono
parents: 14
diff changeset
315 - there exist only one phi node per definition in the loop.
kono
parents: 14
diff changeset
316 */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
317
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
318 static void
16
kono
parents: 14
diff changeset
319 canonicalize_loop_closed_ssa_form (void)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
320 {
16
kono
parents: 14
diff changeset
321 loop_p loop;
kono
parents: 14
diff changeset
322 FOR_EACH_LOOP (loop, LI_FROM_INNERMOST)
kono
parents: 14
diff changeset
323 canonicalize_loop_closed_ssa (loop);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
324
16
kono
parents: 14
diff changeset
325 checking_verify_loop_closed_ssa (true);
kono
parents: 14
diff changeset
326 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
327
16
kono
parents: 14
diff changeset
328 isl_ctx *the_isl_ctx;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
329
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
330 /* 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
331 function. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
332
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
333 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
334 graphite_transform_loops (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
335 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
336 int i;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
337 scop_p scop;
16
kono
parents: 14
diff changeset
338 bool changed = false;
kono
parents: 14
diff changeset
339 vec<scop_p> scops = vNULL;
kono
parents: 14
diff changeset
340 isl_ctx *ctx;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
341
16
kono
parents: 14
diff changeset
342 /* If a function is parallel it was most probably already run through graphite
kono
parents: 14
diff changeset
343 once. No need to run again. */
kono
parents: 14
diff changeset
344 if (parallelized_function_p (cfun->decl))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
345 return;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
346
16
kono
parents: 14
diff changeset
347 calculate_dominance_info (CDI_DOMINATORS);
kono
parents: 14
diff changeset
348
kono
parents: 14
diff changeset
349 ctx = isl_ctx_alloc ();
kono
parents: 14
diff changeset
350 isl_options_set_on_error (ctx, ISL_ON_ERROR_ABORT);
kono
parents: 14
diff changeset
351 the_isl_ctx = ctx;
kono
parents: 14
diff changeset
352
kono
parents: 14
diff changeset
353 sort_sibling_loops (cfun);
kono
parents: 14
diff changeset
354 canonicalize_loop_closed_ssa_form ();
kono
parents: 14
diff changeset
355
kono
parents: 14
diff changeset
356 /* Print the loop structure. */
kono
parents: 14
diff changeset
357 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents: 14
diff changeset
358 {
kono
parents: 14
diff changeset
359 print_loops (dump_file, 2);
kono
parents: 14
diff changeset
360 print_loops (dump_file, 3);
kono
parents: 14
diff changeset
361 }
kono
parents: 14
diff changeset
362
kono
parents: 14
diff changeset
363 calculate_dominance_info (CDI_POST_DOMINATORS);
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
364 build_scops (&scops);
16
kono
parents: 14
diff changeset
365 free_dominance_info (CDI_POST_DOMINATORS);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
366
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
367 if (dump_file && (dump_flags & TDF_DETAILS))
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
368 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
369 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
370 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
371 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
372
16
kono
parents: 14
diff changeset
373 FOR_EACH_VEC_ELT (scops, i, scop)
14
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
374 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: 11
diff changeset
375 {
16
kono
parents: 14
diff changeset
376 scop->isl_context = ctx;
kono
parents: 14
diff changeset
377 if (!build_poly_scop (scop))
kono
parents: 14
diff changeset
378 continue;
kono
parents: 14
diff changeset
379
kono
parents: 14
diff changeset
380 if (!apply_poly_transforms (scop))
kono
parents: 14
diff changeset
381 continue;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
382
16
kono
parents: 14
diff changeset
383 changed = true;
kono
parents: 14
diff changeset
384 if (graphite_regenerate_ast_isl (scop))
kono
parents: 14
diff changeset
385 {
kono
parents: 14
diff changeset
386 location_t loc = find_loop_location
kono
parents: 14
diff changeset
387 (scops[i]->scop_info->region.entry->dest->loop_father);
kono
parents: 14
diff changeset
388 dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
kono
parents: 14
diff changeset
389 "loop nest optimized\n");
kono
parents: 14
diff changeset
390 }
14
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
391 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
392
16
kono
parents: 14
diff changeset
393 if (changed)
kono
parents: 14
diff changeset
394 {
kono
parents: 14
diff changeset
395 mark_virtual_operands_for_renaming (cfun);
kono
parents: 14
diff changeset
396 update_ssa (TODO_update_ssa);
kono
parents: 14
diff changeset
397 checking_verify_ssa (true, true);
kono
parents: 14
diff changeset
398 rewrite_into_loop_closed_ssa (NULL, 0);
kono
parents: 14
diff changeset
399 scev_reset ();
kono
parents: 14
diff changeset
400 checking_verify_loop_structure ();
kono
parents: 14
diff changeset
401 }
kono
parents: 14
diff changeset
402
kono
parents: 14
diff changeset
403 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents: 14
diff changeset
404 {
kono
parents: 14
diff changeset
405 loop_p loop;
kono
parents: 14
diff changeset
406 int num_no_dependency = 0;
kono
parents: 14
diff changeset
407
kono
parents: 14
diff changeset
408 FOR_EACH_LOOP (loop, 0)
kono
parents: 14
diff changeset
409 if (loop->can_be_parallel)
kono
parents: 14
diff changeset
410 num_no_dependency++;
kono
parents: 14
diff changeset
411
kono
parents: 14
diff changeset
412 fprintf (dump_file, "%d loops carried no dependency.\n",
kono
parents: 14
diff changeset
413 num_no_dependency);
kono
parents: 14
diff changeset
414 }
kono
parents: 14
diff changeset
415
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
416 free_scops (scops);
16
kono
parents: 14
diff changeset
417 the_isl_ctx = NULL;
kono
parents: 14
diff changeset
418 isl_ctx_free (ctx);
kono
parents: 14
diff changeset
419
kono
parents: 14
diff changeset
420 if (changed)
kono
parents: 14
diff changeset
421 {
kono
parents: 14
diff changeset
422 cleanup_tree_cfg ();
kono
parents: 14
diff changeset
423 profile_status_for_fn (cfun) = PROFILE_ABSENT;
kono
parents: 14
diff changeset
424 release_recorded_exits (cfun);
kono
parents: 14
diff changeset
425 tree_estimate_probability (false);
kono
parents: 14
diff changeset
426 }
kono
parents: 14
diff changeset
427
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
428 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
429
16
kono
parents: 14
diff changeset
430 #else /* If isl is not available: #ifndef HAVE_isl. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
431
16
kono
parents: 14
diff changeset
432 static void
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
433 graphite_transform_loops (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
434 {
16
kono
parents: 14
diff changeset
435 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
436 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
437
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
438 #endif
16
kono
parents: 14
diff changeset
439
kono
parents: 14
diff changeset
440
kono
parents: 14
diff changeset
441 static unsigned int
kono
parents: 14
diff changeset
442 graphite_transforms (struct function *fun)
kono
parents: 14
diff changeset
443 {
kono
parents: 14
diff changeset
444 if (number_of_loops (fun) <= 1)
kono
parents: 14
diff changeset
445 return 0;
kono
parents: 14
diff changeset
446
kono
parents: 14
diff changeset
447 graphite_transform_loops ();
kono
parents: 14
diff changeset
448
kono
parents: 14
diff changeset
449 return 0;
kono
parents: 14
diff changeset
450 }
kono
parents: 14
diff changeset
451
kono
parents: 14
diff changeset
452 static bool
kono
parents: 14
diff changeset
453 gate_graphite_transforms (void)
kono
parents: 14
diff changeset
454 {
kono
parents: 14
diff changeset
455 /* Enable -fgraphite pass if any one of the graphite optimization flags
kono
parents: 14
diff changeset
456 is turned on. */
kono
parents: 14
diff changeset
457 if (flag_graphite_identity
kono
parents: 14
diff changeset
458 || flag_loop_parallelize_all
kono
parents: 14
diff changeset
459 || flag_loop_nest_optimize)
kono
parents: 14
diff changeset
460 flag_graphite = 1;
kono
parents: 14
diff changeset
461
kono
parents: 14
diff changeset
462 return flag_graphite != 0;
kono
parents: 14
diff changeset
463 }
kono
parents: 14
diff changeset
464
kono
parents: 14
diff changeset
465 namespace {
kono
parents: 14
diff changeset
466
kono
parents: 14
diff changeset
467 const pass_data pass_data_graphite =
kono
parents: 14
diff changeset
468 {
kono
parents: 14
diff changeset
469 GIMPLE_PASS, /* type */
kono
parents: 14
diff changeset
470 "graphite0", /* name */
kono
parents: 14
diff changeset
471 OPTGROUP_LOOP, /* optinfo_flags */
kono
parents: 14
diff changeset
472 TV_GRAPHITE, /* tv_id */
kono
parents: 14
diff changeset
473 ( PROP_cfg | PROP_ssa ), /* properties_required */
kono
parents: 14
diff changeset
474 0, /* properties_provided */
kono
parents: 14
diff changeset
475 0, /* properties_destroyed */
kono
parents: 14
diff changeset
476 0, /* todo_flags_start */
kono
parents: 14
diff changeset
477 0, /* todo_flags_finish */
kono
parents: 14
diff changeset
478 };
kono
parents: 14
diff changeset
479
kono
parents: 14
diff changeset
480 class pass_graphite : public gimple_opt_pass
kono
parents: 14
diff changeset
481 {
kono
parents: 14
diff changeset
482 public:
kono
parents: 14
diff changeset
483 pass_graphite (gcc::context *ctxt)
kono
parents: 14
diff changeset
484 : gimple_opt_pass (pass_data_graphite, ctxt)
kono
parents: 14
diff changeset
485 {}
kono
parents: 14
diff changeset
486
kono
parents: 14
diff changeset
487 /* opt_pass methods: */
kono
parents: 14
diff changeset
488 virtual bool gate (function *) { return gate_graphite_transforms (); }
kono
parents: 14
diff changeset
489
kono
parents: 14
diff changeset
490 }; // class pass_graphite
kono
parents: 14
diff changeset
491
kono
parents: 14
diff changeset
492 } // anon namespace
kono
parents: 14
diff changeset
493
kono
parents: 14
diff changeset
494 gimple_opt_pass *
kono
parents: 14
diff changeset
495 make_pass_graphite (gcc::context *ctxt)
kono
parents: 14
diff changeset
496 {
kono
parents: 14
diff changeset
497 return new pass_graphite (ctxt);
kono
parents: 14
diff changeset
498 }
kono
parents: 14
diff changeset
499
kono
parents: 14
diff changeset
500 namespace {
kono
parents: 14
diff changeset
501
kono
parents: 14
diff changeset
502 const pass_data pass_data_graphite_transforms =
kono
parents: 14
diff changeset
503 {
kono
parents: 14
diff changeset
504 GIMPLE_PASS, /* type */
kono
parents: 14
diff changeset
505 "graphite", /* name */
kono
parents: 14
diff changeset
506 OPTGROUP_LOOP, /* optinfo_flags */
kono
parents: 14
diff changeset
507 TV_GRAPHITE_TRANSFORMS, /* tv_id */
kono
parents: 14
diff changeset
508 ( PROP_cfg | PROP_ssa ), /* properties_required */
kono
parents: 14
diff changeset
509 0, /* properties_provided */
kono
parents: 14
diff changeset
510 0, /* properties_destroyed */
kono
parents: 14
diff changeset
511 0, /* todo_flags_start */
kono
parents: 14
diff changeset
512 0, /* todo_flags_finish */
kono
parents: 14
diff changeset
513 };
kono
parents: 14
diff changeset
514
kono
parents: 14
diff changeset
515 class pass_graphite_transforms : public gimple_opt_pass
kono
parents: 14
diff changeset
516 {
kono
parents: 14
diff changeset
517 public:
kono
parents: 14
diff changeset
518 pass_graphite_transforms (gcc::context *ctxt)
kono
parents: 14
diff changeset
519 : gimple_opt_pass (pass_data_graphite_transforms, ctxt)
kono
parents: 14
diff changeset
520 {}
kono
parents: 14
diff changeset
521
kono
parents: 14
diff changeset
522 /* opt_pass methods: */
kono
parents: 14
diff changeset
523 virtual bool gate (function *) { return gate_graphite_transforms (); }
kono
parents: 14
diff changeset
524 virtual unsigned int execute (function *fun) { return graphite_transforms (fun); }
kono
parents: 14
diff changeset
525
kono
parents: 14
diff changeset
526 }; // class pass_graphite_transforms
kono
parents: 14
diff changeset
527
kono
parents: 14
diff changeset
528 } // anon namespace
kono
parents: 14
diff changeset
529
kono
parents: 14
diff changeset
530 gimple_opt_pass *
kono
parents: 14
diff changeset
531 make_pass_graphite_transforms (gcc::context *ctxt)
kono
parents: 14
diff changeset
532 {
kono
parents: 14
diff changeset
533 return new pass_graphite_transforms (ctxt);
kono
parents: 14
diff changeset
534 }
kono
parents: 14
diff changeset
535
kono
parents: 14
diff changeset
536