annotate gcc/sese.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
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /* Single entry single exit control flow regions.
16
kono
parents: 14
diff changeset
2 Copyright (C) 2008-2017 Free Software Foundation, Inc.
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 Contributed by Jan Sjodin <jan.sjodin@amd.com> and
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 Sebastian Pop <sebastian.pop@amd.com>.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 This file is part of GCC.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 GCC is free software; you can redistribute it and/or modify
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 it under the terms of the GNU General Public License as published by
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 the Free Software Foundation; either version 3, or (at your option)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 any later version.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 GCC is distributed in the hope that it will be useful,
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 GNU General Public License for more details.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 along with GCC; see the file COPYING3. If not see
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 <http://www.gnu.org/licenses/>. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 #include "config.h"
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 #include "system.h"
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 #include "coretypes.h"
16
kono
parents: 14
diff changeset
25 #include "backend.h"
kono
parents: 14
diff changeset
26 #include "tree.h"
kono
parents: 14
diff changeset
27 #include "gimple.h"
kono
parents: 14
diff changeset
28 #include "cfghooks.h"
kono
parents: 14
diff changeset
29 #include "tree-pass.h"
kono
parents: 14
diff changeset
30 #include "ssa.h"
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
31 #include "tree-pretty-print.h"
16
kono
parents: 14
diff changeset
32 #include "fold-const.h"
kono
parents: 14
diff changeset
33 #include "gimplify.h"
kono
parents: 14
diff changeset
34 #include "gimple-iterator.h"
kono
parents: 14
diff changeset
35 #include "gimple-pretty-print.h"
kono
parents: 14
diff changeset
36 #include "gimplify-me.h"
kono
parents: 14
diff changeset
37 #include "tree-cfg.h"
kono
parents: 14
diff changeset
38 #include "tree-ssa-loop.h"
kono
parents: 14
diff changeset
39 #include "tree-into-ssa.h"
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 #include "cfgloop.h"
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 #include "tree-data-ref.h"
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 #include "tree-scalar-evolution.h"
16
kono
parents: 14
diff changeset
43 #include "tree-ssa-propagate.h"
kono
parents: 14
diff changeset
44 #include "cfganal.h"
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 #include "sese.h"
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 /* For a USE in BB, if BB is outside REGION, mark the USE in the
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 LIVEOUTS set. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 static void
16
kono
parents: 14
diff changeset
51 sese_build_liveouts_use (sese_info_p region, bitmap liveouts, basic_block bb,
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 tree use)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 {
16
kono
parents: 14
diff changeset
54 gcc_assert (!bb_in_sese_p (bb, region->region));
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 if (TREE_CODE (use) != SSA_NAME)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 return;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57
16
kono
parents: 14
diff changeset
58 basic_block def_bb = gimple_bb (SSA_NAME_DEF_STMT (use));
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59
16
kono
parents: 14
diff changeset
60 if (!def_bb || !bb_in_sese_p (def_bb, region->region))
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 return;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62
16
kono
parents: 14
diff changeset
63 unsigned ver = SSA_NAME_VERSION (use);
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 bitmap_set_bit (liveouts, ver);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 /* Marks for rewrite all the SSA_NAMES defined in REGION and that are
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 used in BB that is outside of the REGION. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 static void
16
kono
parents: 14
diff changeset
71 sese_build_liveouts_bb (sese_info_p region, basic_block bb)
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 ssa_op_iter iter;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 use_operand_p use_p;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
75
16
kono
parents: 14
diff changeset
76 for (gphi_iterator bsi = gsi_start_phis (bb); !gsi_end_p (bsi);
kono
parents: 14
diff changeset
77 gsi_next (&bsi))
kono
parents: 14
diff changeset
78 FOR_EACH_PHI_ARG (use_p, bsi.phi (), iter, SSA_OP_USE)
kono
parents: 14
diff changeset
79 sese_build_liveouts_use (region, region->liveout,
kono
parents: 14
diff changeset
80 bb, USE_FROM_PTR (use_p));
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
81
16
kono
parents: 14
diff changeset
82 for (gimple_stmt_iterator bsi = gsi_start_bb (bb); !gsi_end_p (bsi);
kono
parents: 14
diff changeset
83 gsi_next (&bsi))
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 {
16
kono
parents: 14
diff changeset
85 gimple *stmt = gsi_stmt (bsi);
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
86
16
kono
parents: 14
diff changeset
87 bitmap liveouts = region->liveout;
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 if (is_gimple_debug (stmt))
16
kono
parents: 14
diff changeset
89 liveouts = region->debug_liveout;
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
90
16
kono
parents: 14
diff changeset
91 FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_USE)
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 sese_build_liveouts_use (region, liveouts, bb, USE_FROM_PTR (use_p));
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
95
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 /* Reset debug stmts that reference SSA_NAMES defined in REGION that
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 are not marked as liveouts. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
98
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 static void
16
kono
parents: 14
diff changeset
100 sese_reset_debug_liveouts (sese_info_p region)
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 {
16
kono
parents: 14
diff changeset
102 bitmap_iterator bi;
kono
parents: 14
diff changeset
103 unsigned i;
kono
parents: 14
diff changeset
104 EXECUTE_IF_AND_COMPL_IN_BITMAP (region->debug_liveout, region->liveout,
kono
parents: 14
diff changeset
105 0, i, bi)
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 {
16
kono
parents: 14
diff changeset
107 tree name = ssa_name (i);
kono
parents: 14
diff changeset
108 auto_vec<gimple *, 4> stmts;
kono
parents: 14
diff changeset
109 gimple *use_stmt;
kono
parents: 14
diff changeset
110 imm_use_iterator use_iter;
kono
parents: 14
diff changeset
111 FOR_EACH_IMM_USE_STMT (use_stmt, use_iter, name)
kono
parents: 14
diff changeset
112 {
kono
parents: 14
diff changeset
113 if (! is_gimple_debug (use_stmt)
kono
parents: 14
diff changeset
114 || bb_in_sese_p (gimple_bb (use_stmt), region->region))
kono
parents: 14
diff changeset
115 continue;
kono
parents: 14
diff changeset
116 stmts.safe_push (use_stmt);
kono
parents: 14
diff changeset
117 }
kono
parents: 14
diff changeset
118 while (!stmts.is_empty ())
kono
parents: 14
diff changeset
119 {
kono
parents: 14
diff changeset
120 gimple *stmt = stmts.pop ();
kono
parents: 14
diff changeset
121 gimple_debug_bind_reset_value (stmt);
kono
parents: 14
diff changeset
122 update_stmt (stmt);
kono
parents: 14
diff changeset
123 }
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
126
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 /* Build the LIVEOUTS of REGION: the set of variables defined inside
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 and used outside the REGION. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
129
16
kono
parents: 14
diff changeset
130 void
kono
parents: 14
diff changeset
131 sese_build_liveouts (sese_info_p region)
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 basic_block bb;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
134
16
kono
parents: 14
diff changeset
135 gcc_assert (region->liveout == NULL
kono
parents: 14
diff changeset
136 && region->debug_liveout == NULL);
kono
parents: 14
diff changeset
137
kono
parents: 14
diff changeset
138 region->liveout = BITMAP_ALLOC (NULL);
kono
parents: 14
diff changeset
139 region->debug_liveout = BITMAP_ALLOC (NULL);
kono
parents: 14
diff changeset
140
kono
parents: 14
diff changeset
141 /* FIXME: We could start iterating form the successor of sese. */
kono
parents: 14
diff changeset
142 FOR_EACH_BB_FN (bb, cfun)
kono
parents: 14
diff changeset
143 if (!bb_in_sese_p (bb, region->region))
kono
parents: 14
diff changeset
144 sese_build_liveouts_bb (region, bb);
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
146
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 /* Builds a new SESE region from edges ENTRY and EXIT. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
148
16
kono
parents: 14
diff changeset
149 sese_info_p
kono
parents: 14
diff changeset
150 new_sese_info (edge entry, edge exit)
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 {
16
kono
parents: 14
diff changeset
152 sese_info_p region = XNEW (struct sese_info_t);
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
153
16
kono
parents: 14
diff changeset
154 region->region.entry = entry;
kono
parents: 14
diff changeset
155 region->region.exit = exit;
kono
parents: 14
diff changeset
156 region->liveout = NULL;
kono
parents: 14
diff changeset
157 region->debug_liveout = NULL;
kono
parents: 14
diff changeset
158 region->params.create (3);
kono
parents: 14
diff changeset
159 region->rename_map = new hash_map <tree, tree>;
kono
parents: 14
diff changeset
160 region->bbs.create (3);
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
161
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
162 return region;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
163 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
164
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 /* Deletes REGION. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
166
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 void
16
kono
parents: 14
diff changeset
168 free_sese_info (sese_info_p region)
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 {
16
kono
parents: 14
diff changeset
170 region->params.release ();
kono
parents: 14
diff changeset
171 BITMAP_FREE (region->liveout);
kono
parents: 14
diff changeset
172 BITMAP_FREE (region->debug_liveout);
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
173
16
kono
parents: 14
diff changeset
174 delete region->rename_map;
kono
parents: 14
diff changeset
175 region->rename_map = NULL;
kono
parents: 14
diff changeset
176 region->bbs.release ();
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
177
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
178 XDELETE (region);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
179 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
180
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
181 /* Add exit phis for USE on EXIT. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
182
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
183 static void
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
184 sese_add_exit_phis_edge (basic_block exit, tree use, edge false_e, edge true_e)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
185 {
16
kono
parents: 14
diff changeset
186 gphi *phi = create_phi_node (NULL_TREE, exit);
kono
parents: 14
diff changeset
187 create_new_def_for (use, phi, gimple_phi_result_ptr (phi));
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
188 add_phi_arg (phi, use, false_e, UNKNOWN_LOCATION);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
189 add_phi_arg (phi, use, true_e, UNKNOWN_LOCATION);
16
kono
parents: 14
diff changeset
190 update_stmt (phi);
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
191 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
192
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
193 /* Insert in the block BB phi nodes for variables defined in REGION
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
194 and used outside the REGION. The code generation moves REGION in
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 the else clause of an "if (1)" and generates code in the then
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
196 clause that is at this point empty:
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
197
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
198 | if (1)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
199 | empty;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
200 | else
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
201 | REGION;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
202 */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
203
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
204 void
16
kono
parents: 14
diff changeset
205 sese_insert_phis_for_liveouts (sese_info_p region, basic_block bb,
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
206 edge false_e, edge true_e)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
207 {
16
kono
parents: 14
diff changeset
208 if (MAY_HAVE_DEBUG_STMTS)
kono
parents: 14
diff changeset
209 sese_reset_debug_liveouts (region);
kono
parents: 14
diff changeset
210
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
211 unsigned i;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
212 bitmap_iterator bi;
16
kono
parents: 14
diff changeset
213 EXECUTE_IF_SET_IN_BITMAP (region->liveout, 0, i, bi)
kono
parents: 14
diff changeset
214 if (!virtual_operand_p (ssa_name (i)))
kono
parents: 14
diff changeset
215 sese_add_exit_phis_edge (bb, ssa_name (i), false_e, true_e);
kono
parents: 14
diff changeset
216 }
kono
parents: 14
diff changeset
217
kono
parents: 14
diff changeset
218 /* Returns the outermost loop in SCOP that contains BB. */
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
219
16
kono
parents: 14
diff changeset
220 struct loop *
kono
parents: 14
diff changeset
221 outermost_loop_in_sese_1 (sese_l &region, basic_block bb)
kono
parents: 14
diff changeset
222 {
kono
parents: 14
diff changeset
223 struct loop *nest;
kono
parents: 14
diff changeset
224
kono
parents: 14
diff changeset
225 nest = bb->loop_father;
kono
parents: 14
diff changeset
226 while (loop_outer (nest)
kono
parents: 14
diff changeset
227 && loop_in_sese_p (loop_outer (nest), region))
kono
parents: 14
diff changeset
228 nest = loop_outer (nest);
kono
parents: 14
diff changeset
229
kono
parents: 14
diff changeset
230 return nest;
kono
parents: 14
diff changeset
231 }
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
232
16
kono
parents: 14
diff changeset
233 /* Same as outermost_loop_in_sese_1, returns the outermost loop
kono
parents: 14
diff changeset
234 containing BB in REGION, but makes sure that the returned loop
kono
parents: 14
diff changeset
235 belongs to the REGION, and so this returns the first loop in the
kono
parents: 14
diff changeset
236 REGION when the loop containing BB does not belong to REGION. */
kono
parents: 14
diff changeset
237
kono
parents: 14
diff changeset
238 loop_p
kono
parents: 14
diff changeset
239 outermost_loop_in_sese (sese_l &region, basic_block bb)
kono
parents: 14
diff changeset
240 {
kono
parents: 14
diff changeset
241 loop_p nest = outermost_loop_in_sese_1 (region, bb);
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
242
16
kono
parents: 14
diff changeset
243 if (loop_in_sese_p (nest, region))
kono
parents: 14
diff changeset
244 return nest;
kono
parents: 14
diff changeset
245
kono
parents: 14
diff changeset
246 /* When the basic block BB does not belong to a loop in the region,
kono
parents: 14
diff changeset
247 return the first loop in the region. */
kono
parents: 14
diff changeset
248 nest = nest->inner;
kono
parents: 14
diff changeset
249 while (nest)
kono
parents: 14
diff changeset
250 if (loop_in_sese_p (nest, region))
kono
parents: 14
diff changeset
251 break;
kono
parents: 14
diff changeset
252 else
kono
parents: 14
diff changeset
253 nest = nest->next;
kono
parents: 14
diff changeset
254
kono
parents: 14
diff changeset
255 gcc_assert (nest);
kono
parents: 14
diff changeset
256 return nest;
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
257 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
258
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
259 /* Returns the first successor edge of BB with EDGE_TRUE_VALUE flag set. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
260
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
261 edge
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
262 get_true_edge_from_guard_bb (basic_block bb)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
263 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
264 edge e;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
265 edge_iterator ei;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
266
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
267 FOR_EACH_EDGE (e, ei, bb->succs)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
268 if (e->flags & EDGE_TRUE_VALUE)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
269 return e;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
270
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
271 gcc_unreachable ();
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
272 return NULL;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
273 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
274
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
275 /* Returns the first successor edge of BB with EDGE_TRUE_VALUE flag cleared. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
276
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
277 edge
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
278 get_false_edge_from_guard_bb (basic_block bb)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
280 edge e;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
281 edge_iterator ei;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
282
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
283 FOR_EACH_EDGE (e, ei, bb->succs)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
284 if (!(e->flags & EDGE_TRUE_VALUE))
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
285 return e;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
286
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
287 gcc_unreachable ();
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
288 return NULL;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
289 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
290
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
291 /* Moves REGION in a condition expression:
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
292 | if (1)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
293 | ;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
294 | else
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
295 | REGION;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
296 */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
297
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
298 ifsese
16
kono
parents: 14
diff changeset
299 move_sese_in_condition (sese_info_p region)
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
300 {
16
kono
parents: 14
diff changeset
301 basic_block region_entry_dest = region->region.entry->dest;
kono
parents: 14
diff changeset
302 basic_block pred_block = split_edge (region->region.entry);
kono
parents: 14
diff changeset
303 basic_block merge_block = split_edge (region->region.exit);
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
304
16
kono
parents: 14
diff changeset
305 edge true_edge = make_edge (pred_block, merge_block, EDGE_TRUE_VALUE);
kono
parents: 14
diff changeset
306 edge false_edge = find_edge (pred_block, region_entry_dest);
kono
parents: 14
diff changeset
307 false_edge->flags &= ~EDGE_FALLTHRU;
kono
parents: 14
diff changeset
308 false_edge->flags |= EDGE_FALSE_VALUE;
kono
parents: 14
diff changeset
309 gimple_stmt_iterator gsi = gsi_last_bb (pred_block);
kono
parents: 14
diff changeset
310 gcond *cond = gimple_build_cond (NE_EXPR, integer_one_node, integer_zero_node,
kono
parents: 14
diff changeset
311 NULL_TREE, NULL_TREE);
kono
parents: 14
diff changeset
312 gsi_insert_after (&gsi, cond, GSI_CONTINUE_LINKING);
kono
parents: 14
diff changeset
313 if (dom_info_available_p (CDI_DOMINATORS))
kono
parents: 14
diff changeset
314 set_immediate_dominator (CDI_DOMINATORS, merge_block, pred_block);
kono
parents: 14
diff changeset
315
kono
parents: 14
diff changeset
316 ifsese if_region = XNEW (ifsese_s);
kono
parents: 14
diff changeset
317 if_region->region = XCNEW (sese_info_t);
kono
parents: 14
diff changeset
318 if_region->true_region = XCNEW (sese_info_t);
kono
parents: 14
diff changeset
319 if_region->false_region = XCNEW (sese_info_t);
kono
parents: 14
diff changeset
320 if_region->region->region.entry = single_pred_edge (pred_block);
kono
parents: 14
diff changeset
321 if_region->region->region.exit = single_succ_edge (merge_block);
kono
parents: 14
diff changeset
322 if_region->false_region->region.entry = false_edge;
kono
parents: 14
diff changeset
323 if_region->false_region->region.exit = region->region.exit;
kono
parents: 14
diff changeset
324 if_region->true_region->region.entry = true_edge;
kono
parents: 14
diff changeset
325 if_region->true_region->region.exit
kono
parents: 14
diff changeset
326 = single_succ_edge (split_edge (true_edge));
kono
parents: 14
diff changeset
327
kono
parents: 14
diff changeset
328 region->region = if_region->false_region->region;
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
329
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
330 return if_region;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
331 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
332
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
333 /* Replaces the condition of the IF_REGION with CONDITION:
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
334 | if (CONDITION)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
335 | true_region;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
336 | else
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
337 | false_region;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
338 */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
339
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
340 void
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
341 set_ifsese_condition (ifsese if_region, tree condition)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
342 {
16
kono
parents: 14
diff changeset
343 sese_info_p region = if_region->region;
kono
parents: 14
diff changeset
344 edge entry = region->region.entry;
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
345 basic_block bb = entry->dest;
16
kono
parents: 14
diff changeset
346 gimple *last = last_stmt (bb);
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
347 gimple_stmt_iterator gsi = gsi_last_bb (bb);
16
kono
parents: 14
diff changeset
348 gcond *cond_stmt;
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
349
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
350 gcc_assert (gimple_code (last) == GIMPLE_COND);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
351
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
352 gsi_remove (&gsi, true);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
353 gsi = gsi_last_bb (bb);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
354 condition = force_gimple_operand_gsi (&gsi, condition, true, NULL,
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
355 false, GSI_NEW_STMT);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
356 cond_stmt = gimple_build_cond_from_tree (condition, NULL_TREE, NULL_TREE);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
357 gsi = gsi_last_bb (bb);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
358 gsi_insert_after (&gsi, cond_stmt, GSI_NEW_STMT);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
359 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
360
16
kono
parents: 14
diff changeset
361 /* Return true when T is defined outside REGION or when no definitions are
kono
parents: 14
diff changeset
362 variant in REGION. When HAS_VDEFS is a valid pointer, sets HAS_VDEFS to true
kono
parents: 14
diff changeset
363 when T depends on memory that may change in REGION. */
kono
parents: 14
diff changeset
364
kono
parents: 14
diff changeset
365 bool
kono
parents: 14
diff changeset
366 invariant_in_sese_p_rec (tree t, const sese_l &region, bool *has_vdefs)
kono
parents: 14
diff changeset
367 {
kono
parents: 14
diff changeset
368 if (!defined_in_sese_p (t, region))
kono
parents: 14
diff changeset
369 return true;
kono
parents: 14
diff changeset
370
kono
parents: 14
diff changeset
371 gimple *stmt = SSA_NAME_DEF_STMT (t);
kono
parents: 14
diff changeset
372
kono
parents: 14
diff changeset
373 if (gimple_code (stmt) == GIMPLE_PHI
kono
parents: 14
diff changeset
374 || gimple_code (stmt) == GIMPLE_CALL)
kono
parents: 14
diff changeset
375 return false;
kono
parents: 14
diff changeset
376
kono
parents: 14
diff changeset
377 /* VDEF is variant when it is in the region. */
kono
parents: 14
diff changeset
378 if (gimple_vdef (stmt))
kono
parents: 14
diff changeset
379 {
kono
parents: 14
diff changeset
380 if (has_vdefs)
kono
parents: 14
diff changeset
381 *has_vdefs = true;
kono
parents: 14
diff changeset
382 return false;
kono
parents: 14
diff changeset
383 }
kono
parents: 14
diff changeset
384
kono
parents: 14
diff changeset
385 /* A VUSE may or may not be variant following the VDEFs. */
kono
parents: 14
diff changeset
386 if (tree vuse = gimple_vuse (stmt))
kono
parents: 14
diff changeset
387 return invariant_in_sese_p_rec (vuse, region, has_vdefs);
kono
parents: 14
diff changeset
388
kono
parents: 14
diff changeset
389 ssa_op_iter iter;
kono
parents: 14
diff changeset
390 use_operand_p use_p;
kono
parents: 14
diff changeset
391 FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_USE)
kono
parents: 14
diff changeset
392 {
kono
parents: 14
diff changeset
393 tree use = USE_FROM_PTR (use_p);
kono
parents: 14
diff changeset
394
kono
parents: 14
diff changeset
395 if (!defined_in_sese_p (use, region))
kono
parents: 14
diff changeset
396 continue;
kono
parents: 14
diff changeset
397
kono
parents: 14
diff changeset
398 if (!invariant_in_sese_p_rec (use, region, has_vdefs))
kono
parents: 14
diff changeset
399 return false;
kono
parents: 14
diff changeset
400 }
kono
parents: 14
diff changeset
401
kono
parents: 14
diff changeset
402 return true;
kono
parents: 14
diff changeset
403 }
kono
parents: 14
diff changeset
404
kono
parents: 14
diff changeset
405 /* Return true when DEF can be analyzed in REGION by the scalar
kono
parents: 14
diff changeset
406 evolution analyzer. */
kono
parents: 14
diff changeset
407
kono
parents: 14
diff changeset
408 bool
kono
parents: 14
diff changeset
409 scev_analyzable_p (tree def, sese_l &region)
kono
parents: 14
diff changeset
410 {
kono
parents: 14
diff changeset
411 loop_p loop;
kono
parents: 14
diff changeset
412 tree scev;
kono
parents: 14
diff changeset
413 tree type = TREE_TYPE (def);
kono
parents: 14
diff changeset
414
kono
parents: 14
diff changeset
415 /* When Graphite generates code for a scev, the code generator
kono
parents: 14
diff changeset
416 expresses the scev in function of a single induction variable.
kono
parents: 14
diff changeset
417 This is unsafe for floating point computations, as it may replace
kono
parents: 14
diff changeset
418 a floating point sum reduction with a multiplication. The
kono
parents: 14
diff changeset
419 following test returns false for non integer types to avoid such
kono
parents: 14
diff changeset
420 problems. */
kono
parents: 14
diff changeset
421 if (!INTEGRAL_TYPE_P (type)
kono
parents: 14
diff changeset
422 && !POINTER_TYPE_P (type))
kono
parents: 14
diff changeset
423 return false;
kono
parents: 14
diff changeset
424
kono
parents: 14
diff changeset
425 loop = loop_containing_stmt (SSA_NAME_DEF_STMT (def));
kono
parents: 14
diff changeset
426 scev = scalar_evolution_in_region (region, loop, def);
kono
parents: 14
diff changeset
427
kono
parents: 14
diff changeset
428 return (!chrec_contains_undetermined (scev)
kono
parents: 14
diff changeset
429 && (TREE_CODE (scev) != SSA_NAME
kono
parents: 14
diff changeset
430 || !defined_in_sese_p (scev, region))
kono
parents: 14
diff changeset
431 && scev_is_linear_expression (scev)
kono
parents: 14
diff changeset
432 && (! loop
kono
parents: 14
diff changeset
433 || ! loop_in_sese_p (loop, region)
kono
parents: 14
diff changeset
434 || ! chrec_contains_symbols_defined_in_loop (scev, loop->num)));
kono
parents: 14
diff changeset
435 }
kono
parents: 14
diff changeset
436
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
437 /* Returns the scalar evolution of T in REGION. Every variable that
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
438 is not defined in the REGION is considered a parameter. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
439
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
440 tree
16
kono
parents: 14
diff changeset
441 scalar_evolution_in_region (const sese_l &region, loop_p loop, tree t)
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
442 {
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
443 /* SCOP parameters. */
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
444 if (TREE_CODE (t) == SSA_NAME
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
445 && !defined_in_sese_p (t, region))
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
446 return t;
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
447
16
kono
parents: 14
diff changeset
448 if (!loop_in_sese_p (loop, region))
kono
parents: 14
diff changeset
449 loop = NULL;
kono
parents: 14
diff changeset
450
kono
parents: 14
diff changeset
451 return instantiate_scev (region.entry, loop,
kono
parents: 14
diff changeset
452 analyze_scalar_evolution (loop, t));
kono
parents: 14
diff changeset
453 }
kono
parents: 14
diff changeset
454
kono
parents: 14
diff changeset
455 /* Return true if BB is empty, contains only DEBUG_INSNs. */
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
456
16
kono
parents: 14
diff changeset
457 bool
kono
parents: 14
diff changeset
458 sese_trivially_empty_bb_p (basic_block bb)
kono
parents: 14
diff changeset
459 {
kono
parents: 14
diff changeset
460 gimple_stmt_iterator gsi;
kono
parents: 14
diff changeset
461
kono
parents: 14
diff changeset
462 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
kono
parents: 14
diff changeset
463 if (gimple_code (gsi_stmt (gsi)) != GIMPLE_DEBUG
kono
parents: 14
diff changeset
464 && gimple_code (gsi_stmt (gsi)) != GIMPLE_LABEL)
kono
parents: 14
diff changeset
465 return false;
kono
parents: 14
diff changeset
466
kono
parents: 14
diff changeset
467 return true;
kono
parents: 14
diff changeset
468 }
kono
parents: 14
diff changeset
469
kono
parents: 14
diff changeset
470 /* Pretty print edge E to FILE. */
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
471
16
kono
parents: 14
diff changeset
472 void
kono
parents: 14
diff changeset
473 print_edge (FILE *file, const_edge e)
kono
parents: 14
diff changeset
474 {
kono
parents: 14
diff changeset
475 fprintf (file, "edge (bb_%d, bb_%d)", e->src->index, e->dest->index);
kono
parents: 14
diff changeset
476 }
kono
parents: 14
diff changeset
477
kono
parents: 14
diff changeset
478 /* Pretty print sese S to FILE. */
kono
parents: 14
diff changeset
479
kono
parents: 14
diff changeset
480 void
kono
parents: 14
diff changeset
481 print_sese (FILE *file, const sese_l &s)
kono
parents: 14
diff changeset
482 {
kono
parents: 14
diff changeset
483 fprintf (file, "(entry_"); print_edge (file, s.entry);
kono
parents: 14
diff changeset
484 fprintf (file, ", exit_"); print_edge (file, s.exit);
kono
parents: 14
diff changeset
485 fprintf (file, ")\n");
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
486 }
16
kono
parents: 14
diff changeset
487
kono
parents: 14
diff changeset
488 /* Pretty print edge E to STDERR. */
kono
parents: 14
diff changeset
489
kono
parents: 14
diff changeset
490 DEBUG_FUNCTION void
kono
parents: 14
diff changeset
491 debug_edge (const_edge e)
kono
parents: 14
diff changeset
492 {
kono
parents: 14
diff changeset
493 print_edge (stderr, e);
kono
parents: 14
diff changeset
494 }
kono
parents: 14
diff changeset
495
kono
parents: 14
diff changeset
496 /* Pretty print sese S to STDERR. */
kono
parents: 14
diff changeset
497
kono
parents: 14
diff changeset
498 DEBUG_FUNCTION void
kono
parents: 14
diff changeset
499 debug_sese (const sese_l &s)
kono
parents: 14
diff changeset
500 {
kono
parents: 14
diff changeset
501 print_sese (stderr, s);
kono
parents: 14
diff changeset
502 }