annotate gcc/graphite.c @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
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.
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
2 Copyright (C) 2006-2020 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 "pretty-print.h"
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
40 #include "cfganal.h"
111
kono
parents: 67
diff changeset
41
kono
parents: 67
diff changeset
42 #ifdef HAVE_isl
kono
parents: 67
diff changeset
43 #include "cfghooks.h"
kono
parents: 67
diff changeset
44 #include "tree.h"
kono
parents: 67
diff changeset
45 #include "gimple.h"
kono
parents: 67
diff changeset
46 #include "ssa.h"
kono
parents: 67
diff changeset
47 #include "fold-const.h"
kono
parents: 67
diff changeset
48 #include "gimple-iterator.h"
kono
parents: 67
diff changeset
49 #include "tree-cfg.h"
kono
parents: 67
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"
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
53 #include "dbgcnt.h"
111
kono
parents: 67
diff changeset
54 #include "tree-parloops.h"
kono
parents: 67
diff changeset
55 #include "tree-cfgcleanup.h"
kono
parents: 67
diff changeset
56 #include "tree-vectorizer.h"
kono
parents: 67
diff changeset
57 #include "tree-ssa-loop-manip.h"
kono
parents: 67
diff changeset
58 #include "tree-ssa.h"
kono
parents: 67
diff changeset
59 #include "tree-into-ssa.h"
kono
parents: 67
diff changeset
60 #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
61
55
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
55
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 {
55
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;
111
kono
parents: 67
diff changeset
71 profile_count n_p_bbs = profile_count::zero ();
kono
parents: 67
diff changeset
72 profile_count n_p_loops = profile_count::zero ();
kono
parents: 67
diff changeset
73 profile_count n_p_stmts = profile_count::zero ();
kono
parents: 67
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
55
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
111
kono
parents: 67
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 {
55
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
55
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++;
111
kono
parents: 67
diff changeset
83 if (bb->count.initialized_p ())
kono
parents: 67
diff changeset
84 n_p_bbs += bb->count;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85
55
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
111
kono
parents: 67
diff changeset
94 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
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++;
111
kono
parents: 67
diff changeset
97 if (bb->count.initialized_p ())
kono
parents: 67
diff changeset
98 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
99 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100
55
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 {
55
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++;
111
kono
parents: 67
diff changeset
104 if (bb->count.initialized_p ())
kono
parents: 67
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
55
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);
111
kono
parents: 67
diff changeset
114 fprintf (file, "Global profiling statistics (");
kono
parents: 67
diff changeset
115 fprintf (file, "BBS:");
kono
parents: 67
diff changeset
116 n_p_bbs.dump (file);
kono
parents: 67
diff changeset
117 fprintf (file, ", LOOPS:");
kono
parents: 67
diff changeset
118 n_p_loops.dump (file);
kono
parents: 67
diff changeset
119 fprintf (file, ", CONDITIONS:");
kono
parents: 67
diff changeset
120 n_p_conditions.dump (file);
kono
parents: 67
diff changeset
121 fprintf (file, ", STMTS:");
kono
parents: 67
diff changeset
122 n_p_stmts.dump (file);
kono
parents: 67
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
55
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
55
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 {
55
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;
111
kono
parents: 67
diff changeset
135 profile_count n_p_bbs = profile_count::zero ();
kono
parents: 67
diff changeset
136 profile_count n_p_loops = profile_count::zero ();
kono
parents: 67
diff changeset
137 profile_count n_p_stmts = profile_count::zero ();
kono
parents: 67
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
111
kono
parents: 67
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 {
55
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
111
kono
parents: 67
diff changeset
147 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
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++;
111
kono
parents: 67
diff changeset
151 if (bb->count.initialized_p ())
kono
parents: 67
diff changeset
152 n_p_bbs += bb->count;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
153
111
kono
parents: 67
diff changeset
154 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
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
55
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
111
kono
parents: 67
diff changeset
166 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
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
111
kono
parents: 67
diff changeset
173 fprintf (file, "\nFunction Name: %s\n", current_function_name ());
kono
parents: 67
diff changeset
174
kono
parents: 67
diff changeset
175 edge scop_begin = scop->scop_info->region.entry;
kono
parents: 67
diff changeset
176 edge scop_end = scop->scop_info->region.exit;
kono
parents: 67
diff changeset
177
kono
parents: 67
diff changeset
178 fprintf (file, "\nSCoP (entry_edge (bb_%d, bb_%d), ",
kono
parents: 67
diff changeset
179 scop_begin->src->index, scop_begin->dest->index);
kono
parents: 67
diff changeset
180 fprintf (file, "exit_edge (bb_%d, bb_%d))",
kono
parents: 67
diff changeset
181 scop_end->src->index, scop_end->dest->index);
kono
parents: 67
diff changeset
182
55
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);
111
kono
parents: 67
diff changeset
188 fprintf (file, "SCoP profiling statistics (");
kono
parents: 67
diff changeset
189 fprintf (file, "BBS:");
kono
parents: 67
diff changeset
190 n_p_bbs.dump (file);
kono
parents: 67
diff changeset
191 fprintf (file, ", LOOPS:");
kono
parents: 67
diff changeset
192 n_p_loops.dump (file);
kono
parents: 67
diff changeset
193 fprintf (file, ", CONDITIONS:");
kono
parents: 67
diff changeset
194 n_p_conditions.dump (file);
kono
parents: 67
diff changeset
195 fprintf (file, ", STMTS:");
kono
parents: 67
diff changeset
196 n_p_stmts.dump (file);
kono
parents: 67
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
55
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
55
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
111
kono
parents: 67
diff changeset
203 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
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
111
kono
parents: 67
diff changeset
208 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
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
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
212 struct seir_cache_key
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
213 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
214 hashval_t hash;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
215 int entry_dest;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
216 int exit_src;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
217 int loop_num;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
218 tree expr;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
219 };
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
220
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
221 struct sese_scev_hash : typed_noop_remove <seir_cache_key>
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
222 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
223 typedef seir_cache_key value_type;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
224 typedef seir_cache_key compare_type;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
225 static hashval_t hash (const seir_cache_key &key) { return key.hash; }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
226 static bool
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
227 equal (const seir_cache_key &key1, const seir_cache_key &key2)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
228 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
229 return (key1.hash == key2.hash
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
230 && key1.entry_dest == key2.entry_dest
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
231 && key1.exit_src == key2.exit_src
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
232 && key1.loop_num == key2.loop_num
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
233 && operand_equal_p (key1.expr, key2.expr, 0));
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
234 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
235 static void mark_deleted (seir_cache_key &key) { key.expr = NULL_TREE; }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
236 static const bool empty_zero_p = false;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
237 static void mark_empty (seir_cache_key &key) { key.entry_dest = 0; }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
238 static bool is_deleted (const seir_cache_key &key) { return !key.expr; }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
239 static bool is_empty (const seir_cache_key &key) { return key.entry_dest == 0; }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
240 };
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
241
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
242 static hash_map<sese_scev_hash, tree> *seir_cache;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
243
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
244 /* Same as scalar_evolution_in_region but caches results so we avoid
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
245 re-computing evolutions during transform phase. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
246
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
247 tree
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
248 cached_scalar_evolution_in_region (const sese_l &region, loop_p loop,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
249 tree expr)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
250 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
251 seir_cache_key key;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
252 key.entry_dest = region.entry->dest->index;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
253 key.exit_src = region.exit->src->index;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
254 key.loop_num = loop->num;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
255 key.expr = expr;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
256 inchash::hash hstate (0);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
257 hstate.add_int (key.entry_dest);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
258 hstate.add_int (key.exit_src);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
259 hstate.add_int (key.loop_num);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
260 inchash::add_expr (key.expr, hstate);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
261 key.hash = hstate.end ();
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
262
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
263 bool existed;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
264 tree &chrec = seir_cache->get_or_insert (key, &existed);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
265 if (!existed)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
266 chrec = scalar_evolution_in_region (region, loop, expr);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
267 return chrec;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
268 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
269
111
kono
parents: 67
diff changeset
270 /* Deletes all scops in SCOPS. */
kono
parents: 67
diff changeset
271
kono
parents: 67
diff changeset
272 static void
kono
parents: 67
diff changeset
273 free_scops (vec<scop_p> scops)
kono
parents: 67
diff changeset
274 {
kono
parents: 67
diff changeset
275 int i;
kono
parents: 67
diff changeset
276 scop_p scop;
kono
parents: 67
diff changeset
277
kono
parents: 67
diff changeset
278 FOR_EACH_VEC_ELT (scops, i, scop)
kono
parents: 67
diff changeset
279 free_scop (scop);
kono
parents: 67
diff changeset
280
kono
parents: 67
diff changeset
281 scops.release ();
kono
parents: 67
diff changeset
282 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
283
111
kono
parents: 67
diff changeset
284 /* Transforms LOOP to the canonical loop closed SSA form. */
kono
parents: 67
diff changeset
285
kono
parents: 67
diff changeset
286 static void
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
287 canonicalize_loop_closed_ssa (loop_p loop, edge e)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
288 {
111
kono
parents: 67
diff changeset
289 basic_block bb;
kono
parents: 67
diff changeset
290 gphi_iterator psi;
kono
parents: 67
diff changeset
291
kono
parents: 67
diff changeset
292 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
293
111
kono
parents: 67
diff changeset
294 /* Make the loop-close PHI node BB contain only PHIs and have a
kono
parents: 67
diff changeset
295 single predecessor. */
kono
parents: 67
diff changeset
296 if (single_pred_p (bb))
kono
parents: 67
diff changeset
297 {
kono
parents: 67
diff changeset
298 e = split_block_after_labels (bb);
kono
parents: 67
diff changeset
299 bb = e->src;
kono
parents: 67
diff changeset
300 }
kono
parents: 67
diff changeset
301 else
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 {
111
kono
parents: 67
diff changeset
303 basic_block close = split_edge (e);
kono
parents: 67
diff changeset
304 e = single_succ_edge (close);
kono
parents: 67
diff changeset
305 for (psi = gsi_start_phis (bb); !gsi_end_p (psi); gsi_next (&psi))
kono
parents: 67
diff changeset
306 {
kono
parents: 67
diff changeset
307 gphi *phi = psi.phi ();
kono
parents: 67
diff changeset
308 use_operand_p use_p = PHI_ARG_DEF_PTR_FROM_EDGE (phi, e);
kono
parents: 67
diff changeset
309 tree arg = USE_FROM_PTR (use_p);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
310
111
kono
parents: 67
diff changeset
311 /* Only add close phi nodes for SSA_NAMEs defined in LOOP. */
kono
parents: 67
diff changeset
312 if (TREE_CODE (arg) != SSA_NAME
kono
parents: 67
diff changeset
313 || SSA_NAME_IS_DEFAULT_DEF (arg)
kono
parents: 67
diff changeset
314 || ! flow_bb_inside_loop_p (loop,
kono
parents: 67
diff changeset
315 gimple_bb (SSA_NAME_DEF_STMT (arg))))
kono
parents: 67
diff changeset
316 continue;
kono
parents: 67
diff changeset
317
kono
parents: 67
diff changeset
318 tree res = copy_ssa_name (arg);
kono
parents: 67
diff changeset
319 gphi *close_phi = create_phi_node (res, close);
kono
parents: 67
diff changeset
320 add_phi_arg (close_phi, arg, gimple_phi_arg_edge (close_phi, 0),
kono
parents: 67
diff changeset
321 UNKNOWN_LOCATION);
kono
parents: 67
diff changeset
322 SET_USE (use_p, res);
kono
parents: 67
diff changeset
323 }
kono
parents: 67
diff changeset
324 bb = close;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
325 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
326
111
kono
parents: 67
diff changeset
327 /* Eliminate duplicates. This relies on processing loops from
kono
parents: 67
diff changeset
328 innermost to outer. */
kono
parents: 67
diff changeset
329 for (psi = gsi_start_phis (bb); !gsi_end_p (psi); gsi_next (&psi))
kono
parents: 67
diff changeset
330 {
kono
parents: 67
diff changeset
331 gphi_iterator gsi = psi;
kono
parents: 67
diff changeset
332 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
333
111
kono
parents: 67
diff changeset
334 /* At this point, PHI should be a close phi in normal form. */
kono
parents: 67
diff changeset
335 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
336
111
kono
parents: 67
diff changeset
337 /* Iterate over the next phis and remove duplicates. */
kono
parents: 67
diff changeset
338 gsi_next (&gsi);
kono
parents: 67
diff changeset
339 while (!gsi_end_p (gsi))
kono
parents: 67
diff changeset
340 if (gimple_phi_arg_def (phi, 0) == gimple_phi_arg_def (gsi.phi (), 0))
kono
parents: 67
diff changeset
341 {
kono
parents: 67
diff changeset
342 replace_uses_by (gimple_phi_result (gsi.phi ()),
kono
parents: 67
diff changeset
343 gimple_phi_result (phi));
kono
parents: 67
diff changeset
344 remove_phi_node (&gsi, true);
kono
parents: 67
diff changeset
345 }
kono
parents: 67
diff changeset
346 else
kono
parents: 67
diff changeset
347 gsi_next (&gsi);
kono
parents: 67
diff changeset
348 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
349 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
350
111
kono
parents: 67
diff changeset
351 /* Converts the current loop closed SSA form to a canonical form
kono
parents: 67
diff changeset
352 expected by the Graphite code generation.
kono
parents: 67
diff changeset
353
kono
parents: 67
diff changeset
354 The loop closed SSA form has the following invariant: a variable
kono
parents: 67
diff changeset
355 defined in a loop that is used outside the loop appears only in the
kono
parents: 67
diff changeset
356 phi nodes in the destination of the loop exit. These phi nodes are
kono
parents: 67
diff changeset
357 called close phi nodes.
kono
parents: 67
diff changeset
358
kono
parents: 67
diff changeset
359 The canonical loop closed SSA form contains the extra invariants:
kono
parents: 67
diff changeset
360
kono
parents: 67
diff changeset
361 - when the loop contains only one exit, the close phi nodes contain
kono
parents: 67
diff changeset
362 only one argument. That implies that the basic block that contains
kono
parents: 67
diff changeset
363 the close phi nodes has only one predecessor, that is a basic block
kono
parents: 67
diff changeset
364 in the loop.
kono
parents: 67
diff changeset
365
kono
parents: 67
diff changeset
366 - the basic block containing the close phi nodes does not contain
kono
parents: 67
diff changeset
367 other statements.
kono
parents: 67
diff changeset
368
kono
parents: 67
diff changeset
369 - there exist only one phi node per definition in the loop.
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
370
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
371 In addition to that we also make sure that loop exit edges are
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
372 first in the successor edge vector. This is to make RPO order
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
373 as computed by pre_and_rev_post_order_compute be consistent with
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
374 what initial schedule generation expects.
111
kono
parents: 67
diff changeset
375 */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
376
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
377 static void
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
378 canonicalize_loop_form (void)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
379 {
111
kono
parents: 67
diff changeset
380 loop_p loop;
kono
parents: 67
diff changeset
381 FOR_EACH_LOOP (loop, LI_FROM_INNERMOST)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
382 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
383 edge e = single_exit (loop);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
384 if (!e || (e->flags & (EDGE_COMPLEX|EDGE_FAKE)))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
385 continue;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
386
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
387 canonicalize_loop_closed_ssa (loop, e);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
388
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
389 /* If the exit is not first in the edge vector make it so. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
390 if (e != EDGE_SUCC (e->src, 0))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
391 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
392 unsigned ei;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
393 for (ei = 0; EDGE_SUCC (e->src, ei) != e; ++ei)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
394 ;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
395 std::swap (EDGE_SUCC (e->src, ei), EDGE_SUCC (e->src, 0));
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
396 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
397 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
398
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
399 /* We can end up releasing duplicate exit PHIs and also introduce
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
400 additional copies so the cached information isn't correct anymore. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
401 scev_reset ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
402
111
kono
parents: 67
diff changeset
403 checking_verify_loop_closed_ssa (true);
kono
parents: 67
diff changeset
404 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
405
111
kono
parents: 67
diff changeset
406 isl_ctx *the_isl_ctx;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
407
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
408 /* 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
409 function. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
410
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
411 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
412 graphite_transform_loops (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
413 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
414 int i;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
415 scop_p scop;
111
kono
parents: 67
diff changeset
416 bool changed = false;
kono
parents: 67
diff changeset
417 vec<scop_p> scops = vNULL;
kono
parents: 67
diff changeset
418 isl_ctx *ctx;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
419
111
kono
parents: 67
diff changeset
420 /* If a function is parallel it was most probably already run through graphite
kono
parents: 67
diff changeset
421 once. No need to run again. */
kono
parents: 67
diff changeset
422 if (parallelized_function_p (cfun->decl))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
423 return;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
424
111
kono
parents: 67
diff changeset
425 calculate_dominance_info (CDI_DOMINATORS);
kono
parents: 67
diff changeset
426
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
427 /* We rely on post-dominators during merging of SESE regions so those
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
428 have to be meaningful. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
429 connect_infinite_loops_to_exit ();
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
430
111
kono
parents: 67
diff changeset
431 ctx = isl_ctx_alloc ();
kono
parents: 67
diff changeset
432 isl_options_set_on_error (ctx, ISL_ON_ERROR_ABORT);
kono
parents: 67
diff changeset
433 the_isl_ctx = ctx;
kono
parents: 67
diff changeset
434
kono
parents: 67
diff changeset
435 sort_sibling_loops (cfun);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
436 canonicalize_loop_form ();
111
kono
parents: 67
diff changeset
437
kono
parents: 67
diff changeset
438 /* Print the loop structure. */
kono
parents: 67
diff changeset
439 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents: 67
diff changeset
440 {
kono
parents: 67
diff changeset
441 print_loops (dump_file, 2);
kono
parents: 67
diff changeset
442 print_loops (dump_file, 3);
kono
parents: 67
diff changeset
443 }
kono
parents: 67
diff changeset
444
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
445 seir_cache = new hash_map<sese_scev_hash, tree>;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
446
111
kono
parents: 67
diff changeset
447 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
448 build_scops (&scops);
111
kono
parents: 67
diff changeset
449 free_dominance_info (CDI_POST_DOMINATORS);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
450
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
451 /* Remove the fake exits before transform given they are not reflected
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
452 in loop structures we end up verifying. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
453 remove_fake_exit_edges ();
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
454
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
455 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
456 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
457 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
458 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
459 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
460
111
kono
parents: 67
diff changeset
461 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
462 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
463 {
111
kono
parents: 67
diff changeset
464 scop->isl_context = ctx;
kono
parents: 67
diff changeset
465 if (!build_poly_scop (scop))
kono
parents: 67
diff changeset
466 continue;
kono
parents: 67
diff changeset
467
kono
parents: 67
diff changeset
468 if (!apply_poly_transforms (scop))
kono
parents: 67
diff changeset
469 continue;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
470
111
kono
parents: 67
diff changeset
471 changed = true;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
472 if (graphite_regenerate_ast_isl (scop)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
473 && dump_enabled_p ())
111
kono
parents: 67
diff changeset
474 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
475 dump_user_location_t loc = find_loop_location
111
kono
parents: 67
diff changeset
476 (scops[i]->scop_info->region.entry->dest->loop_father);
kono
parents: 67
diff changeset
477 dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
kono
parents: 67
diff changeset
478 "loop nest optimized\n");
kono
parents: 67
diff changeset
479 }
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
480 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
481
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
482 delete seir_cache;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
483 seir_cache = NULL;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
484
111
kono
parents: 67
diff changeset
485 if (changed)
kono
parents: 67
diff changeset
486 {
kono
parents: 67
diff changeset
487 mark_virtual_operands_for_renaming (cfun);
kono
parents: 67
diff changeset
488 update_ssa (TODO_update_ssa);
kono
parents: 67
diff changeset
489 checking_verify_ssa (true, true);
kono
parents: 67
diff changeset
490 rewrite_into_loop_closed_ssa (NULL, 0);
kono
parents: 67
diff changeset
491 scev_reset ();
kono
parents: 67
diff changeset
492 checking_verify_loop_structure ();
kono
parents: 67
diff changeset
493 }
kono
parents: 67
diff changeset
494
kono
parents: 67
diff changeset
495 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents: 67
diff changeset
496 {
kono
parents: 67
diff changeset
497 loop_p loop;
kono
parents: 67
diff changeset
498 int num_no_dependency = 0;
kono
parents: 67
diff changeset
499
kono
parents: 67
diff changeset
500 FOR_EACH_LOOP (loop, 0)
kono
parents: 67
diff changeset
501 if (loop->can_be_parallel)
kono
parents: 67
diff changeset
502 num_no_dependency++;
kono
parents: 67
diff changeset
503
kono
parents: 67
diff changeset
504 fprintf (dump_file, "%d loops carried no dependency.\n",
kono
parents: 67
diff changeset
505 num_no_dependency);
kono
parents: 67
diff changeset
506 }
kono
parents: 67
diff changeset
507
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
508 free_scops (scops);
111
kono
parents: 67
diff changeset
509 the_isl_ctx = NULL;
kono
parents: 67
diff changeset
510 isl_ctx_free (ctx);
kono
parents: 67
diff changeset
511
kono
parents: 67
diff changeset
512 if (changed)
kono
parents: 67
diff changeset
513 {
kono
parents: 67
diff changeset
514 cleanup_tree_cfg ();
kono
parents: 67
diff changeset
515 profile_status_for_fn (cfun) = PROFILE_ABSENT;
kono
parents: 67
diff changeset
516 release_recorded_exits (cfun);
kono
parents: 67
diff changeset
517 tree_estimate_probability (false);
kono
parents: 67
diff changeset
518 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
519 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
520
111
kono
parents: 67
diff changeset
521 #else /* If isl is not available: #ifndef HAVE_isl. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
522
111
kono
parents: 67
diff changeset
523 static void
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
524 graphite_transform_loops (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
525 {
111
kono
parents: 67
diff changeset
526 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
527 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
528
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
529 #endif
111
kono
parents: 67
diff changeset
530
kono
parents: 67
diff changeset
531
kono
parents: 67
diff changeset
532 static unsigned int
kono
parents: 67
diff changeset
533 graphite_transforms (struct function *fun)
kono
parents: 67
diff changeset
534 {
kono
parents: 67
diff changeset
535 if (number_of_loops (fun) <= 1)
kono
parents: 67
diff changeset
536 return 0;
kono
parents: 67
diff changeset
537
kono
parents: 67
diff changeset
538 graphite_transform_loops ();
kono
parents: 67
diff changeset
539
kono
parents: 67
diff changeset
540 return 0;
kono
parents: 67
diff changeset
541 }
kono
parents: 67
diff changeset
542
kono
parents: 67
diff changeset
543 static bool
kono
parents: 67
diff changeset
544 gate_graphite_transforms (void)
kono
parents: 67
diff changeset
545 {
kono
parents: 67
diff changeset
546 /* Enable -fgraphite pass if any one of the graphite optimization flags
kono
parents: 67
diff changeset
547 is turned on. */
kono
parents: 67
diff changeset
548 if (flag_graphite_identity
kono
parents: 67
diff changeset
549 || flag_loop_parallelize_all
kono
parents: 67
diff changeset
550 || flag_loop_nest_optimize)
kono
parents: 67
diff changeset
551 flag_graphite = 1;
kono
parents: 67
diff changeset
552
kono
parents: 67
diff changeset
553 return flag_graphite != 0;
kono
parents: 67
diff changeset
554 }
kono
parents: 67
diff changeset
555
kono
parents: 67
diff changeset
556 namespace {
kono
parents: 67
diff changeset
557
kono
parents: 67
diff changeset
558 const pass_data pass_data_graphite =
kono
parents: 67
diff changeset
559 {
kono
parents: 67
diff changeset
560 GIMPLE_PASS, /* type */
kono
parents: 67
diff changeset
561 "graphite0", /* name */
kono
parents: 67
diff changeset
562 OPTGROUP_LOOP, /* optinfo_flags */
kono
parents: 67
diff changeset
563 TV_GRAPHITE, /* tv_id */
kono
parents: 67
diff changeset
564 ( PROP_cfg | PROP_ssa ), /* properties_required */
kono
parents: 67
diff changeset
565 0, /* properties_provided */
kono
parents: 67
diff changeset
566 0, /* properties_destroyed */
kono
parents: 67
diff changeset
567 0, /* todo_flags_start */
kono
parents: 67
diff changeset
568 0, /* todo_flags_finish */
kono
parents: 67
diff changeset
569 };
kono
parents: 67
diff changeset
570
kono
parents: 67
diff changeset
571 class pass_graphite : public gimple_opt_pass
kono
parents: 67
diff changeset
572 {
kono
parents: 67
diff changeset
573 public:
kono
parents: 67
diff changeset
574 pass_graphite (gcc::context *ctxt)
kono
parents: 67
diff changeset
575 : gimple_opt_pass (pass_data_graphite, ctxt)
kono
parents: 67
diff changeset
576 {}
kono
parents: 67
diff changeset
577
kono
parents: 67
diff changeset
578 /* opt_pass methods: */
kono
parents: 67
diff changeset
579 virtual bool gate (function *) { return gate_graphite_transforms (); }
kono
parents: 67
diff changeset
580
kono
parents: 67
diff changeset
581 }; // class pass_graphite
kono
parents: 67
diff changeset
582
kono
parents: 67
diff changeset
583 } // anon namespace
kono
parents: 67
diff changeset
584
kono
parents: 67
diff changeset
585 gimple_opt_pass *
kono
parents: 67
diff changeset
586 make_pass_graphite (gcc::context *ctxt)
kono
parents: 67
diff changeset
587 {
kono
parents: 67
diff changeset
588 return new pass_graphite (ctxt);
kono
parents: 67
diff changeset
589 }
kono
parents: 67
diff changeset
590
kono
parents: 67
diff changeset
591 namespace {
kono
parents: 67
diff changeset
592
kono
parents: 67
diff changeset
593 const pass_data pass_data_graphite_transforms =
kono
parents: 67
diff changeset
594 {
kono
parents: 67
diff changeset
595 GIMPLE_PASS, /* type */
kono
parents: 67
diff changeset
596 "graphite", /* name */
kono
parents: 67
diff changeset
597 OPTGROUP_LOOP, /* optinfo_flags */
kono
parents: 67
diff changeset
598 TV_GRAPHITE_TRANSFORMS, /* tv_id */
kono
parents: 67
diff changeset
599 ( PROP_cfg | PROP_ssa ), /* properties_required */
kono
parents: 67
diff changeset
600 0, /* properties_provided */
kono
parents: 67
diff changeset
601 0, /* properties_destroyed */
kono
parents: 67
diff changeset
602 0, /* todo_flags_start */
kono
parents: 67
diff changeset
603 0, /* todo_flags_finish */
kono
parents: 67
diff changeset
604 };
kono
parents: 67
diff changeset
605
kono
parents: 67
diff changeset
606 class pass_graphite_transforms : public gimple_opt_pass
kono
parents: 67
diff changeset
607 {
kono
parents: 67
diff changeset
608 public:
kono
parents: 67
diff changeset
609 pass_graphite_transforms (gcc::context *ctxt)
kono
parents: 67
diff changeset
610 : gimple_opt_pass (pass_data_graphite_transforms, ctxt)
kono
parents: 67
diff changeset
611 {}
kono
parents: 67
diff changeset
612
kono
parents: 67
diff changeset
613 /* opt_pass methods: */
kono
parents: 67
diff changeset
614 virtual bool gate (function *) { return gate_graphite_transforms (); }
kono
parents: 67
diff changeset
615 virtual unsigned int execute (function *fun) { return graphite_transforms (fun); }
kono
parents: 67
diff changeset
616
kono
parents: 67
diff changeset
617 }; // class pass_graphite_transforms
kono
parents: 67
diff changeset
618
kono
parents: 67
diff changeset
619 } // anon namespace
kono
parents: 67
diff changeset
620
kono
parents: 67
diff changeset
621 gimple_opt_pass *
kono
parents: 67
diff changeset
622 make_pass_graphite_transforms (gcc::context *ctxt)
kono
parents: 67
diff changeset
623 {
kono
parents: 67
diff changeset
624 return new pass_graphite_transforms (ctxt);
kono
parents: 67
diff changeset
625 }
kono
parents: 67
diff changeset
626
kono
parents: 67
diff changeset
627