annotate gcc/tree-if-conv.c @ 116:367f9f4f266e

fix gimple.h
author mir3636
date Tue, 28 Nov 2017 20:22:01 +0900
parents 04ced10e8804
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /* If-conversion for vectorizer.
111
kono
parents: 67
diff changeset
2 Copyright (C) 2004-2017 Free Software Foundation, Inc.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 Contributed by Devang Patel <dpatel@apple.com>
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 it under
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 the terms of the GNU General Public License as published by the Free
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 Software Foundation; either version 3, or (at your option) any later
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 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, but WITHOUT ANY
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 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
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
21 /* This pass implements a tree level if-conversion of loops. Its
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
22 initial goal is to help the vectorizer to vectorize loops with
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
23 conditions.
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 A short description of if-conversion:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 o Decide if a loop is if-convertible or not.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 o Walk all loop basic blocks in breadth first order (BFS order).
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 o Remove conditional statements (at the end of basic block)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 and propagate condition into destination basic blocks'
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 predicate list.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 o Replace modify expression with conditional modify expression
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 using current basic block's condition.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 o Merge all basic blocks
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 o Replace phi nodes with conditional modify expr
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 o Merge all basic blocks into header
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 Sample transformation:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 INPUT
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 -----
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 # i_23 = PHI <0(0), i_18(10)>;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 <L0>:;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 j_15 = A[i_23];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 if (j_15 > 41) goto <L1>; else goto <L17>;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 <L17>:;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 goto <bb 3> (<L3>);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 <L1>:;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 # iftmp.2_4 = PHI <0(8), 42(2)>;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 <L3>:;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 A[i_23] = iftmp.2_4;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 i_18 = i_23 + 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 if (i_18 <= 15) goto <L19>; else goto <L18>;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 <L19>:;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 goto <bb 1> (<L0>);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 <L18>:;
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 OUTPUT
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 ------
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 # i_23 = PHI <0(0), i_18(10)>;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 <L0>:;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 j_15 = A[i_23];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 <L3>:;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 iftmp.2_4 = j_15 > 41 ? 42 : 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 A[i_23] = iftmp.2_4;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 i_18 = i_23 + 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 if (i_18 <= 15) goto <L19>; else goto <L18>;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 <L19>:;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 goto <bb 1> (<L0>);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 <L18>:;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 #include "config.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 #include "system.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 #include "coretypes.h"
111
kono
parents: 67
diff changeset
86 #include "backend.h"
kono
parents: 67
diff changeset
87 #include "rtl.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 #include "tree.h"
111
kono
parents: 67
diff changeset
89 #include "gimple.h"
kono
parents: 67
diff changeset
90 #include "cfghooks.h"
kono
parents: 67
diff changeset
91 #include "tree-pass.h"
kono
parents: 67
diff changeset
92 #include "ssa.h"
kono
parents: 67
diff changeset
93 #include "expmed.h"
kono
parents: 67
diff changeset
94 #include "optabs-query.h"
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
95 #include "gimple-pretty-print.h"
111
kono
parents: 67
diff changeset
96 #include "alias.h"
kono
parents: 67
diff changeset
97 #include "fold-const.h"
kono
parents: 67
diff changeset
98 #include "stor-layout.h"
kono
parents: 67
diff changeset
99 #include "gimple-fold.h"
kono
parents: 67
diff changeset
100 #include "gimplify.h"
kono
parents: 67
diff changeset
101 #include "gimple-iterator.h"
kono
parents: 67
diff changeset
102 #include "gimplify-me.h"
kono
parents: 67
diff changeset
103 #include "tree-cfg.h"
kono
parents: 67
diff changeset
104 #include "tree-into-ssa.h"
kono
parents: 67
diff changeset
105 #include "tree-ssa.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 #include "cfgloop.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 #include "tree-data-ref.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 #include "tree-scalar-evolution.h"
111
kono
parents: 67
diff changeset
109 #include "tree-ssa-loop.h"
kono
parents: 67
diff changeset
110 #include "tree-ssa-loop-niter.h"
kono
parents: 67
diff changeset
111 #include "tree-ssa-loop-ivopts.h"
kono
parents: 67
diff changeset
112 #include "tree-ssa-address.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
113 #include "dbgcnt.h"
111
kono
parents: 67
diff changeset
114 #include "tree-hash-traits.h"
kono
parents: 67
diff changeset
115 #include "varasm.h"
kono
parents: 67
diff changeset
116 #include "builtins.h"
kono
parents: 67
diff changeset
117 #include "params.h"
kono
parents: 67
diff changeset
118 #include "cfganal.h"
kono
parents: 67
diff changeset
119
kono
parents: 67
diff changeset
120 /* Only handle PHIs with no more arguments unless we are asked to by
kono
parents: 67
diff changeset
121 simd pragma. */
kono
parents: 67
diff changeset
122 #define MAX_PHI_ARG_NUM \
kono
parents: 67
diff changeset
123 ((unsigned) PARAM_VALUE (PARAM_MAX_TREE_IF_CONVERSION_PHI_ARGS))
kono
parents: 67
diff changeset
124
kono
parents: 67
diff changeset
125 /* Indicate if new load/store that needs to be predicated is introduced
kono
parents: 67
diff changeset
126 during if conversion. */
kono
parents: 67
diff changeset
127 static bool any_pred_load_store;
kono
parents: 67
diff changeset
128
kono
parents: 67
diff changeset
129 /* Indicate if there are any complicated PHIs that need to be handled in
kono
parents: 67
diff changeset
130 if-conversion. Complicated PHI has more than two arguments and can't
kono
parents: 67
diff changeset
131 be degenerated to two arguments PHI. See more information in comment
kono
parents: 67
diff changeset
132 before phi_convertible_by_degenerating_args. */
kono
parents: 67
diff changeset
133 static bool any_complicated_phi;
kono
parents: 67
diff changeset
134
kono
parents: 67
diff changeset
135 /* Hash for struct innermost_loop_behavior. It depends on the user to
kono
parents: 67
diff changeset
136 free the memory. */
kono
parents: 67
diff changeset
137
kono
parents: 67
diff changeset
138 struct innermost_loop_behavior_hash : nofree_ptr_hash <innermost_loop_behavior>
kono
parents: 67
diff changeset
139 {
kono
parents: 67
diff changeset
140 static inline hashval_t hash (const value_type &);
kono
parents: 67
diff changeset
141 static inline bool equal (const value_type &,
kono
parents: 67
diff changeset
142 const compare_type &);
kono
parents: 67
diff changeset
143 };
kono
parents: 67
diff changeset
144
kono
parents: 67
diff changeset
145 inline hashval_t
kono
parents: 67
diff changeset
146 innermost_loop_behavior_hash::hash (const value_type &e)
kono
parents: 67
diff changeset
147 {
kono
parents: 67
diff changeset
148 hashval_t hash;
kono
parents: 67
diff changeset
149
kono
parents: 67
diff changeset
150 hash = iterative_hash_expr (e->base_address, 0);
kono
parents: 67
diff changeset
151 hash = iterative_hash_expr (e->offset, hash);
kono
parents: 67
diff changeset
152 hash = iterative_hash_expr (e->init, hash);
kono
parents: 67
diff changeset
153 return iterative_hash_expr (e->step, hash);
kono
parents: 67
diff changeset
154 }
kono
parents: 67
diff changeset
155
kono
parents: 67
diff changeset
156 inline bool
kono
parents: 67
diff changeset
157 innermost_loop_behavior_hash::equal (const value_type &e1,
kono
parents: 67
diff changeset
158 const compare_type &e2)
kono
parents: 67
diff changeset
159 {
kono
parents: 67
diff changeset
160 if ((e1->base_address && !e2->base_address)
kono
parents: 67
diff changeset
161 || (!e1->base_address && e2->base_address)
kono
parents: 67
diff changeset
162 || (!e1->offset && e2->offset)
kono
parents: 67
diff changeset
163 || (e1->offset && !e2->offset)
kono
parents: 67
diff changeset
164 || (!e1->init && e2->init)
kono
parents: 67
diff changeset
165 || (e1->init && !e2->init)
kono
parents: 67
diff changeset
166 || (!e1->step && e2->step)
kono
parents: 67
diff changeset
167 || (e1->step && !e2->step))
kono
parents: 67
diff changeset
168 return false;
kono
parents: 67
diff changeset
169
kono
parents: 67
diff changeset
170 if (e1->base_address && e2->base_address
kono
parents: 67
diff changeset
171 && !operand_equal_p (e1->base_address, e2->base_address, 0))
kono
parents: 67
diff changeset
172 return false;
kono
parents: 67
diff changeset
173 if (e1->offset && e2->offset
kono
parents: 67
diff changeset
174 && !operand_equal_p (e1->offset, e2->offset, 0))
kono
parents: 67
diff changeset
175 return false;
kono
parents: 67
diff changeset
176 if (e1->init && e2->init
kono
parents: 67
diff changeset
177 && !operand_equal_p (e1->init, e2->init, 0))
kono
parents: 67
diff changeset
178 return false;
kono
parents: 67
diff changeset
179 if (e1->step && e2->step
kono
parents: 67
diff changeset
180 && !operand_equal_p (e1->step, e2->step, 0))
kono
parents: 67
diff changeset
181 return false;
kono
parents: 67
diff changeset
182
kono
parents: 67
diff changeset
183 return true;
kono
parents: 67
diff changeset
184 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
185
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
186 /* List of basic blocks in if-conversion-suitable order. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
187 static basic_block *ifc_bbs;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
188
111
kono
parents: 67
diff changeset
189 /* Hash table to store <DR's innermost loop behavior, DR> pairs. */
kono
parents: 67
diff changeset
190 static hash_map<innermost_loop_behavior_hash,
kono
parents: 67
diff changeset
191 data_reference_p> *innermost_DR_map;
kono
parents: 67
diff changeset
192
kono
parents: 67
diff changeset
193 /* Hash table to store <base reference, DR> pairs. */
kono
parents: 67
diff changeset
194 static hash_map<tree_operand_hash, data_reference_p> *baseref_DR_map;
kono
parents: 67
diff changeset
195
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
196 /* Structure used to predicate basic blocks. This is attached to the
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
197 ->aux field of the BBs in the loop to be if-converted. */
111
kono
parents: 67
diff changeset
198 struct bb_predicate {
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
199
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
200 /* The condition under which this basic block is executed. */
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
201 tree predicate;
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
202
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
203 /* PREDICATE is gimplified, and the sequence of statements is
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
204 recorded here, in order to avoid the duplication of computations
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
205 that occur in previous conditions. See PR44483. */
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
206 gimple_seq predicate_gimplified_stmts;
111
kono
parents: 67
diff changeset
207 };
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
208
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
209 /* Returns true when the basic block BB has a predicate. */
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
210
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
211 static inline bool
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
212 bb_has_predicate (basic_block bb)
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
213 {
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
214 return bb->aux != NULL;
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
215 }
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
216
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
217 /* Returns the gimplified predicate for basic block BB. */
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
218
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
219 static inline tree
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
220 bb_predicate (basic_block bb)
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
221 {
111
kono
parents: 67
diff changeset
222 return ((struct bb_predicate *) bb->aux)->predicate;
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
223 }
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
224
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
225 /* Sets the gimplified predicate COND for basic block BB. */
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
226
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
227 static inline void
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
228 set_bb_predicate (basic_block bb, tree cond)
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
229 {
111
kono
parents: 67
diff changeset
230 gcc_assert ((TREE_CODE (cond) == TRUTH_NOT_EXPR
kono
parents: 67
diff changeset
231 && is_gimple_condexpr (TREE_OPERAND (cond, 0)))
kono
parents: 67
diff changeset
232 || is_gimple_condexpr (cond));
kono
parents: 67
diff changeset
233 ((struct bb_predicate *) bb->aux)->predicate = cond;
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
234 }
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
235
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
236 /* Returns the sequence of statements of the gimplification of the
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
237 predicate for basic block BB. */
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
238
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
239 static inline gimple_seq
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
240 bb_predicate_gimplified_stmts (basic_block bb)
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
241 {
111
kono
parents: 67
diff changeset
242 return ((struct bb_predicate *) bb->aux)->predicate_gimplified_stmts;
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
243 }
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
244
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
245 /* Sets the sequence of statements STMTS of the gimplification of the
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
246 predicate for basic block BB. */
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
247
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
248 static inline void
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
249 set_bb_predicate_gimplified_stmts (basic_block bb, gimple_seq stmts)
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
250 {
111
kono
parents: 67
diff changeset
251 ((struct bb_predicate *) bb->aux)->predicate_gimplified_stmts = stmts;
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
252 }
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
253
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
254 /* Adds the sequence of statements STMTS to the sequence of statements
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
255 of the predicate for basic block BB. */
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
256
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
257 static inline void
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
258 add_bb_predicate_gimplified_stmts (basic_block bb, gimple_seq stmts)
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
259 {
111
kono
parents: 67
diff changeset
260 gimple_seq_add_seq_without_update
kono
parents: 67
diff changeset
261 (&(((struct bb_predicate *) bb->aux)->predicate_gimplified_stmts), stmts);
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
262 }
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
263
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
264 /* Initializes to TRUE the predicate of basic block BB. */
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
265
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
266 static inline void
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
267 init_bb_predicate (basic_block bb)
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
268 {
111
kono
parents: 67
diff changeset
269 bb->aux = XNEW (struct bb_predicate);
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
270 set_bb_predicate_gimplified_stmts (bb, NULL);
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
271 set_bb_predicate (bb, boolean_true_node);
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
272 }
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
273
111
kono
parents: 67
diff changeset
274 /* Release the SSA_NAMEs associated with the predicate of basic block BB,
kono
parents: 67
diff changeset
275 but don't actually free it. */
kono
parents: 67
diff changeset
276
kono
parents: 67
diff changeset
277 static inline void
kono
parents: 67
diff changeset
278 release_bb_predicate (basic_block bb)
kono
parents: 67
diff changeset
279 {
kono
parents: 67
diff changeset
280 gimple_seq stmts = bb_predicate_gimplified_stmts (bb);
kono
parents: 67
diff changeset
281 if (stmts)
kono
parents: 67
diff changeset
282 {
kono
parents: 67
diff changeset
283 if (flag_checking)
kono
parents: 67
diff changeset
284 for (gimple_stmt_iterator i = gsi_start (stmts);
kono
parents: 67
diff changeset
285 !gsi_end_p (i); gsi_next (&i))
kono
parents: 67
diff changeset
286 gcc_assert (! gimple_use_ops (gsi_stmt (i)));
kono
parents: 67
diff changeset
287
kono
parents: 67
diff changeset
288 set_bb_predicate_gimplified_stmts (bb, NULL);
kono
parents: 67
diff changeset
289 }
kono
parents: 67
diff changeset
290 }
kono
parents: 67
diff changeset
291
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
292 /* Free the predicate of basic block BB. */
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
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
294 static inline void
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
295 free_bb_predicate (basic_block bb)
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
296 {
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
297 if (!bb_has_predicate (bb))
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
298 return;
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
299
111
kono
parents: 67
diff changeset
300 release_bb_predicate (bb);
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
301 free (bb->aux);
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
302 bb->aux = NULL;
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
303 }
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
304
111
kono
parents: 67
diff changeset
305 /* Reinitialize predicate of BB with the true predicate. */
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
306
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
307 static inline void
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
308 reset_bb_predicate (basic_block bb)
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
309 {
111
kono
parents: 67
diff changeset
310 if (!bb_has_predicate (bb))
kono
parents: 67
diff changeset
311 init_bb_predicate (bb);
kono
parents: 67
diff changeset
312 else
kono
parents: 67
diff changeset
313 {
kono
parents: 67
diff changeset
314 release_bb_predicate (bb);
kono
parents: 67
diff changeset
315 set_bb_predicate (bb, boolean_true_node);
kono
parents: 67
diff changeset
316 }
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
317 }
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
318
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
319 /* Returns a new SSA_NAME of type TYPE that is assigned the value of
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
320 the expression EXPR. Inserts the statement created for this
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
321 computation before GSI and leaves the iterator GSI at the same
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
322 statement. */
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
323
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
324 static tree
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
325 ifc_temp_var (tree type, tree expr, gimple_stmt_iterator *gsi)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
326 {
111
kono
parents: 67
diff changeset
327 tree new_name = make_temp_ssa_name (type, NULL, "_ifc_");
kono
parents: 67
diff changeset
328 gimple *stmt = gimple_build_assign (new_name, expr);
kono
parents: 67
diff changeset
329 gimple_set_vuse (stmt, gimple_vuse (gsi_stmt (*gsi)));
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
330 gsi_insert_before (gsi, stmt, GSI_SAME_STMT);
111
kono
parents: 67
diff changeset
331 return new_name;
kono
parents: 67
diff changeset
332 }
kono
parents: 67
diff changeset
333
kono
parents: 67
diff changeset
334 /* Return true when COND is a false predicate. */
kono
parents: 67
diff changeset
335
kono
parents: 67
diff changeset
336 static inline bool
kono
parents: 67
diff changeset
337 is_false_predicate (tree cond)
kono
parents: 67
diff changeset
338 {
kono
parents: 67
diff changeset
339 return (cond != NULL_TREE
kono
parents: 67
diff changeset
340 && (cond == boolean_false_node
kono
parents: 67
diff changeset
341 || integer_zerop (cond)));
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
342 }
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
343
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
344 /* Return true when COND is a true predicate. */
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
345
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
346 static inline bool
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
347 is_true_predicate (tree cond)
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
348 {
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
349 return (cond == NULL_TREE
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
350 || cond == boolean_true_node
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
351 || integer_onep (cond));
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
352 }
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
353
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
354 /* Returns true when BB has a predicate that is not trivial: true or
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
355 NULL_TREE. */
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
356
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
357 static inline bool
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
358 is_predicated (basic_block bb)
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
359 {
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
360 return !is_true_predicate (bb_predicate (bb));
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
361 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
362
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
363 /* Parses the predicate COND and returns its comparison code and
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
364 operands OP0 and OP1. */
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
365
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
366 static enum tree_code
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
367 parse_predicate (tree cond, tree *op0, tree *op1)
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
368 {
111
kono
parents: 67
diff changeset
369 gimple *s;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
370
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
371 if (TREE_CODE (cond) == SSA_NAME
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
372 && is_gimple_assign (s = SSA_NAME_DEF_STMT (cond)))
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
373 {
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
374 if (TREE_CODE_CLASS (gimple_assign_rhs_code (s)) == tcc_comparison)
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
375 {
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
376 *op0 = gimple_assign_rhs1 (s);
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
377 *op1 = gimple_assign_rhs2 (s);
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
378 return gimple_assign_rhs_code (s);
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
379 }
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
380
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
381 else if (gimple_assign_rhs_code (s) == TRUTH_NOT_EXPR)
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
382 {
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
383 tree op = gimple_assign_rhs1 (s);
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
384 tree type = TREE_TYPE (op);
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
385 enum tree_code code = parse_predicate (op, op0, op1);
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
386
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
387 return code == ERROR_MARK ? ERROR_MARK
111
kono
parents: 67
diff changeset
388 : invert_tree_comparison (code, HONOR_NANS (type));
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
389 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
390
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
391 return ERROR_MARK;
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
392 }
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
393
111
kono
parents: 67
diff changeset
394 if (COMPARISON_CLASS_P (cond))
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
395 {
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
396 *op0 = TREE_OPERAND (cond, 0);
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
397 *op1 = TREE_OPERAND (cond, 1);
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
398 return TREE_CODE (cond);
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
399 }
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
400
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
401 return ERROR_MARK;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
402 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
403
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
404 /* Returns the fold of predicate C1 OR C2 at location LOC. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
405
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
406 static tree
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
407 fold_or_predicates (location_t loc, tree c1, tree c2)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
408 {
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
409 tree op1a, op1b, op2a, op2b;
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
410 enum tree_code code1 = parse_predicate (c1, &op1a, &op1b);
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
411 enum tree_code code2 = parse_predicate (c2, &op2a, &op2b);
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
412
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
413 if (code1 != ERROR_MARK && code2 != ERROR_MARK)
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
414 {
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
415 tree t = maybe_fold_or_comparisons (code1, op1a, op1b,
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
416 code2, op2a, op2b);
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
417 if (t)
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
418 return t;
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
419 }
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
420
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
421 return fold_build2_loc (loc, TRUTH_OR_EXPR, boolean_type_node, c1, c2);
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
422 }
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
423
111
kono
parents: 67
diff changeset
424 /* Returns either a COND_EXPR or the folded expression if the folded
kono
parents: 67
diff changeset
425 expression is a MIN_EXPR, a MAX_EXPR, an ABS_EXPR,
kono
parents: 67
diff changeset
426 a constant or a SSA_NAME. */
kono
parents: 67
diff changeset
427
kono
parents: 67
diff changeset
428 static tree
kono
parents: 67
diff changeset
429 fold_build_cond_expr (tree type, tree cond, tree rhs, tree lhs)
kono
parents: 67
diff changeset
430 {
kono
parents: 67
diff changeset
431 tree rhs1, lhs1, cond_expr;
kono
parents: 67
diff changeset
432
kono
parents: 67
diff changeset
433 /* If COND is comparison r != 0 and r has boolean type, convert COND
kono
parents: 67
diff changeset
434 to SSA_NAME to accept by vect bool pattern. */
kono
parents: 67
diff changeset
435 if (TREE_CODE (cond) == NE_EXPR)
kono
parents: 67
diff changeset
436 {
kono
parents: 67
diff changeset
437 tree op0 = TREE_OPERAND (cond, 0);
kono
parents: 67
diff changeset
438 tree op1 = TREE_OPERAND (cond, 1);
kono
parents: 67
diff changeset
439 if (TREE_CODE (op0) == SSA_NAME
kono
parents: 67
diff changeset
440 && TREE_CODE (TREE_TYPE (op0)) == BOOLEAN_TYPE
kono
parents: 67
diff changeset
441 && (integer_zerop (op1)))
kono
parents: 67
diff changeset
442 cond = op0;
kono
parents: 67
diff changeset
443 }
kono
parents: 67
diff changeset
444 cond_expr = fold_ternary (COND_EXPR, type, cond, rhs, lhs);
kono
parents: 67
diff changeset
445
kono
parents: 67
diff changeset
446 if (cond_expr == NULL_TREE)
kono
parents: 67
diff changeset
447 return build3 (COND_EXPR, type, cond, rhs, lhs);
kono
parents: 67
diff changeset
448
kono
parents: 67
diff changeset
449 STRIP_USELESS_TYPE_CONVERSION (cond_expr);
kono
parents: 67
diff changeset
450
kono
parents: 67
diff changeset
451 if (is_gimple_val (cond_expr))
kono
parents: 67
diff changeset
452 return cond_expr;
kono
parents: 67
diff changeset
453
kono
parents: 67
diff changeset
454 if (TREE_CODE (cond_expr) == ABS_EXPR)
kono
parents: 67
diff changeset
455 {
kono
parents: 67
diff changeset
456 rhs1 = TREE_OPERAND (cond_expr, 1);
kono
parents: 67
diff changeset
457 STRIP_USELESS_TYPE_CONVERSION (rhs1);
kono
parents: 67
diff changeset
458 if (is_gimple_val (rhs1))
kono
parents: 67
diff changeset
459 return build1 (ABS_EXPR, type, rhs1);
kono
parents: 67
diff changeset
460 }
kono
parents: 67
diff changeset
461
kono
parents: 67
diff changeset
462 if (TREE_CODE (cond_expr) == MIN_EXPR
kono
parents: 67
diff changeset
463 || TREE_CODE (cond_expr) == MAX_EXPR)
kono
parents: 67
diff changeset
464 {
kono
parents: 67
diff changeset
465 lhs1 = TREE_OPERAND (cond_expr, 0);
kono
parents: 67
diff changeset
466 STRIP_USELESS_TYPE_CONVERSION (lhs1);
kono
parents: 67
diff changeset
467 rhs1 = TREE_OPERAND (cond_expr, 1);
kono
parents: 67
diff changeset
468 STRIP_USELESS_TYPE_CONVERSION (rhs1);
kono
parents: 67
diff changeset
469 if (is_gimple_val (rhs1) && is_gimple_val (lhs1))
kono
parents: 67
diff changeset
470 return build2 (TREE_CODE (cond_expr), type, lhs1, rhs1);
kono
parents: 67
diff changeset
471 }
kono
parents: 67
diff changeset
472 return build3 (COND_EXPR, type, cond, rhs, lhs);
kono
parents: 67
diff changeset
473 }
kono
parents: 67
diff changeset
474
kono
parents: 67
diff changeset
475 /* Add condition NC to the predicate list of basic block BB. LOOP is
kono
parents: 67
diff changeset
476 the loop to be if-converted. Use predicate of cd-equivalent block
kono
parents: 67
diff changeset
477 for join bb if it exists: we call basic blocks bb1 and bb2
kono
parents: 67
diff changeset
478 cd-equivalent if they are executed under the same condition. */
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
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 static inline void
111
kono
parents: 67
diff changeset
481 add_to_predicate_list (struct loop *loop, basic_block bb, tree nc)
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
482 {
111
kono
parents: 67
diff changeset
483 tree bc, *tp;
kono
parents: 67
diff changeset
484 basic_block dom_bb;
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
485
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
486 if (is_true_predicate (nc))
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
487 return;
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
488
111
kono
parents: 67
diff changeset
489 /* If dominance tells us this basic block is always executed,
kono
parents: 67
diff changeset
490 don't record any predicates for it. */
kono
parents: 67
diff changeset
491 if (dominated_by_p (CDI_DOMINATORS, loop->latch, bb))
kono
parents: 67
diff changeset
492 return;
kono
parents: 67
diff changeset
493
kono
parents: 67
diff changeset
494 dom_bb = get_immediate_dominator (CDI_DOMINATORS, bb);
kono
parents: 67
diff changeset
495 /* We use notion of cd equivalence to get simpler predicate for
kono
parents: 67
diff changeset
496 join block, e.g. if join block has 2 predecessors with predicates
kono
parents: 67
diff changeset
497 p1 & p2 and p1 & !p2, we'd like to get p1 for it instead of
kono
parents: 67
diff changeset
498 p1 & p2 | p1 & !p2. */
kono
parents: 67
diff changeset
499 if (dom_bb != loop->header
kono
parents: 67
diff changeset
500 && get_immediate_dominator (CDI_POST_DOMINATORS, dom_bb) == bb)
kono
parents: 67
diff changeset
501 {
kono
parents: 67
diff changeset
502 gcc_assert (flow_bb_inside_loop_p (loop, dom_bb));
kono
parents: 67
diff changeset
503 bc = bb_predicate (dom_bb);
kono
parents: 67
diff changeset
504 if (!is_true_predicate (bc))
kono
parents: 67
diff changeset
505 set_bb_predicate (bb, bc);
kono
parents: 67
diff changeset
506 else
kono
parents: 67
diff changeset
507 gcc_assert (is_true_predicate (bb_predicate (bb)));
kono
parents: 67
diff changeset
508 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents: 67
diff changeset
509 fprintf (dump_file, "Use predicate of bb#%d for bb#%d\n",
kono
parents: 67
diff changeset
510 dom_bb->index, bb->index);
kono
parents: 67
diff changeset
511 return;
kono
parents: 67
diff changeset
512 }
kono
parents: 67
diff changeset
513
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
514 if (!is_predicated (bb))
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
515 bc = nc;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
516 else
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
517 {
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
518 bc = bb_predicate (bb);
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
519 bc = fold_or_predicates (EXPR_LOCATION (bc), nc, bc);
111
kono
parents: 67
diff changeset
520 if (is_true_predicate (bc))
kono
parents: 67
diff changeset
521 {
kono
parents: 67
diff changeset
522 reset_bb_predicate (bb);
kono
parents: 67
diff changeset
523 return;
kono
parents: 67
diff changeset
524 }
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
525 }
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
526
111
kono
parents: 67
diff changeset
527 /* Allow a TRUTH_NOT_EXPR around the main predicate. */
kono
parents: 67
diff changeset
528 if (TREE_CODE (bc) == TRUTH_NOT_EXPR)
kono
parents: 67
diff changeset
529 tp = &TREE_OPERAND (bc, 0);
kono
parents: 67
diff changeset
530 else
kono
parents: 67
diff changeset
531 tp = &bc;
kono
parents: 67
diff changeset
532 if (!is_gimple_condexpr (*tp))
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
533 {
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
534 gimple_seq stmts;
111
kono
parents: 67
diff changeset
535 *tp = force_gimple_operand_1 (*tp, &stmts, is_gimple_condexpr, NULL_TREE);
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
536 add_bb_predicate_gimplified_stmts (bb, stmts);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
537 }
111
kono
parents: 67
diff changeset
538 set_bb_predicate (bb, bc);
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
539 }
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
540
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
541 /* Add the condition COND to the previous condition PREV_COND, and add
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
542 this to the predicate list of the destination of edge E. LOOP is
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
543 the loop to be if-converted. */
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
544
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
545 static void
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
546 add_to_dst_predicate_list (struct loop *loop, edge e,
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
547 tree prev_cond, tree cond)
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
548 {
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
549 if (!flow_bb_inside_loop_p (loop, e->dest))
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
550 return;
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
551
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
552 if (!is_true_predicate (prev_cond))
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
553 cond = fold_build2 (TRUTH_AND_EXPR, boolean_type_node,
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
554 prev_cond, cond);
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
555
111
kono
parents: 67
diff changeset
556 if (!dominated_by_p (CDI_DOMINATORS, loop->latch, e->dest))
kono
parents: 67
diff changeset
557 add_to_predicate_list (loop, e->dest, cond);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
558 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
559
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
560 /* Return true if one of the successor edges of BB exits LOOP. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
561
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
562 static bool
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
563 bb_with_exit_edge_p (struct loop *loop, basic_block bb)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
564 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
565 edge e;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
566 edge_iterator ei;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
567
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
568 FOR_EACH_EDGE (e, ei, bb->succs)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
569 if (loop_exit_edge_p (loop, e))
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
570 return true;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
571
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
572 return false;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
573 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
574
111
kono
parents: 67
diff changeset
575 /* Given PHI which has more than two arguments, this function checks if
kono
parents: 67
diff changeset
576 it's if-convertible by degenerating its arguments. Specifically, if
kono
parents: 67
diff changeset
577 below two conditions are satisfied:
kono
parents: 67
diff changeset
578
kono
parents: 67
diff changeset
579 1) Number of PHI arguments with different values equals to 2 and one
kono
parents: 67
diff changeset
580 argument has the only occurrence.
kono
parents: 67
diff changeset
581 2) The edge corresponding to the unique argument isn't critical edge.
kono
parents: 67
diff changeset
582
kono
parents: 67
diff changeset
583 Such PHI can be handled as PHIs have only two arguments. For example,
kono
parents: 67
diff changeset
584 below PHI:
kono
parents: 67
diff changeset
585
kono
parents: 67
diff changeset
586 res = PHI <A_1(e1), A_1(e2), A_2(e3)>;
kono
parents: 67
diff changeset
587
kono
parents: 67
diff changeset
588 can be transformed into:
kono
parents: 67
diff changeset
589
kono
parents: 67
diff changeset
590 res = (predicate of e3) ? A_2 : A_1;
kono
parents: 67
diff changeset
591
kono
parents: 67
diff changeset
592 Return TRUE if it is the case, FALSE otherwise. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
593
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
594 static bool
111
kono
parents: 67
diff changeset
595 phi_convertible_by_degenerating_args (gphi *phi)
kono
parents: 67
diff changeset
596 {
kono
parents: 67
diff changeset
597 edge e;
kono
parents: 67
diff changeset
598 tree arg, t1 = NULL, t2 = NULL;
kono
parents: 67
diff changeset
599 unsigned int i, i1 = 0, i2 = 0, n1 = 0, n2 = 0;
kono
parents: 67
diff changeset
600 unsigned int num_args = gimple_phi_num_args (phi);
kono
parents: 67
diff changeset
601
kono
parents: 67
diff changeset
602 gcc_assert (num_args > 2);
kono
parents: 67
diff changeset
603
kono
parents: 67
diff changeset
604 for (i = 0; i < num_args; i++)
kono
parents: 67
diff changeset
605 {
kono
parents: 67
diff changeset
606 arg = gimple_phi_arg_def (phi, i);
kono
parents: 67
diff changeset
607 if (t1 == NULL || operand_equal_p (t1, arg, 0))
kono
parents: 67
diff changeset
608 {
kono
parents: 67
diff changeset
609 n1++;
kono
parents: 67
diff changeset
610 i1 = i;
kono
parents: 67
diff changeset
611 t1 = arg;
kono
parents: 67
diff changeset
612 }
kono
parents: 67
diff changeset
613 else if (t2 == NULL || operand_equal_p (t2, arg, 0))
kono
parents: 67
diff changeset
614 {
kono
parents: 67
diff changeset
615 n2++;
kono
parents: 67
diff changeset
616 i2 = i;
kono
parents: 67
diff changeset
617 t2 = arg;
kono
parents: 67
diff changeset
618 }
kono
parents: 67
diff changeset
619 else
kono
parents: 67
diff changeset
620 return false;
kono
parents: 67
diff changeset
621 }
kono
parents: 67
diff changeset
622
kono
parents: 67
diff changeset
623 if (n1 != 1 && n2 != 1)
kono
parents: 67
diff changeset
624 return false;
kono
parents: 67
diff changeset
625
kono
parents: 67
diff changeset
626 /* Check if the edge corresponding to the unique arg is critical. */
kono
parents: 67
diff changeset
627 e = gimple_phi_arg_edge (phi, (n1 == 1) ? i1 : i2);
kono
parents: 67
diff changeset
628 if (EDGE_COUNT (e->src->succs) > 1)
kono
parents: 67
diff changeset
629 return false;
kono
parents: 67
diff changeset
630
kono
parents: 67
diff changeset
631 return true;
kono
parents: 67
diff changeset
632 }
kono
parents: 67
diff changeset
633
kono
parents: 67
diff changeset
634 /* Return true when PHI is if-convertible. PHI is part of loop LOOP
kono
parents: 67
diff changeset
635 and it belongs to basic block BB. Note at this point, it is sure
kono
parents: 67
diff changeset
636 that PHI is if-convertible. This function updates global variable
kono
parents: 67
diff changeset
637 ANY_COMPLICATED_PHI if PHI is complicated. */
kono
parents: 67
diff changeset
638
kono
parents: 67
diff changeset
639 static bool
kono
parents: 67
diff changeset
640 if_convertible_phi_p (struct loop *loop, basic_block bb, gphi *phi)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
641 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
642 if (dump_file && (dump_flags & TDF_DETAILS))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
643 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
644 fprintf (dump_file, "-------------------------\n");
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
645 print_gimple_stmt (dump_file, phi, 0, TDF_SLIM);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
646 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
647
111
kono
parents: 67
diff changeset
648 if (bb != loop->header
kono
parents: 67
diff changeset
649 && gimple_phi_num_args (phi) > 2
kono
parents: 67
diff changeset
650 && !phi_convertible_by_degenerating_args (phi))
kono
parents: 67
diff changeset
651 any_complicated_phi = true;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
652
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
653 return true;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
654 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
655
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
656 /* Records the status of a data reference. This struct is attached to
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
657 each DR->aux field. */
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
658
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
659 struct ifc_dr {
111
kono
parents: 67
diff changeset
660 bool rw_unconditionally;
kono
parents: 67
diff changeset
661 bool w_unconditionally;
kono
parents: 67
diff changeset
662 bool written_at_least_once;
kono
parents: 67
diff changeset
663
kono
parents: 67
diff changeset
664 tree rw_predicate;
kono
parents: 67
diff changeset
665 tree w_predicate;
kono
parents: 67
diff changeset
666 tree base_w_predicate;
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
667 };
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
668
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
669 #define IFC_DR(DR) ((struct ifc_dr *) (DR)->aux)
111
kono
parents: 67
diff changeset
670 #define DR_BASE_W_UNCONDITIONALLY(DR) (IFC_DR (DR)->written_at_least_once)
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
671 #define DR_RW_UNCONDITIONALLY(DR) (IFC_DR (DR)->rw_unconditionally)
111
kono
parents: 67
diff changeset
672 #define DR_W_UNCONDITIONALLY(DR) (IFC_DR (DR)->w_unconditionally)
kono
parents: 67
diff changeset
673
kono
parents: 67
diff changeset
674 /* Iterates over DR's and stores refs, DR and base refs, DR pairs in
kono
parents: 67
diff changeset
675 HASH tables. While storing them in HASH table, it checks if the
kono
parents: 67
diff changeset
676 reference is unconditionally read or written and stores that as a flag
kono
parents: 67
diff changeset
677 information. For base reference it checks if it is written atlest once
kono
parents: 67
diff changeset
678 unconditionally and stores it as flag information along with DR.
kono
parents: 67
diff changeset
679 In other words for every data reference A in STMT there exist other
kono
parents: 67
diff changeset
680 accesses to a data reference with the same base with predicates that
kono
parents: 67
diff changeset
681 add up (OR-up) to the true predicate: this ensures that the data
kono
parents: 67
diff changeset
682 reference A is touched (read or written) on every iteration of the
kono
parents: 67
diff changeset
683 if-converted loop. */
kono
parents: 67
diff changeset
684 static void
kono
parents: 67
diff changeset
685 hash_memrefs_baserefs_and_store_DRs_read_written_info (data_reference_p a)
kono
parents: 67
diff changeset
686 {
kono
parents: 67
diff changeset
687
kono
parents: 67
diff changeset
688 data_reference_p *master_dr, *base_master_dr;
kono
parents: 67
diff changeset
689 tree base_ref = DR_BASE_OBJECT (a);
kono
parents: 67
diff changeset
690 innermost_loop_behavior *innermost = &DR_INNERMOST (a);
kono
parents: 67
diff changeset
691 tree ca = bb_predicate (gimple_bb (DR_STMT (a)));
kono
parents: 67
diff changeset
692 bool exist1, exist2;
kono
parents: 67
diff changeset
693
kono
parents: 67
diff changeset
694 master_dr = &innermost_DR_map->get_or_insert (innermost, &exist1);
kono
parents: 67
diff changeset
695 if (!exist1)
kono
parents: 67
diff changeset
696 *master_dr = a;
kono
parents: 67
diff changeset
697
kono
parents: 67
diff changeset
698 if (DR_IS_WRITE (a))
kono
parents: 67
diff changeset
699 {
kono
parents: 67
diff changeset
700 IFC_DR (*master_dr)->w_predicate
kono
parents: 67
diff changeset
701 = fold_or_predicates (UNKNOWN_LOCATION, ca,
kono
parents: 67
diff changeset
702 IFC_DR (*master_dr)->w_predicate);
kono
parents: 67
diff changeset
703 if (is_true_predicate (IFC_DR (*master_dr)->w_predicate))
kono
parents: 67
diff changeset
704 DR_W_UNCONDITIONALLY (*master_dr) = true;
kono
parents: 67
diff changeset
705 }
kono
parents: 67
diff changeset
706 IFC_DR (*master_dr)->rw_predicate
kono
parents: 67
diff changeset
707 = fold_or_predicates (UNKNOWN_LOCATION, ca,
kono
parents: 67
diff changeset
708 IFC_DR (*master_dr)->rw_predicate);
kono
parents: 67
diff changeset
709 if (is_true_predicate (IFC_DR (*master_dr)->rw_predicate))
kono
parents: 67
diff changeset
710 DR_RW_UNCONDITIONALLY (*master_dr) = true;
kono
parents: 67
diff changeset
711
kono
parents: 67
diff changeset
712 if (DR_IS_WRITE (a))
kono
parents: 67
diff changeset
713 {
kono
parents: 67
diff changeset
714 base_master_dr = &baseref_DR_map->get_or_insert (base_ref, &exist2);
kono
parents: 67
diff changeset
715 if (!exist2)
kono
parents: 67
diff changeset
716 *base_master_dr = a;
kono
parents: 67
diff changeset
717 IFC_DR (*base_master_dr)->base_w_predicate
kono
parents: 67
diff changeset
718 = fold_or_predicates (UNKNOWN_LOCATION, ca,
kono
parents: 67
diff changeset
719 IFC_DR (*base_master_dr)->base_w_predicate);
kono
parents: 67
diff changeset
720 if (is_true_predicate (IFC_DR (*base_master_dr)->base_w_predicate))
kono
parents: 67
diff changeset
721 DR_BASE_W_UNCONDITIONALLY (*base_master_dr) = true;
kono
parents: 67
diff changeset
722 }
kono
parents: 67
diff changeset
723 }
kono
parents: 67
diff changeset
724
kono
parents: 67
diff changeset
725 /* Return TRUE if can prove the index IDX of an array reference REF is
kono
parents: 67
diff changeset
726 within array bound. Return false otherwise. */
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
727
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
728 static bool
111
kono
parents: 67
diff changeset
729 idx_within_array_bound (tree ref, tree *idx, void *dta)
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
730 {
111
kono
parents: 67
diff changeset
731 bool overflow;
kono
parents: 67
diff changeset
732 widest_int niter, valid_niter, delta, wi_step;
kono
parents: 67
diff changeset
733 tree ev, init, step;
kono
parents: 67
diff changeset
734 tree low, high;
kono
parents: 67
diff changeset
735 struct loop *loop = (struct loop*) dta;
kono
parents: 67
diff changeset
736
kono
parents: 67
diff changeset
737 /* Only support within-bound access for array references. */
kono
parents: 67
diff changeset
738 if (TREE_CODE (ref) != ARRAY_REF)
kono
parents: 67
diff changeset
739 return false;
kono
parents: 67
diff changeset
740
kono
parents: 67
diff changeset
741 /* For arrays at the end of the structure, we are not guaranteed that they
kono
parents: 67
diff changeset
742 do not really extend over their declared size. However, for arrays of
kono
parents: 67
diff changeset
743 size greater than one, this is unlikely to be intended. */
kono
parents: 67
diff changeset
744 if (array_at_struct_end_p (ref))
kono
parents: 67
diff changeset
745 return false;
kono
parents: 67
diff changeset
746
kono
parents: 67
diff changeset
747 ev = analyze_scalar_evolution (loop, *idx);
kono
parents: 67
diff changeset
748 ev = instantiate_parameters (loop, ev);
kono
parents: 67
diff changeset
749 init = initial_condition (ev);
kono
parents: 67
diff changeset
750 step = evolution_part_in_loop_num (ev, loop->num);
kono
parents: 67
diff changeset
751
kono
parents: 67
diff changeset
752 if (!init || TREE_CODE (init) != INTEGER_CST
kono
parents: 67
diff changeset
753 || (step && TREE_CODE (step) != INTEGER_CST))
kono
parents: 67
diff changeset
754 return false;
kono
parents: 67
diff changeset
755
kono
parents: 67
diff changeset
756 low = array_ref_low_bound (ref);
kono
parents: 67
diff changeset
757 high = array_ref_up_bound (ref);
kono
parents: 67
diff changeset
758
kono
parents: 67
diff changeset
759 /* The case of nonconstant bounds could be handled, but it would be
kono
parents: 67
diff changeset
760 complicated. */
kono
parents: 67
diff changeset
761 if (TREE_CODE (low) != INTEGER_CST
kono
parents: 67
diff changeset
762 || !high || TREE_CODE (high) != INTEGER_CST)
kono
parents: 67
diff changeset
763 return false;
kono
parents: 67
diff changeset
764
kono
parents: 67
diff changeset
765 /* Check if the intial idx is within bound. */
kono
parents: 67
diff changeset
766 if (wi::to_widest (init) < wi::to_widest (low)
kono
parents: 67
diff changeset
767 || wi::to_widest (init) > wi::to_widest (high))
kono
parents: 67
diff changeset
768 return false;
kono
parents: 67
diff changeset
769
kono
parents: 67
diff changeset
770 /* The idx is always within bound. */
kono
parents: 67
diff changeset
771 if (!step || integer_zerop (step))
kono
parents: 67
diff changeset
772 return true;
kono
parents: 67
diff changeset
773
kono
parents: 67
diff changeset
774 if (!max_loop_iterations (loop, &niter))
kono
parents: 67
diff changeset
775 return false;
kono
parents: 67
diff changeset
776
kono
parents: 67
diff changeset
777 if (wi::to_widest (step) < 0)
kono
parents: 67
diff changeset
778 {
kono
parents: 67
diff changeset
779 delta = wi::to_widest (init) - wi::to_widest (low);
kono
parents: 67
diff changeset
780 wi_step = -wi::to_widest (step);
kono
parents: 67
diff changeset
781 }
kono
parents: 67
diff changeset
782 else
kono
parents: 67
diff changeset
783 {
kono
parents: 67
diff changeset
784 delta = wi::to_widest (high) - wi::to_widest (init);
kono
parents: 67
diff changeset
785 wi_step = wi::to_widest (step);
kono
parents: 67
diff changeset
786 }
kono
parents: 67
diff changeset
787
kono
parents: 67
diff changeset
788 valid_niter = wi::div_floor (delta, wi_step, SIGNED, &overflow);
kono
parents: 67
diff changeset
789 /* The iteration space of idx is within array bound. */
kono
parents: 67
diff changeset
790 if (!overflow && niter <= valid_niter)
kono
parents: 67
diff changeset
791 return true;
kono
parents: 67
diff changeset
792
kono
parents: 67
diff changeset
793 return false;
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
794 }
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
795
111
kono
parents: 67
diff changeset
796 /* Return TRUE if ref is a within bound array reference. */
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
797
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
798 static bool
111
kono
parents: 67
diff changeset
799 ref_within_array_bound (gimple *stmt, tree ref)
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
800 {
111
kono
parents: 67
diff changeset
801 struct loop *loop = loop_containing_stmt (stmt);
kono
parents: 67
diff changeset
802
kono
parents: 67
diff changeset
803 gcc_assert (loop != NULL);
kono
parents: 67
diff changeset
804 return for_each_index (&ref, idx_within_array_bound, loop);
kono
parents: 67
diff changeset
805 }
kono
parents: 67
diff changeset
806
kono
parents: 67
diff changeset
807
kono
parents: 67
diff changeset
808 /* Given a memory reference expression T, return TRUE if base object
kono
parents: 67
diff changeset
809 it refers to is writable. The base object of a memory reference
kono
parents: 67
diff changeset
810 is the main object being referenced, which is returned by function
kono
parents: 67
diff changeset
811 get_base_address. */
kono
parents: 67
diff changeset
812
kono
parents: 67
diff changeset
813 static bool
kono
parents: 67
diff changeset
814 base_object_writable (tree ref)
kono
parents: 67
diff changeset
815 {
kono
parents: 67
diff changeset
816 tree base_tree = get_base_address (ref);
kono
parents: 67
diff changeset
817
kono
parents: 67
diff changeset
818 return (base_tree
kono
parents: 67
diff changeset
819 && DECL_P (base_tree)
kono
parents: 67
diff changeset
820 && decl_binds_to_current_def_p (base_tree)
kono
parents: 67
diff changeset
821 && !TREE_READONLY (base_tree));
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
822 }
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
823
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
824 /* Return true when the memory references of STMT won't trap in the
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
825 if-converted code. There are two things that we have to check for:
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
826
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
827 - writes to memory occur to writable memory: if-conversion of
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
828 memory writes transforms the conditional memory writes into
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
829 unconditional writes, i.e. "if (cond) A[i] = foo" is transformed
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
830 into "A[i] = cond ? foo : A[i]", and as the write to memory may not
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
831 be executed at all in the original code, it may be a readonly
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
832 memory. To check that A is not const-qualified, we check that
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
833 there exists at least an unconditional write to A in the current
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
834 function.
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
835
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
836 - reads or writes to memory are valid memory accesses for every
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
837 iteration. To check that the memory accesses are correctly formed
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
838 and that we are allowed to read and write in these locations, we
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
839 check that the memory accesses to be if-converted occur at every
111
kono
parents: 67
diff changeset
840 iteration unconditionally.
kono
parents: 67
diff changeset
841
kono
parents: 67
diff changeset
842 Returns true for the memory reference in STMT, same memory reference
kono
parents: 67
diff changeset
843 is read or written unconditionally atleast once and the base memory
kono
parents: 67
diff changeset
844 reference is written unconditionally once. This is to check reference
kono
parents: 67
diff changeset
845 will not write fault. Also retuns true if the memory reference is
kono
parents: 67
diff changeset
846 unconditionally read once then we are conditionally writing to memory
kono
parents: 67
diff changeset
847 which is defined as read and write and is bound to the definition
kono
parents: 67
diff changeset
848 we are seeing. */
kono
parents: 67
diff changeset
849 static bool
kono
parents: 67
diff changeset
850 ifcvt_memrefs_wont_trap (gimple *stmt, vec<data_reference_p> drs)
kono
parents: 67
diff changeset
851 {
kono
parents: 67
diff changeset
852 data_reference_p *master_dr, *base_master_dr;
kono
parents: 67
diff changeset
853 data_reference_p a = drs[gimple_uid (stmt) - 1];
kono
parents: 67
diff changeset
854
kono
parents: 67
diff changeset
855 tree base = DR_BASE_OBJECT (a);
kono
parents: 67
diff changeset
856 innermost_loop_behavior *innermost = &DR_INNERMOST (a);
kono
parents: 67
diff changeset
857
kono
parents: 67
diff changeset
858 gcc_assert (DR_STMT (a) == stmt);
kono
parents: 67
diff changeset
859 gcc_assert (DR_BASE_ADDRESS (a) || DR_OFFSET (a)
kono
parents: 67
diff changeset
860 || DR_INIT (a) || DR_STEP (a));
kono
parents: 67
diff changeset
861
kono
parents: 67
diff changeset
862 master_dr = innermost_DR_map->get (innermost);
kono
parents: 67
diff changeset
863 gcc_assert (master_dr != NULL);
kono
parents: 67
diff changeset
864
kono
parents: 67
diff changeset
865 base_master_dr = baseref_DR_map->get (base);
kono
parents: 67
diff changeset
866
kono
parents: 67
diff changeset
867 /* If a is unconditionally written to it doesn't trap. */
kono
parents: 67
diff changeset
868 if (DR_W_UNCONDITIONALLY (*master_dr))
kono
parents: 67
diff changeset
869 return true;
kono
parents: 67
diff changeset
870
kono
parents: 67
diff changeset
871 /* If a is unconditionally accessed then ...
kono
parents: 67
diff changeset
872
kono
parents: 67
diff changeset
873 Even a is conditional access, we can treat it as an unconditional
kono
parents: 67
diff changeset
874 one if it's an array reference and all its index are within array
kono
parents: 67
diff changeset
875 bound. */
kono
parents: 67
diff changeset
876 if (DR_RW_UNCONDITIONALLY (*master_dr)
kono
parents: 67
diff changeset
877 || ref_within_array_bound (stmt, DR_REF (a)))
kono
parents: 67
diff changeset
878 {
kono
parents: 67
diff changeset
879 /* an unconditional read won't trap. */
kono
parents: 67
diff changeset
880 if (DR_IS_READ (a))
kono
parents: 67
diff changeset
881 return true;
kono
parents: 67
diff changeset
882
kono
parents: 67
diff changeset
883 /* an unconditionaly write won't trap if the base is written
kono
parents: 67
diff changeset
884 to unconditionally. */
kono
parents: 67
diff changeset
885 if (base_master_dr
kono
parents: 67
diff changeset
886 && DR_BASE_W_UNCONDITIONALLY (*base_master_dr))
kono
parents: 67
diff changeset
887 return PARAM_VALUE (PARAM_ALLOW_STORE_DATA_RACES);
kono
parents: 67
diff changeset
888 /* or the base is known to be not readonly. */
kono
parents: 67
diff changeset
889 else if (base_object_writable (DR_REF (a)))
kono
parents: 67
diff changeset
890 return PARAM_VALUE (PARAM_ALLOW_STORE_DATA_RACES);
kono
parents: 67
diff changeset
891 }
kono
parents: 67
diff changeset
892
kono
parents: 67
diff changeset
893 return false;
kono
parents: 67
diff changeset
894 }
kono
parents: 67
diff changeset
895
kono
parents: 67
diff changeset
896 /* Return true if STMT could be converted into a masked load or store
kono
parents: 67
diff changeset
897 (conditional load or store based on a mask computed from bb predicate). */
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
898
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
899 static bool
111
kono
parents: 67
diff changeset
900 ifcvt_can_use_mask_load_store (gimple *stmt)
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
901 {
111
kono
parents: 67
diff changeset
902 tree lhs, ref;
kono
parents: 67
diff changeset
903 machine_mode mode;
kono
parents: 67
diff changeset
904 basic_block bb = gimple_bb (stmt);
kono
parents: 67
diff changeset
905 bool is_load;
kono
parents: 67
diff changeset
906
kono
parents: 67
diff changeset
907 if (!(flag_tree_loop_vectorize || bb->loop_father->force_vectorize)
kono
parents: 67
diff changeset
908 || bb->loop_father->dont_vectorize
kono
parents: 67
diff changeset
909 || !gimple_assign_single_p (stmt)
kono
parents: 67
diff changeset
910 || gimple_has_volatile_ops (stmt))
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
911 return false;
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
912
111
kono
parents: 67
diff changeset
913 /* Check whether this is a load or store. */
kono
parents: 67
diff changeset
914 lhs = gimple_assign_lhs (stmt);
kono
parents: 67
diff changeset
915 if (gimple_store_p (stmt))
kono
parents: 67
diff changeset
916 {
kono
parents: 67
diff changeset
917 if (!is_gimple_val (gimple_assign_rhs1 (stmt)))
kono
parents: 67
diff changeset
918 return false;
kono
parents: 67
diff changeset
919 is_load = false;
kono
parents: 67
diff changeset
920 ref = lhs;
kono
parents: 67
diff changeset
921 }
kono
parents: 67
diff changeset
922 else if (gimple_assign_load_p (stmt))
kono
parents: 67
diff changeset
923 {
kono
parents: 67
diff changeset
924 is_load = true;
kono
parents: 67
diff changeset
925 ref = gimple_assign_rhs1 (stmt);
kono
parents: 67
diff changeset
926 }
kono
parents: 67
diff changeset
927 else
kono
parents: 67
diff changeset
928 return false;
kono
parents: 67
diff changeset
929
kono
parents: 67
diff changeset
930 if (may_be_nonaddressable_p (ref))
kono
parents: 67
diff changeset
931 return false;
kono
parents: 67
diff changeset
932
kono
parents: 67
diff changeset
933 /* Mask should be integer mode of the same size as the load/store
kono
parents: 67
diff changeset
934 mode. */
kono
parents: 67
diff changeset
935 mode = TYPE_MODE (TREE_TYPE (lhs));
kono
parents: 67
diff changeset
936 if (!int_mode_for_mode (mode).exists () || VECTOR_MODE_P (mode))
kono
parents: 67
diff changeset
937 return false;
kono
parents: 67
diff changeset
938
kono
parents: 67
diff changeset
939 if (can_vec_mask_load_store_p (mode, VOIDmode, is_load))
kono
parents: 67
diff changeset
940 return true;
kono
parents: 67
diff changeset
941
kono
parents: 67
diff changeset
942 return false;
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
943 }
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
944
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
945 /* Return true when STMT is if-convertible.
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
946
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
947 GIMPLE_ASSIGN statement is not if-convertible if,
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
948 - it is not movable,
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
949 - it could trap,
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
950 - LHS is not var decl. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
951
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
952 static bool
111
kono
parents: 67
diff changeset
953 if_convertible_gimple_assign_stmt_p (gimple *stmt,
kono
parents: 67
diff changeset
954 vec<data_reference_p> refs)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
955 {
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
956 tree lhs = gimple_assign_lhs (stmt);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
957
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
958 if (dump_file && (dump_flags & TDF_DETAILS))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
959 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
960 fprintf (dump_file, "-------------------------\n");
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
961 print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
962 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
963
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
964 if (!is_gimple_reg_type (TREE_TYPE (lhs)))
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
965 return false;
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
966
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
967 /* Some of these constrains might be too conservative. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
968 if (stmt_ends_bb_p (stmt)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
969 || gimple_has_volatile_ops (stmt)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
970 || (TREE_CODE (lhs) == SSA_NAME
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
971 && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (lhs))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
972 || gimple_has_side_effects (stmt))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
973 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
974 if (dump_file && (dump_flags & TDF_DETAILS))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
975 fprintf (dump_file, "stmt not suitable for ifcvt\n");
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
976 return false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
977 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
978
111
kono
parents: 67
diff changeset
979 /* tree-into-ssa.c uses GF_PLF_1, so avoid it, because
kono
parents: 67
diff changeset
980 in between if_convertible_loop_p and combine_blocks
kono
parents: 67
diff changeset
981 we can perform loop versioning. */
kono
parents: 67
diff changeset
982 gimple_set_plf (stmt, GF_PLF_2, false);
kono
parents: 67
diff changeset
983
kono
parents: 67
diff changeset
984 if ((! gimple_vuse (stmt)
kono
parents: 67
diff changeset
985 || gimple_could_trap_p_1 (stmt, false, false)
kono
parents: 67
diff changeset
986 || ! ifcvt_memrefs_wont_trap (stmt, refs))
kono
parents: 67
diff changeset
987 && gimple_could_trap_p (stmt))
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
988 {
111
kono
parents: 67
diff changeset
989 if (ifcvt_can_use_mask_load_store (stmt))
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
990 {
111
kono
parents: 67
diff changeset
991 gimple_set_plf (stmt, GF_PLF_2, true);
kono
parents: 67
diff changeset
992 any_pred_load_store = true;
kono
parents: 67
diff changeset
993 return true;
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
994 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
995 if (dump_file && (dump_flags & TDF_DETAILS))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
996 fprintf (dump_file, "tree could trap...\n");
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
997 return false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
998 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
999
111
kono
parents: 67
diff changeset
1000 /* When if-converting stores force versioning, likewise if we
kono
parents: 67
diff changeset
1001 ended up generating store data races. */
kono
parents: 67
diff changeset
1002 if (gimple_vdef (stmt))
kono
parents: 67
diff changeset
1003 any_pred_load_store = true;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1004
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1005 return true;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1006 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1007
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1008 /* Return true when STMT is if-convertible.
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1009
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1010 A statement is if-convertible if:
111
kono
parents: 67
diff changeset
1011 - it is an if-convertible GIMPLE_ASSIGN,
kono
parents: 67
diff changeset
1012 - it is a GIMPLE_LABEL or a GIMPLE_COND,
kono
parents: 67
diff changeset
1013 - it is builtins call. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1014
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1015 static bool
111
kono
parents: 67
diff changeset
1016 if_convertible_stmt_p (gimple *stmt, vec<data_reference_p> refs)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1017 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1018 switch (gimple_code (stmt))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1019 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1020 case GIMPLE_LABEL:
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1021 case GIMPLE_DEBUG:
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1022 case GIMPLE_COND:
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1023 return true;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1024
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1025 case GIMPLE_ASSIGN:
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
1026 return if_convertible_gimple_assign_stmt_p (stmt, refs);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1027
111
kono
parents: 67
diff changeset
1028 case GIMPLE_CALL:
kono
parents: 67
diff changeset
1029 {
kono
parents: 67
diff changeset
1030 tree fndecl = gimple_call_fndecl (stmt);
kono
parents: 67
diff changeset
1031 if (fndecl)
kono
parents: 67
diff changeset
1032 {
kono
parents: 67
diff changeset
1033 int flags = gimple_call_flags (stmt);
kono
parents: 67
diff changeset
1034 if ((flags & ECF_CONST)
kono
parents: 67
diff changeset
1035 && !(flags & ECF_LOOPING_CONST_OR_PURE)
kono
parents: 67
diff changeset
1036 /* We can only vectorize some builtins at the moment,
kono
parents: 67
diff changeset
1037 so restrict if-conversion to those. */
kono
parents: 67
diff changeset
1038 && DECL_BUILT_IN (fndecl))
kono
parents: 67
diff changeset
1039 return true;
kono
parents: 67
diff changeset
1040 }
kono
parents: 67
diff changeset
1041 return false;
kono
parents: 67
diff changeset
1042 }
kono
parents: 67
diff changeset
1043
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1044 default:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1045 /* Don't know what to do with 'em so don't do anything. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1046 if (dump_file && (dump_flags & TDF_DETAILS))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1047 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1048 fprintf (dump_file, "don't know what to do\n");
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1049 print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1050 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1051 return false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1052 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1053
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1054 return true;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1055 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1056
111
kono
parents: 67
diff changeset
1057 /* Assumes that BB has more than 1 predecessors.
kono
parents: 67
diff changeset
1058 Returns false if at least one successor is not on critical edge
kono
parents: 67
diff changeset
1059 and true otherwise. */
kono
parents: 67
diff changeset
1060
kono
parents: 67
diff changeset
1061 static inline bool
kono
parents: 67
diff changeset
1062 all_preds_critical_p (basic_block bb)
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
1063 {
111
kono
parents: 67
diff changeset
1064 edge e;
kono
parents: 67
diff changeset
1065 edge_iterator ei;
kono
parents: 67
diff changeset
1066
kono
parents: 67
diff changeset
1067 FOR_EACH_EDGE (e, ei, bb->preds)
kono
parents: 67
diff changeset
1068 if (EDGE_COUNT (e->src->succs) == 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
1069 return false;
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
1070 return true;
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
1071 }
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
1072
111
kono
parents: 67
diff changeset
1073 /* Returns true if at least one successor in on critical edge. */
kono
parents: 67
diff changeset
1074 static inline bool
kono
parents: 67
diff changeset
1075 has_pred_critical_p (basic_block bb)
kono
parents: 67
diff changeset
1076 {
kono
parents: 67
diff changeset
1077 edge e;
kono
parents: 67
diff changeset
1078 edge_iterator ei;
kono
parents: 67
diff changeset
1079
kono
parents: 67
diff changeset
1080 FOR_EACH_EDGE (e, ei, bb->preds)
kono
parents: 67
diff changeset
1081 if (EDGE_COUNT (e->src->succs) > 1)
kono
parents: 67
diff changeset
1082 return true;
kono
parents: 67
diff changeset
1083 return false;
kono
parents: 67
diff changeset
1084 }
kono
parents: 67
diff changeset
1085
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1086 /* Return true when BB is if-convertible. This routine does not check
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1087 basic block's statements and phis.
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1088
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1089 A basic block is not if-convertible if:
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1090 - it is non-empty and it is after the exit block (in BFS order),
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1091 - it is after the exit block but before the latch,
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1092 - its edges are not normal.
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1093
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1094 EXIT_BB is the basic block containing the exit of the LOOP. BB is
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1095 inside LOOP. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1096
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1097 static bool
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1098 if_convertible_bb_p (struct loop *loop, basic_block bb, basic_block exit_bb)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1099 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1100 edge e;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1101 edge_iterator ei;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1102
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1103 if (dump_file && (dump_flags & TDF_DETAILS))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1104 fprintf (dump_file, "----------[%d]-------------\n", bb->index);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1105
111
kono
parents: 67
diff changeset
1106 if (EDGE_COUNT (bb->succs) > 2)
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
1107 return false;
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
1108
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1109 if (exit_bb)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1110 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1111 if (bb != loop->latch)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1112 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1113 if (dump_file && (dump_flags & TDF_DETAILS))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1114 fprintf (dump_file, "basic block after exit bb but before latch\n");
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1115 return false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1116 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1117 else if (!empty_block_p (bb))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1118 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1119 if (dump_file && (dump_flags & TDF_DETAILS))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1120 fprintf (dump_file, "non empty basic block after exit bb\n");
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1121 return false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1122 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1123 else if (bb == loop->latch
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1124 && bb != exit_bb
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1125 && !dominated_by_p (CDI_DOMINATORS, bb, exit_bb))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1126 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1127 if (dump_file && (dump_flags & TDF_DETAILS))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1128 fprintf (dump_file, "latch is not dominated by exit_block\n");
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1129 return false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1130 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1131 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1132
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1133 /* Be less adventurous and handle only normal edges. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1134 FOR_EACH_EDGE (e, ei, bb->succs)
111
kono
parents: 67
diff changeset
1135 if (e->flags & (EDGE_EH | EDGE_ABNORMAL | EDGE_IRREDUCIBLE_LOOP))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1136 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1137 if (dump_file && (dump_flags & TDF_DETAILS))
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1138 fprintf (dump_file, "Difficult to handle edges\n");
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1139 return false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1140 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1141
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1142 return true;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1143 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1144
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1145 /* Return true when all predecessor blocks of BB are visited. The
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1146 VISITED bitmap keeps track of the visited blocks. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1147
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1148 static bool
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1149 pred_blocks_visited_p (basic_block bb, bitmap *visited)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1150 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1151 edge e;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1152 edge_iterator ei;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1153 FOR_EACH_EDGE (e, ei, bb->preds)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1154 if (!bitmap_bit_p (*visited, e->src->index))
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1155 return false;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1156
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1157 return true;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1158 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1159
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1160 /* Get body of a LOOP in suitable order for if-conversion. It is
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1161 caller's responsibility to deallocate basic block list.
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1162 If-conversion suitable order is, breadth first sort (BFS) order
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1163 with an additional constraint: select a block only if all its
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1164 predecessors are already selected. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1165
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1166 static basic_block *
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1167 get_loop_body_in_if_conv_order (const struct loop *loop)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1168 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1169 basic_block *blocks, *blocks_in_bfs_order;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1170 basic_block bb;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1171 bitmap visited;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1172 unsigned int index = 0;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1173 unsigned int visited_count = 0;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1174
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1175 gcc_assert (loop->num_nodes);
111
kono
parents: 67
diff changeset
1176 gcc_assert (loop->latch != EXIT_BLOCK_PTR_FOR_FN (cfun));
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1177
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1178 blocks = XCNEWVEC (basic_block, loop->num_nodes);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1179 visited = BITMAP_ALLOC (NULL);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1180
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1181 blocks_in_bfs_order = get_loop_body_in_bfs_order (loop);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1182
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1183 index = 0;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1184 while (index < loop->num_nodes)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1185 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1186 bb = blocks_in_bfs_order [index];
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1187
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1188 if (bb->flags & BB_IRREDUCIBLE_LOOP)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1189 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1190 free (blocks_in_bfs_order);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1191 BITMAP_FREE (visited);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1192 free (blocks);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1193 return NULL;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1194 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1195
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1196 if (!bitmap_bit_p (visited, bb->index))
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1197 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1198 if (pred_blocks_visited_p (bb, &visited)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1199 || bb == loop->header)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1200 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1201 /* This block is now visited. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1202 bitmap_set_bit (visited, bb->index);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1203 blocks[visited_count++] = bb;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1204 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1205 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1206
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1207 index++;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1208
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1209 if (index == loop->num_nodes
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1210 && visited_count != loop->num_nodes)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1211 /* Not done yet. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1212 index = 0;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1213 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1214 free (blocks_in_bfs_order);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1215 BITMAP_FREE (visited);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1216 return blocks;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1217 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1218
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
1219 /* Returns true when the analysis of the predicates for all the basic
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
1220 blocks in LOOP succeeded.
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
1221
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
1222 predicate_bbs first allocates the predicates of the basic blocks.
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
1223 These fields are then initialized with the tree expressions
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
1224 representing the predicates under which a basic block is executed
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
1225 in the LOOP. As the loop->header is executed at each iteration, it
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
1226 has the "true" predicate. Other statements executed under a
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
1227 condition are predicated with that condition, for example
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
1228
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
1229 | if (x)
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
1230 | S1;
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
1231 | else
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
1232 | S2;
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
1233
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
1234 S1 will be predicated with "x", and
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
1235 S2 will be predicated with "!x". */
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
1236
111
kono
parents: 67
diff changeset
1237 static void
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
1238 predicate_bbs (loop_p loop)
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
1239 {
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
1240 unsigned int i;
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
1241
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
1242 for (i = 0; i < loop->num_nodes; i++)
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
1243 init_bb_predicate (ifc_bbs[i]);
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
1244
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
1245 for (i = 0; i < loop->num_nodes; i++)
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
1246 {
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
1247 basic_block bb = ifc_bbs[i];
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
1248 tree cond;
111
kono
parents: 67
diff changeset
1249 gimple *stmt;
kono
parents: 67
diff changeset
1250
kono
parents: 67
diff changeset
1251 /* The loop latch and loop exit block are always executed and
kono
parents: 67
diff changeset
1252 have no extra conditions to be processed: skip them. */
kono
parents: 67
diff changeset
1253 if (bb == loop->latch
kono
parents: 67
diff changeset
1254 || bb_with_exit_edge_p (loop, bb))
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
1255 {
111
kono
parents: 67
diff changeset
1256 reset_bb_predicate (bb);
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
1257 continue;
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
1258 }
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
1259
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
1260 cond = bb_predicate (bb);
111
kono
parents: 67
diff changeset
1261 stmt = last_stmt (bb);
kono
parents: 67
diff changeset
1262 if (stmt && gimple_code (stmt) == GIMPLE_COND)
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
1263 {
111
kono
parents: 67
diff changeset
1264 tree c2;
kono
parents: 67
diff changeset
1265 edge true_edge, false_edge;
kono
parents: 67
diff changeset
1266 location_t loc = gimple_location (stmt);
kono
parents: 67
diff changeset
1267 tree c = build2_loc (loc, gimple_cond_code (stmt),
kono
parents: 67
diff changeset
1268 boolean_type_node,
kono
parents: 67
diff changeset
1269 gimple_cond_lhs (stmt),
kono
parents: 67
diff changeset
1270 gimple_cond_rhs (stmt));
kono
parents: 67
diff changeset
1271
kono
parents: 67
diff changeset
1272 /* Add new condition into destination's predicate list. */
kono
parents: 67
diff changeset
1273 extract_true_false_edges_from_block (gimple_bb (stmt),
kono
parents: 67
diff changeset
1274 &true_edge, &false_edge);
kono
parents: 67
diff changeset
1275
kono
parents: 67
diff changeset
1276 /* If C is true, then TRUE_EDGE is taken. */
kono
parents: 67
diff changeset
1277 add_to_dst_predicate_list (loop, true_edge, unshare_expr (cond),
kono
parents: 67
diff changeset
1278 unshare_expr (c));
kono
parents: 67
diff changeset
1279
kono
parents: 67
diff changeset
1280 /* If C is false, then FALSE_EDGE is taken. */
kono
parents: 67
diff changeset
1281 c2 = build1_loc (loc, TRUTH_NOT_EXPR, boolean_type_node,
kono
parents: 67
diff changeset
1282 unshare_expr (c));
kono
parents: 67
diff changeset
1283 add_to_dst_predicate_list (loop, false_edge,
kono
parents: 67
diff changeset
1284 unshare_expr (cond), c2);
kono
parents: 67
diff changeset
1285
kono
parents: 67
diff changeset
1286 cond = NULL_TREE;
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
1287 }
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
1288
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
1289 /* If current bb has only one successor, then consider it as an
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
1290 unconditional goto. */
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
1291 if (single_succ_p (bb))
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
1292 {
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
1293 basic_block bb_n = single_succ (bb);
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
1294
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
1295 /* The successor bb inherits the predicate of its
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
1296 predecessor. If there is no predicate in the predecessor
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
1297 bb, then consider the successor bb as always executed. */
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
1298 if (cond == NULL_TREE)
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
1299 cond = boolean_true_node;
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
1300
111
kono
parents: 67
diff changeset
1301 add_to_predicate_list (loop, bb_n, cond);
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
1302 }
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
1303 }
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
1304
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
1305 /* The loop header is always executed. */
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
1306 reset_bb_predicate (loop->header);
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
1307 gcc_assert (bb_predicate_gimplified_stmts (loop->header) == NULL
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
1308 && bb_predicate_gimplified_stmts (loop->latch) == NULL);
111
kono
parents: 67
diff changeset
1309 }
kono
parents: 67
diff changeset
1310
kono
parents: 67
diff changeset
1311 /* Build region by adding loop pre-header and post-header blocks. */
kono
parents: 67
diff changeset
1312
kono
parents: 67
diff changeset
1313 static vec<basic_block>
kono
parents: 67
diff changeset
1314 build_region (struct loop *loop)
kono
parents: 67
diff changeset
1315 {
kono
parents: 67
diff changeset
1316 vec<basic_block> region = vNULL;
kono
parents: 67
diff changeset
1317 basic_block exit_bb = NULL;
kono
parents: 67
diff changeset
1318
kono
parents: 67
diff changeset
1319 gcc_assert (ifc_bbs);
kono
parents: 67
diff changeset
1320 /* The first element is loop pre-header. */
kono
parents: 67
diff changeset
1321 region.safe_push (loop_preheader_edge (loop)->src);
kono
parents: 67
diff changeset
1322
kono
parents: 67
diff changeset
1323 for (unsigned int i = 0; i < loop->num_nodes; i++)
kono
parents: 67
diff changeset
1324 {
kono
parents: 67
diff changeset
1325 basic_block bb = ifc_bbs[i];
kono
parents: 67
diff changeset
1326 region.safe_push (bb);
kono
parents: 67
diff changeset
1327 /* Find loop postheader. */
kono
parents: 67
diff changeset
1328 edge e;
kono
parents: 67
diff changeset
1329 edge_iterator ei;
kono
parents: 67
diff changeset
1330 FOR_EACH_EDGE (e, ei, bb->succs)
kono
parents: 67
diff changeset
1331 if (loop_exit_edge_p (loop, e))
kono
parents: 67
diff changeset
1332 {
kono
parents: 67
diff changeset
1333 exit_bb = e->dest;
kono
parents: 67
diff changeset
1334 break;
kono
parents: 67
diff changeset
1335 }
kono
parents: 67
diff changeset
1336 }
kono
parents: 67
diff changeset
1337 /* The last element is loop post-header. */
kono
parents: 67
diff changeset
1338 gcc_assert (exit_bb);
kono
parents: 67
diff changeset
1339 region.safe_push (exit_bb);
kono
parents: 67
diff changeset
1340 return region;
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
1341 }
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
1342
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
1343 /* Return true when LOOP is if-convertible. This is a helper function
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
1344 for if_convertible_loop_p. REFS and DDRS are initialized and freed
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
1345 in if_convertible_loop_p. */
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
1346
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
1347 static bool
111
kono
parents: 67
diff changeset
1348 if_convertible_loop_p_1 (struct loop *loop, vec<data_reference_p> *refs)
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
1349 {
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
1350 unsigned int i;
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
1351 basic_block exit_bb = NULL;
111
kono
parents: 67
diff changeset
1352 vec<basic_block> region;
kono
parents: 67
diff changeset
1353
kono
parents: 67
diff changeset
1354 if (find_data_references_in_loop (loop, refs) == chrec_dont_know)
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
1355 return false;
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
1356
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
1357 calculate_dominance_info (CDI_DOMINATORS);
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
1358
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
1359 /* Allow statements that can be handled during if-conversion. */
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
1360 ifc_bbs = get_loop_body_in_if_conv_order (loop);
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
1361 if (!ifc_bbs)
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
1362 {
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
1363 if (dump_file && (dump_flags & TDF_DETAILS))
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
1364 fprintf (dump_file, "Irreducible loop\n");
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
1365 return false;
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
1366 }
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
1367
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
1368 for (i = 0; i < loop->num_nodes; i++)
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
1369 {
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
1370 basic_block bb = ifc_bbs[i];
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
1371
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
1372 if (!if_convertible_bb_p (loop, bb, exit_bb))
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
1373 return false;
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
1374
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
1375 if (bb_with_exit_edge_p (loop, bb))
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
1376 exit_bb = bb;
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
1377 }
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
1378
111
kono
parents: 67
diff changeset
1379 for (i = 0; i < loop->num_nodes; i++)
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
1380 {
111
kono
parents: 67
diff changeset
1381 basic_block bb = ifc_bbs[i];
kono
parents: 67
diff changeset
1382 gimple_stmt_iterator gsi;
kono
parents: 67
diff changeset
1383
kono
parents: 67
diff changeset
1384 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
kono
parents: 67
diff changeset
1385 switch (gimple_code (gsi_stmt (gsi)))
kono
parents: 67
diff changeset
1386 {
kono
parents: 67
diff changeset
1387 case GIMPLE_LABEL:
kono
parents: 67
diff changeset
1388 case GIMPLE_ASSIGN:
kono
parents: 67
diff changeset
1389 case GIMPLE_CALL:
kono
parents: 67
diff changeset
1390 case GIMPLE_DEBUG:
kono
parents: 67
diff changeset
1391 case GIMPLE_COND:
kono
parents: 67
diff changeset
1392 gimple_set_uid (gsi_stmt (gsi), 0);
kono
parents: 67
diff changeset
1393 break;
kono
parents: 67
diff changeset
1394 default:
kono
parents: 67
diff changeset
1395 return false;
kono
parents: 67
diff changeset
1396 }
kono
parents: 67
diff changeset
1397 }
kono
parents: 67
diff changeset
1398
kono
parents: 67
diff changeset
1399 data_reference_p dr;
kono
parents: 67
diff changeset
1400
kono
parents: 67
diff changeset
1401 innermost_DR_map
kono
parents: 67
diff changeset
1402 = new hash_map<innermost_loop_behavior_hash, data_reference_p>;
kono
parents: 67
diff changeset
1403 baseref_DR_map = new hash_map<tree_operand_hash, data_reference_p>;
kono
parents: 67
diff changeset
1404
kono
parents: 67
diff changeset
1405 /* Compute post-dominator tree locally. */
kono
parents: 67
diff changeset
1406 region = build_region (loop);
kono
parents: 67
diff changeset
1407 calculate_dominance_info_for_region (CDI_POST_DOMINATORS, region);
kono
parents: 67
diff changeset
1408
kono
parents: 67
diff changeset
1409 predicate_bbs (loop);
kono
parents: 67
diff changeset
1410
kono
parents: 67
diff changeset
1411 /* Free post-dominator tree since it is not used after predication. */
kono
parents: 67
diff changeset
1412 free_dominance_info_for_region (cfun, CDI_POST_DOMINATORS, region);
kono
parents: 67
diff changeset
1413 region.release ();
kono
parents: 67
diff changeset
1414
kono
parents: 67
diff changeset
1415 for (i = 0; refs->iterate (i, &dr); i++)
kono
parents: 67
diff changeset
1416 {
kono
parents: 67
diff changeset
1417 tree ref = DR_REF (dr);
kono
parents: 67
diff changeset
1418
kono
parents: 67
diff changeset
1419 dr->aux = XNEW (struct ifc_dr);
kono
parents: 67
diff changeset
1420 DR_BASE_W_UNCONDITIONALLY (dr) = false;
kono
parents: 67
diff changeset
1421 DR_RW_UNCONDITIONALLY (dr) = false;
kono
parents: 67
diff changeset
1422 DR_W_UNCONDITIONALLY (dr) = false;
kono
parents: 67
diff changeset
1423 IFC_DR (dr)->rw_predicate = boolean_false_node;
kono
parents: 67
diff changeset
1424 IFC_DR (dr)->w_predicate = boolean_false_node;
kono
parents: 67
diff changeset
1425 IFC_DR (dr)->base_w_predicate = boolean_false_node;
kono
parents: 67
diff changeset
1426 if (gimple_uid (DR_STMT (dr)) == 0)
kono
parents: 67
diff changeset
1427 gimple_set_uid (DR_STMT (dr), i + 1);
kono
parents: 67
diff changeset
1428
kono
parents: 67
diff changeset
1429 /* If DR doesn't have innermost loop behavior or it's a compound
kono
parents: 67
diff changeset
1430 memory reference, we synthesize its innermost loop behavior
kono
parents: 67
diff changeset
1431 for hashing. */
kono
parents: 67
diff changeset
1432 if (TREE_CODE (ref) == COMPONENT_REF
kono
parents: 67
diff changeset
1433 || TREE_CODE (ref) == IMAGPART_EXPR
kono
parents: 67
diff changeset
1434 || TREE_CODE (ref) == REALPART_EXPR
kono
parents: 67
diff changeset
1435 || !(DR_BASE_ADDRESS (dr) || DR_OFFSET (dr)
kono
parents: 67
diff changeset
1436 || DR_INIT (dr) || DR_STEP (dr)))
kono
parents: 67
diff changeset
1437 {
kono
parents: 67
diff changeset
1438 while (TREE_CODE (ref) == COMPONENT_REF
kono
parents: 67
diff changeset
1439 || TREE_CODE (ref) == IMAGPART_EXPR
kono
parents: 67
diff changeset
1440 || TREE_CODE (ref) == REALPART_EXPR)
kono
parents: 67
diff changeset
1441 ref = TREE_OPERAND (ref, 0);
kono
parents: 67
diff changeset
1442
kono
parents: 67
diff changeset
1443 memset (&DR_INNERMOST (dr), 0, sizeof (DR_INNERMOST (dr)));
kono
parents: 67
diff changeset
1444 DR_BASE_ADDRESS (dr) = ref;
kono
parents: 67
diff changeset
1445 }
kono
parents: 67
diff changeset
1446 hash_memrefs_baserefs_and_store_DRs_read_written_info (dr);
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
1447 }
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
1448
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
1449 for (i = 0; i < loop->num_nodes; i++)
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
1450 {
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
1451 basic_block bb = ifc_bbs[i];
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
1452 gimple_stmt_iterator itr;
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
1453
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
1454 /* Check the if-convertibility of statements in predicated BBs. */
111
kono
parents: 67
diff changeset
1455 if (!dominated_by_p (CDI_DOMINATORS, loop->latch, bb))
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
1456 for (itr = gsi_start_bb (bb); !gsi_end_p (itr); gsi_next (&itr))
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
1457 if (!if_convertible_stmt_p (gsi_stmt (itr), *refs))
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
1458 return false;
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
1459 }
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
1460
111
kono
parents: 67
diff changeset
1461 /* Checking PHIs needs to be done after stmts, as the fact whether there
kono
parents: 67
diff changeset
1462 are any masked loads or stores affects the tests. */
kono
parents: 67
diff changeset
1463 for (i = 0; i < loop->num_nodes; i++)
kono
parents: 67
diff changeset
1464 {
kono
parents: 67
diff changeset
1465 basic_block bb = ifc_bbs[i];
kono
parents: 67
diff changeset
1466 gphi_iterator itr;
kono
parents: 67
diff changeset
1467
kono
parents: 67
diff changeset
1468 for (itr = gsi_start_phis (bb); !gsi_end_p (itr); gsi_next (&itr))
kono
parents: 67
diff changeset
1469 if (!if_convertible_phi_p (loop, bb, itr.phi ()))
kono
parents: 67
diff changeset
1470 return false;
kono
parents: 67
diff changeset
1471 }
kono
parents: 67
diff changeset
1472
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
1473 if (dump_file)
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
1474 fprintf (dump_file, "Applying if-conversion\n");
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
1475
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
1476 return true;
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
1477 }
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
1478
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1479 /* Return true when LOOP is if-convertible.
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1480 LOOP is if-convertible if:
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1481 - it is innermost,
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1482 - it has two or more basic blocks,
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1483 - it has only one exit,
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1484 - loop header is not the exit edge,
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1485 - if its basic blocks and phi nodes are if convertible. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1486
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1487 static bool
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1488 if_convertible_loop_p (struct loop *loop)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1489 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1490 edge e;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1491 edge_iterator ei;
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
1492 bool res = false;
111
kono
parents: 67
diff changeset
1493 vec<data_reference_p> refs;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1494
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
1495 /* Handle only innermost loop. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1496 if (!loop || loop->inner)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1497 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1498 if (dump_file && (dump_flags & TDF_DETAILS))
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
1499 fprintf (dump_file, "not innermost loop\n");
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1500 return false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1501 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1502
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1503 /* If only one block, no need for if-conversion. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1504 if (loop->num_nodes <= 2)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1505 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1506 if (dump_file && (dump_flags & TDF_DETAILS))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1507 fprintf (dump_file, "less than 2 basic blocks\n");
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1508 return false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1509 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1510
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1511 /* More than one loop exit is too much to handle. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1512 if (!single_exit (loop))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1513 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1514 if (dump_file && (dump_flags & TDF_DETAILS))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1515 fprintf (dump_file, "multiple exits\n");
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1516 return false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1517 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1518
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
1519 /* If one of the loop header's edge is an exit edge then do not
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
1520 apply if-conversion. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1521 FOR_EACH_EDGE (e, ei, loop->header->succs)
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
1522 if (loop_exit_edge_p (loop, e))
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
1523 return false;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1524
111
kono
parents: 67
diff changeset
1525 refs.create (5);
kono
parents: 67
diff changeset
1526 res = if_convertible_loop_p_1 (loop, &refs);
kono
parents: 67
diff changeset
1527
kono
parents: 67
diff changeset
1528 data_reference_p dr;
kono
parents: 67
diff changeset
1529 unsigned int i;
kono
parents: 67
diff changeset
1530 for (i = 0; refs.iterate (i, &dr); i++)
kono
parents: 67
diff changeset
1531 free (dr->aux);
kono
parents: 67
diff changeset
1532
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
1533 free_data_refs (refs);
111
kono
parents: 67
diff changeset
1534
kono
parents: 67
diff changeset
1535 delete innermost_DR_map;
kono
parents: 67
diff changeset
1536 innermost_DR_map = NULL;
kono
parents: 67
diff changeset
1537
kono
parents: 67
diff changeset
1538 delete baseref_DR_map;
kono
parents: 67
diff changeset
1539 baseref_DR_map = NULL;
kono
parents: 67
diff changeset
1540
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
1541 return res;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1542 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1543
111
kono
parents: 67
diff changeset
1544 /* Returns true if def-stmt for phi argument ARG is simple increment/decrement
kono
parents: 67
diff changeset
1545 which is in predicated basic block.
kono
parents: 67
diff changeset
1546 In fact, the following PHI pattern is searching:
kono
parents: 67
diff changeset
1547 loop-header:
kono
parents: 67
diff changeset
1548 reduc_1 = PHI <..., reduc_2>
kono
parents: 67
diff changeset
1549 ...
kono
parents: 67
diff changeset
1550 if (...)
kono
parents: 67
diff changeset
1551 reduc_3 = ...
kono
parents: 67
diff changeset
1552 reduc_2 = PHI <reduc_1, reduc_3>
kono
parents: 67
diff changeset
1553
kono
parents: 67
diff changeset
1554 ARG_0 and ARG_1 are correspondent PHI arguments.
kono
parents: 67
diff changeset
1555 REDUC, OP0 and OP1 contain reduction stmt and its operands.
kono
parents: 67
diff changeset
1556 EXTENDED is true if PHI has > 2 arguments. */
kono
parents: 67
diff changeset
1557
kono
parents: 67
diff changeset
1558 static bool
kono
parents: 67
diff changeset
1559 is_cond_scalar_reduction (gimple *phi, gimple **reduc, tree arg_0, tree arg_1,
kono
parents: 67
diff changeset
1560 tree *op0, tree *op1, bool extended)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1561 {
111
kono
parents: 67
diff changeset
1562 tree lhs, r_op1, r_op2;
kono
parents: 67
diff changeset
1563 gimple *stmt;
kono
parents: 67
diff changeset
1564 gimple *header_phi = NULL;
kono
parents: 67
diff changeset
1565 enum tree_code reduction_op;
kono
parents: 67
diff changeset
1566 basic_block bb = gimple_bb (phi);
kono
parents: 67
diff changeset
1567 struct loop *loop = bb->loop_father;
kono
parents: 67
diff changeset
1568 edge latch_e = loop_latch_edge (loop);
kono
parents: 67
diff changeset
1569 imm_use_iterator imm_iter;
kono
parents: 67
diff changeset
1570 use_operand_p use_p;
kono
parents: 67
diff changeset
1571 edge e;
kono
parents: 67
diff changeset
1572 edge_iterator ei;
kono
parents: 67
diff changeset
1573 bool result = false;
kono
parents: 67
diff changeset
1574 if (TREE_CODE (arg_0) != SSA_NAME || TREE_CODE (arg_1) != SSA_NAME)
kono
parents: 67
diff changeset
1575 return false;
kono
parents: 67
diff changeset
1576
kono
parents: 67
diff changeset
1577 if (!extended && gimple_code (SSA_NAME_DEF_STMT (arg_0)) == GIMPLE_PHI)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1578 {
111
kono
parents: 67
diff changeset
1579 lhs = arg_1;
kono
parents: 67
diff changeset
1580 header_phi = SSA_NAME_DEF_STMT (arg_0);
kono
parents: 67
diff changeset
1581 stmt = SSA_NAME_DEF_STMT (arg_1);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1582 }
111
kono
parents: 67
diff changeset
1583 else if (gimple_code (SSA_NAME_DEF_STMT (arg_1)) == GIMPLE_PHI)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1584 {
111
kono
parents: 67
diff changeset
1585 lhs = arg_0;
kono
parents: 67
diff changeset
1586 header_phi = SSA_NAME_DEF_STMT (arg_1);
kono
parents: 67
diff changeset
1587 stmt = SSA_NAME_DEF_STMT (arg_0);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1588 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1589 else
111
kono
parents: 67
diff changeset
1590 return false;
kono
parents: 67
diff changeset
1591 if (gimple_bb (header_phi) != loop->header)
kono
parents: 67
diff changeset
1592 return false;
kono
parents: 67
diff changeset
1593
kono
parents: 67
diff changeset
1594 if (PHI_ARG_DEF_FROM_EDGE (header_phi, latch_e) != PHI_RESULT (phi))
kono
parents: 67
diff changeset
1595 return false;
kono
parents: 67
diff changeset
1596
kono
parents: 67
diff changeset
1597 if (gimple_code (stmt) != GIMPLE_ASSIGN
kono
parents: 67
diff changeset
1598 || gimple_has_volatile_ops (stmt))
kono
parents: 67
diff changeset
1599 return false;
kono
parents: 67
diff changeset
1600
kono
parents: 67
diff changeset
1601 if (!flow_bb_inside_loop_p (loop, gimple_bb (stmt)))
kono
parents: 67
diff changeset
1602 return false;
kono
parents: 67
diff changeset
1603
kono
parents: 67
diff changeset
1604 if (!is_predicated (gimple_bb (stmt)))
kono
parents: 67
diff changeset
1605 return false;
kono
parents: 67
diff changeset
1606
kono
parents: 67
diff changeset
1607 /* Check that stmt-block is predecessor of phi-block. */
kono
parents: 67
diff changeset
1608 FOR_EACH_EDGE (e, ei, gimple_bb (stmt)->succs)
kono
parents: 67
diff changeset
1609 if (e->dest == bb)
kono
parents: 67
diff changeset
1610 {
kono
parents: 67
diff changeset
1611 result = true;
kono
parents: 67
diff changeset
1612 break;
kono
parents: 67
diff changeset
1613 }
kono
parents: 67
diff changeset
1614 if (!result)
kono
parents: 67
diff changeset
1615 return false;
kono
parents: 67
diff changeset
1616
kono
parents: 67
diff changeset
1617 if (!has_single_use (lhs))
kono
parents: 67
diff changeset
1618 return false;
kono
parents: 67
diff changeset
1619
kono
parents: 67
diff changeset
1620 reduction_op = gimple_assign_rhs_code (stmt);
kono
parents: 67
diff changeset
1621 if (reduction_op != PLUS_EXPR && reduction_op != MINUS_EXPR)
kono
parents: 67
diff changeset
1622 return false;
kono
parents: 67
diff changeset
1623 r_op1 = gimple_assign_rhs1 (stmt);
kono
parents: 67
diff changeset
1624 r_op2 = gimple_assign_rhs2 (stmt);
kono
parents: 67
diff changeset
1625
kono
parents: 67
diff changeset
1626 /* Make R_OP1 to hold reduction variable. */
kono
parents: 67
diff changeset
1627 if (r_op2 == PHI_RESULT (header_phi)
kono
parents: 67
diff changeset
1628 && reduction_op == PLUS_EXPR)
kono
parents: 67
diff changeset
1629 std::swap (r_op1, r_op2);
kono
parents: 67
diff changeset
1630 else if (r_op1 != PHI_RESULT (header_phi))
kono
parents: 67
diff changeset
1631 return false;
kono
parents: 67
diff changeset
1632
kono
parents: 67
diff changeset
1633 /* Check that R_OP1 is used in reduction stmt or in PHI only. */
kono
parents: 67
diff changeset
1634 FOR_EACH_IMM_USE_FAST (use_p, imm_iter, r_op1)
kono
parents: 67
diff changeset
1635 {
kono
parents: 67
diff changeset
1636 gimple *use_stmt = USE_STMT (use_p);
kono
parents: 67
diff changeset
1637 if (is_gimple_debug (use_stmt))
kono
parents: 67
diff changeset
1638 continue;
kono
parents: 67
diff changeset
1639 if (use_stmt == stmt)
kono
parents: 67
diff changeset
1640 continue;
kono
parents: 67
diff changeset
1641 if (gimple_code (use_stmt) != GIMPLE_PHI)
kono
parents: 67
diff changeset
1642 return false;
kono
parents: 67
diff changeset
1643 }
kono
parents: 67
diff changeset
1644
kono
parents: 67
diff changeset
1645 *op0 = r_op1; *op1 = r_op2;
kono
parents: 67
diff changeset
1646 *reduc = stmt;
kono
parents: 67
diff changeset
1647 return true;
kono
parents: 67
diff changeset
1648 }
kono
parents: 67
diff changeset
1649
kono
parents: 67
diff changeset
1650 /* Converts conditional scalar reduction into unconditional form, e.g.
kono
parents: 67
diff changeset
1651 bb_4
kono
parents: 67
diff changeset
1652 if (_5 != 0) goto bb_5 else goto bb_6
kono
parents: 67
diff changeset
1653 end_bb_4
kono
parents: 67
diff changeset
1654 bb_5
kono
parents: 67
diff changeset
1655 res_6 = res_13 + 1;
kono
parents: 67
diff changeset
1656 end_bb_5
kono
parents: 67
diff changeset
1657 bb_6
kono
parents: 67
diff changeset
1658 # res_2 = PHI <res_13(4), res_6(5)>
kono
parents: 67
diff changeset
1659 end_bb_6
kono
parents: 67
diff changeset
1660
kono
parents: 67
diff changeset
1661 will be converted into sequence
kono
parents: 67
diff changeset
1662 _ifc__1 = _5 != 0 ? 1 : 0;
kono
parents: 67
diff changeset
1663 res_2 = res_13 + _ifc__1;
kono
parents: 67
diff changeset
1664 Argument SWAP tells that arguments of conditional expression should be
kono
parents: 67
diff changeset
1665 swapped.
kono
parents: 67
diff changeset
1666 Returns rhs of resulting PHI assignment. */
kono
parents: 67
diff changeset
1667
kono
parents: 67
diff changeset
1668 static tree
kono
parents: 67
diff changeset
1669 convert_scalar_cond_reduction (gimple *reduc, gimple_stmt_iterator *gsi,
kono
parents: 67
diff changeset
1670 tree cond, tree op0, tree op1, bool swap)
kono
parents: 67
diff changeset
1671 {
kono
parents: 67
diff changeset
1672 gimple_stmt_iterator stmt_it;
kono
parents: 67
diff changeset
1673 gimple *new_assign;
kono
parents: 67
diff changeset
1674 tree rhs;
kono
parents: 67
diff changeset
1675 tree rhs1 = gimple_assign_rhs1 (reduc);
kono
parents: 67
diff changeset
1676 tree tmp = make_temp_ssa_name (TREE_TYPE (rhs1), NULL, "_ifc_");
kono
parents: 67
diff changeset
1677 tree c;
kono
parents: 67
diff changeset
1678 tree zero = build_zero_cst (TREE_TYPE (rhs1));
kono
parents: 67
diff changeset
1679
kono
parents: 67
diff changeset
1680 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents: 67
diff changeset
1681 {
kono
parents: 67
diff changeset
1682 fprintf (dump_file, "Found cond scalar reduction.\n");
kono
parents: 67
diff changeset
1683 print_gimple_stmt (dump_file, reduc, 0, TDF_SLIM);
kono
parents: 67
diff changeset
1684 }
kono
parents: 67
diff changeset
1685
kono
parents: 67
diff changeset
1686 /* Build cond expression using COND and constant operand
kono
parents: 67
diff changeset
1687 of reduction rhs. */
kono
parents: 67
diff changeset
1688 c = fold_build_cond_expr (TREE_TYPE (rhs1),
kono
parents: 67
diff changeset
1689 unshare_expr (cond),
kono
parents: 67
diff changeset
1690 swap ? zero : op1,
kono
parents: 67
diff changeset
1691 swap ? op1 : zero);
kono
parents: 67
diff changeset
1692
kono
parents: 67
diff changeset
1693 /* Create assignment stmt and insert it at GSI. */
kono
parents: 67
diff changeset
1694 new_assign = gimple_build_assign (tmp, c);
kono
parents: 67
diff changeset
1695 gsi_insert_before (gsi, new_assign, GSI_SAME_STMT);
kono
parents: 67
diff changeset
1696 /* Build rhs for unconditional increment/decrement. */
kono
parents: 67
diff changeset
1697 rhs = fold_build2 (gimple_assign_rhs_code (reduc),
kono
parents: 67
diff changeset
1698 TREE_TYPE (rhs1), op0, tmp);
kono
parents: 67
diff changeset
1699
kono
parents: 67
diff changeset
1700 /* Delete original reduction stmt. */
kono
parents: 67
diff changeset
1701 stmt_it = gsi_for_stmt (reduc);
kono
parents: 67
diff changeset
1702 gsi_remove (&stmt_it, true);
kono
parents: 67
diff changeset
1703 release_defs (reduc);
kono
parents: 67
diff changeset
1704 return rhs;
kono
parents: 67
diff changeset
1705 }
kono
parents: 67
diff changeset
1706
kono
parents: 67
diff changeset
1707 /* Produce condition for all occurrences of ARG in PHI node. */
kono
parents: 67
diff changeset
1708
kono
parents: 67
diff changeset
1709 static tree
kono
parents: 67
diff changeset
1710 gen_phi_arg_condition (gphi *phi, vec<int> *occur,
kono
parents: 67
diff changeset
1711 gimple_stmt_iterator *gsi)
kono
parents: 67
diff changeset
1712 {
kono
parents: 67
diff changeset
1713 int len;
kono
parents: 67
diff changeset
1714 int i;
kono
parents: 67
diff changeset
1715 tree cond = NULL_TREE;
kono
parents: 67
diff changeset
1716 tree c;
kono
parents: 67
diff changeset
1717 edge e;
kono
parents: 67
diff changeset
1718
kono
parents: 67
diff changeset
1719 len = occur->length ();
kono
parents: 67
diff changeset
1720 gcc_assert (len > 0);
kono
parents: 67
diff changeset
1721 for (i = 0; i < len; i++)
kono
parents: 67
diff changeset
1722 {
kono
parents: 67
diff changeset
1723 e = gimple_phi_arg_edge (phi, (*occur)[i]);
kono
parents: 67
diff changeset
1724 c = bb_predicate (e->src);
kono
parents: 67
diff changeset
1725 if (is_true_predicate (c))
kono
parents: 67
diff changeset
1726 {
kono
parents: 67
diff changeset
1727 cond = c;
kono
parents: 67
diff changeset
1728 break;
kono
parents: 67
diff changeset
1729 }
kono
parents: 67
diff changeset
1730 c = force_gimple_operand_gsi_1 (gsi, unshare_expr (c),
kono
parents: 67
diff changeset
1731 is_gimple_condexpr, NULL_TREE,
kono
parents: 67
diff changeset
1732 true, GSI_SAME_STMT);
kono
parents: 67
diff changeset
1733 if (cond != NULL_TREE)
kono
parents: 67
diff changeset
1734 {
kono
parents: 67
diff changeset
1735 /* Must build OR expression. */
kono
parents: 67
diff changeset
1736 cond = fold_or_predicates (EXPR_LOCATION (c), c, cond);
kono
parents: 67
diff changeset
1737 cond = force_gimple_operand_gsi_1 (gsi, unshare_expr (cond),
kono
parents: 67
diff changeset
1738 is_gimple_condexpr, NULL_TREE,
kono
parents: 67
diff changeset
1739 true, GSI_SAME_STMT);
kono
parents: 67
diff changeset
1740 }
kono
parents: 67
diff changeset
1741 else
kono
parents: 67
diff changeset
1742 cond = c;
kono
parents: 67
diff changeset
1743 }
kono
parents: 67
diff changeset
1744 gcc_assert (cond != NULL_TREE);
kono
parents: 67
diff changeset
1745 return cond;
kono
parents: 67
diff changeset
1746 }
kono
parents: 67
diff changeset
1747
kono
parents: 67
diff changeset
1748 /* Local valueization callback that follows all-use SSA edges. */
kono
parents: 67
diff changeset
1749
kono
parents: 67
diff changeset
1750 static tree
kono
parents: 67
diff changeset
1751 ifcvt_follow_ssa_use_edges (tree val)
kono
parents: 67
diff changeset
1752 {
kono
parents: 67
diff changeset
1753 return val;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1754 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1755
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
1756 /* Replace a scalar PHI node with a COND_EXPR using COND as condition.
111
kono
parents: 67
diff changeset
1757 This routine can handle PHI nodes with more than two arguments.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1758
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1759 For example,
111
kono
parents: 67
diff changeset
1760 S1: A = PHI <x1(1), x2(5)>
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1761 is converted into,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1762 S2: A = cond ? x1 : x2;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1763
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1764 The generated code is inserted at GSI that points to the top of
111
kono
parents: 67
diff changeset
1765 basic block's statement list.
kono
parents: 67
diff changeset
1766 If PHI node has more than two arguments a chain of conditional
kono
parents: 67
diff changeset
1767 expression is produced. */
kono
parents: 67
diff changeset
1768
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1769
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1770 static void
111
kono
parents: 67
diff changeset
1771 predicate_scalar_phi (gphi *phi, gimple_stmt_iterator *gsi)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1772 {
111
kono
parents: 67
diff changeset
1773 gimple *new_stmt = NULL, *reduc;
kono
parents: 67
diff changeset
1774 tree rhs, res, arg0, arg1, op0, op1, scev;
kono
parents: 67
diff changeset
1775 tree cond;
kono
parents: 67
diff changeset
1776 unsigned int index0;
kono
parents: 67
diff changeset
1777 unsigned int max, args_len;
kono
parents: 67
diff changeset
1778 edge e;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1779 basic_block bb;
111
kono
parents: 67
diff changeset
1780 unsigned int i;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1781
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
1782 res = gimple_phi_result (phi);
111
kono
parents: 67
diff changeset
1783 if (virtual_operand_p (res))
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
1784 return;
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
1785
111
kono
parents: 67
diff changeset
1786 if ((rhs = degenerate_phi_result (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
1787 || ((scev = analyze_scalar_evolution (gimple_bb (phi)->loop_father,
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
1788 res))
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
1789 && !chrec_contains_undetermined (scev)
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
1790 && scev != res
111
kono
parents: 67
diff changeset
1791 && (rhs = gimple_phi_arg_def (phi, 0))))
kono
parents: 67
diff changeset
1792 {
kono
parents: 67
diff changeset
1793 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents: 67
diff changeset
1794 {
kono
parents: 67
diff changeset
1795 fprintf (dump_file, "Degenerate phi!\n");
kono
parents: 67
diff changeset
1796 print_gimple_stmt (dump_file, phi, 0, TDF_SLIM);
kono
parents: 67
diff changeset
1797 }
kono
parents: 67
diff changeset
1798 new_stmt = gimple_build_assign (res, rhs);
kono
parents: 67
diff changeset
1799 gsi_insert_before (gsi, new_stmt, GSI_SAME_STMT);
kono
parents: 67
diff changeset
1800 update_stmt (new_stmt);
kono
parents: 67
diff changeset
1801 return;
kono
parents: 67
diff changeset
1802 }
kono
parents: 67
diff changeset
1803
kono
parents: 67
diff changeset
1804 bb = gimple_bb (phi);
kono
parents: 67
diff changeset
1805 if (EDGE_COUNT (bb->preds) == 2)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1806 {
111
kono
parents: 67
diff changeset
1807 /* Predicate ordinary PHI node with 2 arguments. */
kono
parents: 67
diff changeset
1808 edge first_edge, second_edge;
kono
parents: 67
diff changeset
1809 basic_block true_bb;
kono
parents: 67
diff changeset
1810 first_edge = EDGE_PRED (bb, 0);
kono
parents: 67
diff changeset
1811 second_edge = EDGE_PRED (bb, 1);
kono
parents: 67
diff changeset
1812 cond = bb_predicate (first_edge->src);
kono
parents: 67
diff changeset
1813 if (TREE_CODE (cond) == TRUTH_NOT_EXPR)
kono
parents: 67
diff changeset
1814 std::swap (first_edge, second_edge);
kono
parents: 67
diff changeset
1815 if (EDGE_COUNT (first_edge->src->succs) > 1)
kono
parents: 67
diff changeset
1816 {
kono
parents: 67
diff changeset
1817 cond = bb_predicate (second_edge->src);
kono
parents: 67
diff changeset
1818 if (TREE_CODE (cond) == TRUTH_NOT_EXPR)
kono
parents: 67
diff changeset
1819 cond = TREE_OPERAND (cond, 0);
kono
parents: 67
diff changeset
1820 else
kono
parents: 67
diff changeset
1821 first_edge = second_edge;
kono
parents: 67
diff changeset
1822 }
kono
parents: 67
diff changeset
1823 else
kono
parents: 67
diff changeset
1824 cond = bb_predicate (first_edge->src);
kono
parents: 67
diff changeset
1825 /* Gimplify the condition to a valid cond-expr conditonal operand. */
kono
parents: 67
diff changeset
1826 cond = force_gimple_operand_gsi_1 (gsi, unshare_expr (cond),
kono
parents: 67
diff changeset
1827 is_gimple_condexpr, NULL_TREE,
kono
parents: 67
diff changeset
1828 true, GSI_SAME_STMT);
kono
parents: 67
diff changeset
1829 true_bb = first_edge->src;
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
1830 if (EDGE_PRED (bb, 1)->src == true_bb)
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
1831 {
111
kono
parents: 67
diff changeset
1832 arg0 = gimple_phi_arg_def (phi, 1);
kono
parents: 67
diff changeset
1833 arg1 = gimple_phi_arg_def (phi, 0);
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
1834 }
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
1835 else
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
1836 {
111
kono
parents: 67
diff changeset
1837 arg0 = gimple_phi_arg_def (phi, 0);
kono
parents: 67
diff changeset
1838 arg1 = gimple_phi_arg_def (phi, 1);
kono
parents: 67
diff changeset
1839 }
kono
parents: 67
diff changeset
1840 if (is_cond_scalar_reduction (phi, &reduc, arg0, arg1,
kono
parents: 67
diff changeset
1841 &op0, &op1, false))
kono
parents: 67
diff changeset
1842 /* Convert reduction stmt into vectorizable form. */
kono
parents: 67
diff changeset
1843 rhs = convert_scalar_cond_reduction (reduc, gsi, cond, op0, op1,
kono
parents: 67
diff changeset
1844 true_bb != gimple_bb (reduc));
kono
parents: 67
diff changeset
1845 else
kono
parents: 67
diff changeset
1846 /* Build new RHS using selected condition and arguments. */
kono
parents: 67
diff changeset
1847 rhs = fold_build_cond_expr (TREE_TYPE (res), unshare_expr (cond),
kono
parents: 67
diff changeset
1848 arg0, arg1);
kono
parents: 67
diff changeset
1849 new_stmt = gimple_build_assign (res, rhs);
kono
parents: 67
diff changeset
1850 gsi_insert_before (gsi, new_stmt, GSI_SAME_STMT);
kono
parents: 67
diff changeset
1851 gimple_stmt_iterator new_gsi = gsi_for_stmt (new_stmt);
kono
parents: 67
diff changeset
1852 if (fold_stmt (&new_gsi, ifcvt_follow_ssa_use_edges))
kono
parents: 67
diff changeset
1853 {
kono
parents: 67
diff changeset
1854 new_stmt = gsi_stmt (new_gsi);
kono
parents: 67
diff changeset
1855 update_stmt (new_stmt);
kono
parents: 67
diff changeset
1856 }
kono
parents: 67
diff changeset
1857
kono
parents: 67
diff changeset
1858 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents: 67
diff changeset
1859 {
kono
parents: 67
diff changeset
1860 fprintf (dump_file, "new phi replacement stmt\n");
kono
parents: 67
diff changeset
1861 print_gimple_stmt (dump_file, new_stmt, 0, TDF_SLIM);
kono
parents: 67
diff changeset
1862 }
kono
parents: 67
diff changeset
1863 return;
kono
parents: 67
diff changeset
1864 }
kono
parents: 67
diff changeset
1865
kono
parents: 67
diff changeset
1866 /* Create hashmap for PHI node which contain vector of argument indexes
kono
parents: 67
diff changeset
1867 having the same value. */
kono
parents: 67
diff changeset
1868 bool swap = false;
kono
parents: 67
diff changeset
1869 hash_map<tree_operand_hash, auto_vec<int> > phi_arg_map;
kono
parents: 67
diff changeset
1870 unsigned int num_args = gimple_phi_num_args (phi);
kono
parents: 67
diff changeset
1871 int max_ind = -1;
kono
parents: 67
diff changeset
1872 /* Vector of different PHI argument values. */
kono
parents: 67
diff changeset
1873 auto_vec<tree> args (num_args);
kono
parents: 67
diff changeset
1874
kono
parents: 67
diff changeset
1875 /* Compute phi_arg_map. */
kono
parents: 67
diff changeset
1876 for (i = 0; i < num_args; i++)
kono
parents: 67
diff changeset
1877 {
kono
parents: 67
diff changeset
1878 tree arg;
kono
parents: 67
diff changeset
1879
kono
parents: 67
diff changeset
1880 arg = gimple_phi_arg_def (phi, i);
kono
parents: 67
diff changeset
1881 if (!phi_arg_map.get (arg))
kono
parents: 67
diff changeset
1882 args.quick_push (arg);
kono
parents: 67
diff changeset
1883 phi_arg_map.get_or_insert (arg).safe_push (i);
kono
parents: 67
diff changeset
1884 }
kono
parents: 67
diff changeset
1885
kono
parents: 67
diff changeset
1886 /* Determine element with max number of occurrences. */
kono
parents: 67
diff changeset
1887 max_ind = -1;
kono
parents: 67
diff changeset
1888 max = 1;
kono
parents: 67
diff changeset
1889 args_len = args.length ();
kono
parents: 67
diff changeset
1890 for (i = 0; i < args_len; i++)
kono
parents: 67
diff changeset
1891 {
kono
parents: 67
diff changeset
1892 unsigned int len;
kono
parents: 67
diff changeset
1893 if ((len = phi_arg_map.get (args[i])->length ()) > max)
kono
parents: 67
diff changeset
1894 {
kono
parents: 67
diff changeset
1895 max_ind = (int) i;
kono
parents: 67
diff changeset
1896 max = len;
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
1897 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1898 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1899
111
kono
parents: 67
diff changeset
1900 /* Put element with max number of occurences to the end of ARGS. */
kono
parents: 67
diff changeset
1901 if (max_ind != -1 && max_ind +1 != (int) args_len)
kono
parents: 67
diff changeset
1902 std::swap (args[args_len - 1], args[max_ind]);
kono
parents: 67
diff changeset
1903
kono
parents: 67
diff changeset
1904 /* Handle one special case when number of arguments with different values
kono
parents: 67
diff changeset
1905 is equal 2 and one argument has the only occurrence. Such PHI can be
kono
parents: 67
diff changeset
1906 handled as if would have only 2 arguments. */
kono
parents: 67
diff changeset
1907 if (args_len == 2 && phi_arg_map.get (args[0])->length () == 1)
kono
parents: 67
diff changeset
1908 {
kono
parents: 67
diff changeset
1909 vec<int> *indexes;
kono
parents: 67
diff changeset
1910 indexes = phi_arg_map.get (args[0]);
kono
parents: 67
diff changeset
1911 index0 = (*indexes)[0];
kono
parents: 67
diff changeset
1912 arg0 = args[0];
kono
parents: 67
diff changeset
1913 arg1 = args[1];
kono
parents: 67
diff changeset
1914 e = gimple_phi_arg_edge (phi, index0);
kono
parents: 67
diff changeset
1915 cond = bb_predicate (e->src);
kono
parents: 67
diff changeset
1916 if (TREE_CODE (cond) == TRUTH_NOT_EXPR)
kono
parents: 67
diff changeset
1917 {
kono
parents: 67
diff changeset
1918 swap = true;
kono
parents: 67
diff changeset
1919 cond = TREE_OPERAND (cond, 0);
kono
parents: 67
diff changeset
1920 }
kono
parents: 67
diff changeset
1921 /* Gimplify the condition to a valid cond-expr conditonal operand. */
kono
parents: 67
diff changeset
1922 cond = force_gimple_operand_gsi_1 (gsi, unshare_expr (cond),
kono
parents: 67
diff changeset
1923 is_gimple_condexpr, NULL_TREE,
kono
parents: 67
diff changeset
1924 true, GSI_SAME_STMT);
kono
parents: 67
diff changeset
1925 if (!(is_cond_scalar_reduction (phi, &reduc, arg0 , arg1,
kono
parents: 67
diff changeset
1926 &op0, &op1, true)))
kono
parents: 67
diff changeset
1927 rhs = fold_build_cond_expr (TREE_TYPE (res), unshare_expr (cond),
kono
parents: 67
diff changeset
1928 swap? arg1 : arg0,
kono
parents: 67
diff changeset
1929 swap? arg0 : arg1);
kono
parents: 67
diff changeset
1930 else
kono
parents: 67
diff changeset
1931 /* Convert reduction stmt into vectorizable form. */
kono
parents: 67
diff changeset
1932 rhs = convert_scalar_cond_reduction (reduc, gsi, cond, op0, op1,
kono
parents: 67
diff changeset
1933 swap);
kono
parents: 67
diff changeset
1934 new_stmt = gimple_build_assign (res, rhs);
kono
parents: 67
diff changeset
1935 gsi_insert_before (gsi, new_stmt, GSI_SAME_STMT);
kono
parents: 67
diff changeset
1936 update_stmt (new_stmt);
kono
parents: 67
diff changeset
1937 }
kono
parents: 67
diff changeset
1938 else
kono
parents: 67
diff changeset
1939 {
kono
parents: 67
diff changeset
1940 /* Common case. */
kono
parents: 67
diff changeset
1941 vec<int> *indexes;
kono
parents: 67
diff changeset
1942 tree type = TREE_TYPE (gimple_phi_result (phi));
kono
parents: 67
diff changeset
1943 tree lhs;
kono
parents: 67
diff changeset
1944 arg1 = args[1];
kono
parents: 67
diff changeset
1945 for (i = 0; i < args_len; i++)
kono
parents: 67
diff changeset
1946 {
kono
parents: 67
diff changeset
1947 arg0 = args[i];
kono
parents: 67
diff changeset
1948 indexes = phi_arg_map.get (args[i]);
kono
parents: 67
diff changeset
1949 if (i != args_len - 1)
kono
parents: 67
diff changeset
1950 lhs = make_temp_ssa_name (type, NULL, "_ifc_");
kono
parents: 67
diff changeset
1951 else
kono
parents: 67
diff changeset
1952 lhs = res;
kono
parents: 67
diff changeset
1953 cond = gen_phi_arg_condition (phi, indexes, gsi);
kono
parents: 67
diff changeset
1954 rhs = fold_build_cond_expr (type, unshare_expr (cond),
kono
parents: 67
diff changeset
1955 arg0, arg1);
kono
parents: 67
diff changeset
1956 new_stmt = gimple_build_assign (lhs, rhs);
kono
parents: 67
diff changeset
1957 gsi_insert_before (gsi, new_stmt, GSI_SAME_STMT);
kono
parents: 67
diff changeset
1958 update_stmt (new_stmt);
kono
parents: 67
diff changeset
1959 arg1 = lhs;
kono
parents: 67
diff changeset
1960 }
kono
parents: 67
diff changeset
1961 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1962
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1963 if (dump_file && (dump_flags & TDF_DETAILS))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1964 {
111
kono
parents: 67
diff changeset
1965 fprintf (dump_file, "new extended phi replacement stmt\n");
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1966 print_gimple_stmt (dump_file, new_stmt, 0, TDF_SLIM);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1967 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1968 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1969
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
1970 /* Replaces in LOOP all the scalar phi nodes other than those in the
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
1971 LOOP->header block with conditional modify expressions. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1972
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1973 static void
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
1974 predicate_all_scalar_phis (struct loop *loop)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1975 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1976 basic_block bb;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1977 unsigned int orig_loop_num_nodes = loop->num_nodes;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1978 unsigned int i;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1979
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1980 for (i = 1; i < orig_loop_num_nodes; i++)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1981 {
111
kono
parents: 67
diff changeset
1982 gphi *phi;
kono
parents: 67
diff changeset
1983 gimple_stmt_iterator gsi;
kono
parents: 67
diff changeset
1984 gphi_iterator phi_gsi;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1985 bb = ifc_bbs[i];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1986
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1987 if (bb == loop->header)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1988 continue;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1989
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1990 phi_gsi = gsi_start_phis (bb);
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
1991 if (gsi_end_p (phi_gsi))
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
1992 continue;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1993
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
1994 gsi = gsi_after_labels (bb);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1995 while (!gsi_end_p (phi_gsi))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1996 {
111
kono
parents: 67
diff changeset
1997 phi = phi_gsi.phi ();
kono
parents: 67
diff changeset
1998 if (virtual_operand_p (gimple_phi_result (phi)))
kono
parents: 67
diff changeset
1999 gsi_next (&phi_gsi);
kono
parents: 67
diff changeset
2000 else
kono
parents: 67
diff changeset
2001 {
kono
parents: 67
diff changeset
2002 predicate_scalar_phi (phi, &gsi);
kono
parents: 67
diff changeset
2003 remove_phi_node (&phi_gsi, false);
kono
parents: 67
diff changeset
2004 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2005 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2006 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2007 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2008
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
2009 /* Insert in each basic block of LOOP the statements produced by the
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
2010 gimplification of the predicates. */
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
2011
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
2012 static void
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
2013 insert_gimplified_predicates (loop_p loop)
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
2014 {
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
2015 unsigned int i;
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
2016
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
2017 for (i = 0; i < loop->num_nodes; i++)
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
2018 {
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
2019 basic_block bb = ifc_bbs[i];
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
2020 gimple_seq stmts;
111
kono
parents: 67
diff changeset
2021 if (!is_predicated (bb))
kono
parents: 67
diff changeset
2022 gcc_assert (bb_predicate_gimplified_stmts (bb) == NULL);
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
2023 if (!is_predicated (bb))
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
2024 {
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
2025 /* Do not insert statements for a basic block that is not
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
2026 predicated. Also make sure that the predicate of the
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
2027 basic block is set to true. */
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
2028 reset_bb_predicate (bb);
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
2029 continue;
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
2030 }
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
2031
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
2032 stmts = bb_predicate_gimplified_stmts (bb);
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
2033 if (stmts)
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
2034 {
111
kono
parents: 67
diff changeset
2035 if (any_pred_load_store)
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
2036 {
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
2037 /* Insert the predicate of the BB just after the label,
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
2038 as the if-conversion of memory writes will use this
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
2039 predicate. */
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
2040 gimple_stmt_iterator gsi = gsi_after_labels (bb);
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
2041 gsi_insert_seq_before (&gsi, stmts, GSI_SAME_STMT);
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
2042 }
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
2043 else
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
2044 {
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
2045 /* Insert the predicate of the BB at the end of the BB
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
2046 as this would reduce the register pressure: the only
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
2047 use of this predicate will be in successor BBs. */
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
2048 gimple_stmt_iterator gsi = gsi_last_bb (bb);
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
2049
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
2050 if (gsi_end_p (gsi)
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
2051 || stmt_ends_bb_p (gsi_stmt (gsi)))
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
2052 gsi_insert_seq_before (&gsi, stmts, GSI_SAME_STMT);
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
2053 else
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
2054 gsi_insert_seq_after (&gsi, stmts, GSI_SAME_STMT);
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
2055 }
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
2056
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
2057 /* Once the sequence is code generated, set it to NULL. */
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
2058 set_bb_predicate_gimplified_stmts (bb, NULL);
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
2059 }
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
2060 }
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
2061 }
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
2062
111
kono
parents: 67
diff changeset
2063 /* Helper function for predicate_mem_writes. Returns index of existent
kono
parents: 67
diff changeset
2064 mask if it was created for given SIZE and -1 otherwise. */
kono
parents: 67
diff changeset
2065
kono
parents: 67
diff changeset
2066 static int
kono
parents: 67
diff changeset
2067 mask_exists (int size, vec<int> vec)
kono
parents: 67
diff changeset
2068 {
kono
parents: 67
diff changeset
2069 unsigned int ix;
kono
parents: 67
diff changeset
2070 int v;
kono
parents: 67
diff changeset
2071 FOR_EACH_VEC_ELT (vec, ix, v)
kono
parents: 67
diff changeset
2072 if (v == size)
kono
parents: 67
diff changeset
2073 return (int) ix;
kono
parents: 67
diff changeset
2074 return -1;
kono
parents: 67
diff changeset
2075 }
kono
parents: 67
diff changeset
2076
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
2077 /* Predicate each write to memory in LOOP.
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
2078
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
2079 This function transforms control flow constructs containing memory
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
2080 writes of the form:
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
2081
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
2082 | for (i = 0; i < N; i++)
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
2083 | if (cond)
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
2084 | A[i] = expr;
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
2085
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
2086 into the following form that does not contain control flow:
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
2087
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
2088 | for (i = 0; i < N; i++)
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
2089 | A[i] = cond ? expr : A[i];
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
2090
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
2091 The original CFG looks like this:
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
2092
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
2093 | bb_0
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
2094 | i = 0
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
2095 | end_bb_0
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
2096 |
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
2097 | bb_1
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
2098 | if (i < N) goto bb_5 else goto bb_2
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
2099 | end_bb_1
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
2100 |
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
2101 | bb_2
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
2102 | cond = some_computation;
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
2103 | if (cond) goto bb_3 else goto bb_4
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
2104 | end_bb_2
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
2105 |
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
2106 | bb_3
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
2107 | A[i] = expr;
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
2108 | goto bb_4
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
2109 | end_bb_3
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
2110 |
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
2111 | bb_4
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
2112 | goto bb_1
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
2113 | end_bb_4
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
2114
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
2115 insert_gimplified_predicates inserts the computation of the COND
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
2116 expression at the beginning of the destination basic block:
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
2117
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
2118 | bb_0
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
2119 | i = 0
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
2120 | end_bb_0
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
2121 |
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
2122 | bb_1
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
2123 | if (i < N) goto bb_5 else goto bb_2
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
2124 | end_bb_1
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
2125 |
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
2126 | bb_2
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
2127 | cond = some_computation;
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
2128 | if (cond) goto bb_3 else goto bb_4
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
2129 | end_bb_2
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
2130 |
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
2131 | bb_3
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
2132 | cond = some_computation;
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
2133 | A[i] = expr;
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
2134 | goto bb_4
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
2135 | end_bb_3
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
2136 |
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
2137 | bb_4
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
2138 | goto bb_1
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
2139 | end_bb_4
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
2140
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
2141 predicate_mem_writes is then predicating the memory write as follows:
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
2142
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
2143 | bb_0
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
2144 | i = 0
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
2145 | end_bb_0
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
2146 |
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
2147 | bb_1
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
2148 | if (i < N) goto bb_5 else goto bb_2
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
2149 | end_bb_1
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
2150 |
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
2151 | bb_2
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
2152 | if (cond) goto bb_3 else goto bb_4
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
2153 | end_bb_2
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
2154 |
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
2155 | bb_3
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
2156 | cond = some_computation;
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
2157 | A[i] = cond ? expr : A[i];
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
2158 | goto bb_4
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
2159 | end_bb_3
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
2160 |
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
2161 | bb_4
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
2162 | goto bb_1
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
2163 | end_bb_4
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
2164
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
2165 and finally combine_blocks removes the basic block boundaries making
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
2166 the loop vectorizable:
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
2167
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
2168 | bb_0
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
2169 | i = 0
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
2170 | if (i < N) goto bb_5 else goto bb_1
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
2171 | end_bb_0
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
2172 |
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
2173 | bb_1
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
2174 | cond = some_computation;
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
2175 | A[i] = cond ? expr : A[i];
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
2176 | if (i < N) goto bb_5 else goto bb_4
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
2177 | end_bb_1
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
2178 |
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
2179 | bb_4
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
2180 | goto bb_1
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
2181 | end_bb_4
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
2182 */
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
2183
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
2184 static void
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
2185 predicate_mem_writes (loop_p loop)
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
2186 {
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
2187 unsigned int i, orig_loop_num_nodes = loop->num_nodes;
111
kono
parents: 67
diff changeset
2188 auto_vec<int, 1> vect_sizes;
kono
parents: 67
diff changeset
2189 auto_vec<tree, 1> vect_masks;
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
2190
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
2191 for (i = 1; i < orig_loop_num_nodes; i++)
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
2192 {
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
2193 gimple_stmt_iterator gsi;
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
2194 basic_block bb = ifc_bbs[i];
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
2195 tree cond = bb_predicate (bb);
111
kono
parents: 67
diff changeset
2196 bool swap;
kono
parents: 67
diff changeset
2197 gimple *stmt;
kono
parents: 67
diff changeset
2198 int index;
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
2199
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
2200 if (is_true_predicate (cond))
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
2201 continue;
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
2202
111
kono
parents: 67
diff changeset
2203 swap = false;
kono
parents: 67
diff changeset
2204 if (TREE_CODE (cond) == TRUTH_NOT_EXPR)
kono
parents: 67
diff changeset
2205 {
kono
parents: 67
diff changeset
2206 swap = true;
kono
parents: 67
diff changeset
2207 cond = TREE_OPERAND (cond, 0);
kono
parents: 67
diff changeset
2208 }
kono
parents: 67
diff changeset
2209
kono
parents: 67
diff changeset
2210 vect_sizes.truncate (0);
kono
parents: 67
diff changeset
2211 vect_masks.truncate (0);
kono
parents: 67
diff changeset
2212
kono
parents: 67
diff changeset
2213 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi);)
kono
parents: 67
diff changeset
2214 {
kono
parents: 67
diff changeset
2215 if (!gimple_assign_single_p (stmt = gsi_stmt (gsi)))
kono
parents: 67
diff changeset
2216 ;
kono
parents: 67
diff changeset
2217 else if (is_false_predicate (cond)
kono
parents: 67
diff changeset
2218 && gimple_vdef (stmt))
kono
parents: 67
diff changeset
2219 {
kono
parents: 67
diff changeset
2220 unlink_stmt_vdef (stmt);
kono
parents: 67
diff changeset
2221 gsi_remove (&gsi, true);
kono
parents: 67
diff changeset
2222 release_defs (stmt);
kono
parents: 67
diff changeset
2223 continue;
kono
parents: 67
diff changeset
2224 }
kono
parents: 67
diff changeset
2225 else if (gimple_plf (stmt, GF_PLF_2))
kono
parents: 67
diff changeset
2226 {
kono
parents: 67
diff changeset
2227 tree lhs = gimple_assign_lhs (stmt);
kono
parents: 67
diff changeset
2228 tree rhs = gimple_assign_rhs1 (stmt);
kono
parents: 67
diff changeset
2229 tree ref, addr, ptr, mask;
kono
parents: 67
diff changeset
2230 gcall *new_stmt;
kono
parents: 67
diff changeset
2231 gimple_seq stmts = NULL;
kono
parents: 67
diff changeset
2232 int bitsize = GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (lhs)));
kono
parents: 67
diff changeset
2233 ref = TREE_CODE (lhs) == SSA_NAME ? rhs : lhs;
kono
parents: 67
diff changeset
2234 mark_addressable (ref);
kono
parents: 67
diff changeset
2235 addr = force_gimple_operand_gsi (&gsi, build_fold_addr_expr (ref),
kono
parents: 67
diff changeset
2236 true, NULL_TREE, true,
kono
parents: 67
diff changeset
2237 GSI_SAME_STMT);
kono
parents: 67
diff changeset
2238 if (!vect_sizes.is_empty ()
kono
parents: 67
diff changeset
2239 && (index = mask_exists (bitsize, vect_sizes)) != -1)
kono
parents: 67
diff changeset
2240 /* Use created mask. */
kono
parents: 67
diff changeset
2241 mask = vect_masks[index];
kono
parents: 67
diff changeset
2242 else
kono
parents: 67
diff changeset
2243 {
kono
parents: 67
diff changeset
2244 if (COMPARISON_CLASS_P (cond))
kono
parents: 67
diff changeset
2245 mask = gimple_build (&stmts, TREE_CODE (cond),
kono
parents: 67
diff changeset
2246 boolean_type_node,
kono
parents: 67
diff changeset
2247 TREE_OPERAND (cond, 0),
kono
parents: 67
diff changeset
2248 TREE_OPERAND (cond, 1));
kono
parents: 67
diff changeset
2249 else
kono
parents: 67
diff changeset
2250 {
kono
parents: 67
diff changeset
2251 gcc_assert (TREE_CODE (cond) == SSA_NAME);
kono
parents: 67
diff changeset
2252 mask = cond;
kono
parents: 67
diff changeset
2253 }
kono
parents: 67
diff changeset
2254
kono
parents: 67
diff changeset
2255 if (swap)
kono
parents: 67
diff changeset
2256 {
kono
parents: 67
diff changeset
2257 tree true_val
kono
parents: 67
diff changeset
2258 = constant_boolean_node (true, TREE_TYPE (mask));
kono
parents: 67
diff changeset
2259 mask = gimple_build (&stmts, BIT_XOR_EXPR,
kono
parents: 67
diff changeset
2260 TREE_TYPE (mask), mask, true_val);
kono
parents: 67
diff changeset
2261 }
kono
parents: 67
diff changeset
2262 gsi_insert_seq_before (&gsi, stmts, GSI_SAME_STMT);
kono
parents: 67
diff changeset
2263
kono
parents: 67
diff changeset
2264 mask = ifc_temp_var (TREE_TYPE (mask), mask, &gsi);
kono
parents: 67
diff changeset
2265 /* Save mask and its size for further use. */
kono
parents: 67
diff changeset
2266 vect_sizes.safe_push (bitsize);
kono
parents: 67
diff changeset
2267 vect_masks.safe_push (mask);
kono
parents: 67
diff changeset
2268 }
kono
parents: 67
diff changeset
2269 ptr = build_int_cst (reference_alias_ptr_type (ref),
kono
parents: 67
diff changeset
2270 get_object_alignment (ref));
kono
parents: 67
diff changeset
2271 /* Copy points-to info if possible. */
kono
parents: 67
diff changeset
2272 if (TREE_CODE (addr) == SSA_NAME && !SSA_NAME_PTR_INFO (addr))
kono
parents: 67
diff changeset
2273 copy_ref_info (build2 (MEM_REF, TREE_TYPE (ref), addr, ptr),
kono
parents: 67
diff changeset
2274 ref);
kono
parents: 67
diff changeset
2275 if (TREE_CODE (lhs) == SSA_NAME)
kono
parents: 67
diff changeset
2276 {
kono
parents: 67
diff changeset
2277 new_stmt
kono
parents: 67
diff changeset
2278 = gimple_build_call_internal (IFN_MASK_LOAD, 3, addr,
kono
parents: 67
diff changeset
2279 ptr, mask);
kono
parents: 67
diff changeset
2280 gimple_call_set_lhs (new_stmt, lhs);
kono
parents: 67
diff changeset
2281 gimple_set_vuse (new_stmt, gimple_vuse (stmt));
kono
parents: 67
diff changeset
2282 }
kono
parents: 67
diff changeset
2283 else
kono
parents: 67
diff changeset
2284 {
kono
parents: 67
diff changeset
2285 new_stmt
kono
parents: 67
diff changeset
2286 = gimple_build_call_internal (IFN_MASK_STORE, 4, addr, ptr,
kono
parents: 67
diff changeset
2287 mask, rhs);
kono
parents: 67
diff changeset
2288 gimple_set_vuse (new_stmt, gimple_vuse (stmt));
kono
parents: 67
diff changeset
2289 gimple_set_vdef (new_stmt, gimple_vdef (stmt));
kono
parents: 67
diff changeset
2290 SSA_NAME_DEF_STMT (gimple_vdef (new_stmt)) = new_stmt;
kono
parents: 67
diff changeset
2291 }
kono
parents: 67
diff changeset
2292 gimple_call_set_nothrow (new_stmt, true);
kono
parents: 67
diff changeset
2293
kono
parents: 67
diff changeset
2294 gsi_replace (&gsi, new_stmt, true);
kono
parents: 67
diff changeset
2295 }
kono
parents: 67
diff changeset
2296 else if (gimple_vdef (stmt))
kono
parents: 67
diff changeset
2297 {
kono
parents: 67
diff changeset
2298 tree lhs = gimple_assign_lhs (stmt);
kono
parents: 67
diff changeset
2299 tree rhs = gimple_assign_rhs1 (stmt);
kono
parents: 67
diff changeset
2300 tree type = TREE_TYPE (lhs);
kono
parents: 67
diff changeset
2301
kono
parents: 67
diff changeset
2302 lhs = ifc_temp_var (type, unshare_expr (lhs), &gsi);
kono
parents: 67
diff changeset
2303 rhs = ifc_temp_var (type, unshare_expr (rhs), &gsi);
kono
parents: 67
diff changeset
2304 if (swap)
kono
parents: 67
diff changeset
2305 std::swap (lhs, rhs);
kono
parents: 67
diff changeset
2306 cond = force_gimple_operand_gsi_1 (&gsi, unshare_expr (cond),
kono
parents: 67
diff changeset
2307 is_gimple_condexpr, NULL_TREE,
kono
parents: 67
diff changeset
2308 true, GSI_SAME_STMT);
kono
parents: 67
diff changeset
2309 rhs = fold_build_cond_expr (type, unshare_expr (cond), rhs, lhs);
kono
parents: 67
diff changeset
2310 gimple_assign_set_rhs1 (stmt, ifc_temp_var (type, rhs, &gsi));
kono
parents: 67
diff changeset
2311 update_stmt (stmt);
kono
parents: 67
diff changeset
2312 }
kono
parents: 67
diff changeset
2313 gsi_next (&gsi);
kono
parents: 67
diff changeset
2314 }
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
2315 }
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
2316 }
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
2317
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
2318 /* Remove all GIMPLE_CONDs and GIMPLE_LABELs of all the basic blocks
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
2319 other than the exit and latch of the LOOP. Also resets the
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
2320 GIMPLE_DEBUG information. */
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
2321
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
2322 static void
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
2323 remove_conditions_and_labels (loop_p loop)
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
2324 {
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
2325 gimple_stmt_iterator gsi;
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
2326 unsigned int i;
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
2327
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
2328 for (i = 0; i < loop->num_nodes; i++)
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
2329 {
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
2330 basic_block bb = ifc_bbs[i];
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
2331
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
2332 if (bb_with_exit_edge_p (loop, bb)
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
2333 || bb == loop->latch)
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
2334 continue;
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
2335
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
2336 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); )
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
2337 switch (gimple_code (gsi_stmt (gsi)))
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
2338 {
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
2339 case GIMPLE_COND:
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
2340 case GIMPLE_LABEL:
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
2341 gsi_remove (&gsi, true);
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
2342 break;
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
2343
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
2344 case GIMPLE_DEBUG:
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
2345 /* ??? Should there be conditional GIMPLE_DEBUG_BINDs? */
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
2346 if (gimple_debug_bind_p (gsi_stmt (gsi)))
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
2347 {
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
2348 gimple_debug_bind_reset_value (gsi_stmt (gsi));
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
2349 update_stmt (gsi_stmt (gsi));
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
2350 }
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
2351 gsi_next (&gsi);
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
2352 break;
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
2353
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
2354 default:
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
2355 gsi_next (&gsi);
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
2356 }
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
2357 }
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
2358 }
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
2359
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2360 /* Combine all the basic blocks from LOOP into one or two super basic
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2361 blocks. Replace PHI nodes with conditional modify expressions. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2362
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2363 static void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2364 combine_blocks (struct loop *loop)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2365 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2366 basic_block bb, exit_bb, merge_target_bb;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2367 unsigned int orig_loop_num_nodes = loop->num_nodes;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2368 unsigned int i;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2369 edge e;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2370 edge_iterator ei;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2371
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
2372 remove_conditions_and_labels (loop);
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
2373 insert_gimplified_predicates (loop);
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
2374 predicate_all_scalar_phis (loop);
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
2375
111
kono
parents: 67
diff changeset
2376 if (any_pred_load_store)
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
2377 predicate_mem_writes (loop);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2378
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2379 /* Merge basic blocks: first remove all the edges in the loop,
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2380 except for those from the exit block. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2381 exit_bb = NULL;
111
kono
parents: 67
diff changeset
2382 bool *predicated = XNEWVEC (bool, orig_loop_num_nodes);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2383 for (i = 0; i < orig_loop_num_nodes; i++)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2384 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2385 bb = ifc_bbs[i];
111
kono
parents: 67
diff changeset
2386 predicated[i] = !is_true_predicate (bb_predicate (bb));
kono
parents: 67
diff changeset
2387 free_bb_predicate (bb);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2388 if (bb_with_exit_edge_p (loop, bb))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2389 {
111
kono
parents: 67
diff changeset
2390 gcc_assert (exit_bb == NULL);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2391 exit_bb = bb;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2392 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2393 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2394 gcc_assert (exit_bb != loop->latch);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2395
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2396 for (i = 1; i < orig_loop_num_nodes; i++)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2397 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2398 bb = ifc_bbs[i];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2399
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2400 for (ei = ei_start (bb->preds); (e = ei_safe_edge (ei));)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2401 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2402 if (e->src == exit_bb)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2403 ei_next (&ei);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2404 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2405 remove_edge (e);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2406 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2407 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2408
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2409 if (exit_bb != NULL)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2410 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2411 if (exit_bb != loop->header)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2412 {
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2413 /* Connect this node to loop header. */
111
kono
parents: 67
diff changeset
2414 make_single_succ_edge (loop->header, exit_bb, EDGE_FALLTHRU);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2415 set_immediate_dominator (CDI_DOMINATORS, exit_bb, loop->header);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2416 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2417
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2418 /* Redirect non-exit edges to loop->latch. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2419 FOR_EACH_EDGE (e, ei, exit_bb->succs)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2420 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2421 if (!loop_exit_edge_p (loop, e))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2422 redirect_edge_and_branch (e, loop->latch);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2423 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2424 set_immediate_dominator (CDI_DOMINATORS, loop->latch, exit_bb);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2425 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2426 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2427 {
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2428 /* If the loop does not have an exit, reconnect header and latch. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2429 make_edge (loop->header, loop->latch, EDGE_FALLTHRU);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2430 set_immediate_dominator (CDI_DOMINATORS, loop->latch, loop->header);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2431 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2432
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2433 merge_target_bb = loop->header;
111
kono
parents: 67
diff changeset
2434
kono
parents: 67
diff changeset
2435 /* Get at the virtual def valid for uses starting at the first block
kono
parents: 67
diff changeset
2436 we merge into the header. Without a virtual PHI the loop has the
kono
parents: 67
diff changeset
2437 same virtual use on all stmts. */
kono
parents: 67
diff changeset
2438 gphi *vphi = get_virtual_phi (loop->header);
kono
parents: 67
diff changeset
2439 tree last_vdef = NULL_TREE;
kono
parents: 67
diff changeset
2440 if (vphi)
kono
parents: 67
diff changeset
2441 {
kono
parents: 67
diff changeset
2442 last_vdef = gimple_phi_result (vphi);
kono
parents: 67
diff changeset
2443 for (gimple_stmt_iterator gsi = gsi_start_bb (loop->header);
kono
parents: 67
diff changeset
2444 ! gsi_end_p (gsi); gsi_next (&gsi))
kono
parents: 67
diff changeset
2445 if (gimple_vdef (gsi_stmt (gsi)))
kono
parents: 67
diff changeset
2446 last_vdef = gimple_vdef (gsi_stmt (gsi));
kono
parents: 67
diff changeset
2447 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2448 for (i = 1; i < orig_loop_num_nodes; i++)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2449 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2450 gimple_stmt_iterator gsi;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2451 gimple_stmt_iterator last;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2452
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2453 bb = ifc_bbs[i];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2454
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2455 if (bb == exit_bb || bb == loop->latch)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2456 continue;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2457
111
kono
parents: 67
diff changeset
2458 /* We release virtual PHIs late because we have to propagate them
kono
parents: 67
diff changeset
2459 out using the current VUSE. The def might be the one used
kono
parents: 67
diff changeset
2460 after the loop. */
kono
parents: 67
diff changeset
2461 vphi = get_virtual_phi (bb);
kono
parents: 67
diff changeset
2462 if (vphi)
kono
parents: 67
diff changeset
2463 {
kono
parents: 67
diff changeset
2464 imm_use_iterator iter;
kono
parents: 67
diff changeset
2465 use_operand_p use_p;
kono
parents: 67
diff changeset
2466 gimple *use_stmt;
kono
parents: 67
diff changeset
2467 FOR_EACH_IMM_USE_STMT (use_stmt, iter, gimple_phi_result (vphi))
kono
parents: 67
diff changeset
2468 {
kono
parents: 67
diff changeset
2469 FOR_EACH_IMM_USE_ON_STMT (use_p, iter)
kono
parents: 67
diff changeset
2470 SET_USE (use_p, last_vdef);
kono
parents: 67
diff changeset
2471 }
kono
parents: 67
diff changeset
2472 gsi = gsi_for_stmt (vphi);
kono
parents: 67
diff changeset
2473 remove_phi_node (&gsi, true);
kono
parents: 67
diff changeset
2474 }
kono
parents: 67
diff changeset
2475
kono
parents: 67
diff changeset
2476 /* Make stmts member of loop->header and clear range info from all stmts
kono
parents: 67
diff changeset
2477 in BB which is now no longer executed conditional on a predicate we
kono
parents: 67
diff changeset
2478 could have derived it from. */
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
2479 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
111
kono
parents: 67
diff changeset
2480 {
kono
parents: 67
diff changeset
2481 gimple *stmt = gsi_stmt (gsi);
kono
parents: 67
diff changeset
2482 gimple_set_bb (stmt, merge_target_bb);
kono
parents: 67
diff changeset
2483 /* Update virtual operands. */
kono
parents: 67
diff changeset
2484 if (last_vdef)
kono
parents: 67
diff changeset
2485 {
kono
parents: 67
diff changeset
2486 use_operand_p use_p = ssa_vuse_operand (stmt);
kono
parents: 67
diff changeset
2487 if (use_p
kono
parents: 67
diff changeset
2488 && USE_FROM_PTR (use_p) != last_vdef)
kono
parents: 67
diff changeset
2489 SET_USE (use_p, last_vdef);
kono
parents: 67
diff changeset
2490 if (gimple_vdef (stmt))
kono
parents: 67
diff changeset
2491 last_vdef = gimple_vdef (stmt);
kono
parents: 67
diff changeset
2492 }
kono
parents: 67
diff changeset
2493 if (predicated[i])
kono
parents: 67
diff changeset
2494 {
kono
parents: 67
diff changeset
2495 ssa_op_iter i;
kono
parents: 67
diff changeset
2496 tree op;
kono
parents: 67
diff changeset
2497 FOR_EACH_SSA_TREE_OPERAND (op, stmt, i, SSA_OP_DEF)
kono
parents: 67
diff changeset
2498 reset_flow_sensitive_info (op);
kono
parents: 67
diff changeset
2499 }
kono
parents: 67
diff changeset
2500 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2501
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2502 /* Update stmt list. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2503 last = gsi_last_bb (merge_target_bb);
111
kono
parents: 67
diff changeset
2504 gsi_insert_seq_after_without_update (&last, bb_seq (bb), GSI_NEW_STMT);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2505 set_bb_seq (bb, NULL);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2506
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2507 delete_basic_block (bb);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2508 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2509
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2510 /* If possible, merge loop header to the block with the exit edge.
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2511 This reduces the number of basic blocks to two, to please the
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
2512 vectorizer that handles only loops with two nodes. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2513 if (exit_bb
111
kono
parents: 67
diff changeset
2514 && exit_bb != loop->header)
kono
parents: 67
diff changeset
2515 {
kono
parents: 67
diff changeset
2516 /* We release virtual PHIs late because we have to propagate them
kono
parents: 67
diff changeset
2517 out using the current VUSE. The def might be the one used
kono
parents: 67
diff changeset
2518 after the loop. */
kono
parents: 67
diff changeset
2519 vphi = get_virtual_phi (exit_bb);
kono
parents: 67
diff changeset
2520 if (vphi)
kono
parents: 67
diff changeset
2521 {
kono
parents: 67
diff changeset
2522 imm_use_iterator iter;
kono
parents: 67
diff changeset
2523 use_operand_p use_p;
kono
parents: 67
diff changeset
2524 gimple *use_stmt;
kono
parents: 67
diff changeset
2525 FOR_EACH_IMM_USE_STMT (use_stmt, iter, gimple_phi_result (vphi))
kono
parents: 67
diff changeset
2526 {
kono
parents: 67
diff changeset
2527 FOR_EACH_IMM_USE_ON_STMT (use_p, iter)
kono
parents: 67
diff changeset
2528 SET_USE (use_p, last_vdef);
kono
parents: 67
diff changeset
2529 }
kono
parents: 67
diff changeset
2530 gimple_stmt_iterator gsi = gsi_for_stmt (vphi);
kono
parents: 67
diff changeset
2531 remove_phi_node (&gsi, true);
kono
parents: 67
diff changeset
2532 }
kono
parents: 67
diff changeset
2533
kono
parents: 67
diff changeset
2534 if (can_merge_blocks_p (loop->header, exit_bb))
kono
parents: 67
diff changeset
2535 merge_blocks (loop->header, exit_bb);
kono
parents: 67
diff changeset
2536 }
kono
parents: 67
diff changeset
2537
kono
parents: 67
diff changeset
2538 free (ifc_bbs);
kono
parents: 67
diff changeset
2539 ifc_bbs = NULL;
kono
parents: 67
diff changeset
2540 free (predicated);
kono
parents: 67
diff changeset
2541 }
kono
parents: 67
diff changeset
2542
kono
parents: 67
diff changeset
2543 /* Version LOOP before if-converting it; the original loop
kono
parents: 67
diff changeset
2544 will be if-converted, the new copy of the loop will not,
kono
parents: 67
diff changeset
2545 and the LOOP_VECTORIZED internal call will be guarding which
kono
parents: 67
diff changeset
2546 loop to execute. The vectorizer pass will fold this
kono
parents: 67
diff changeset
2547 internal call into either true or false.
kono
parents: 67
diff changeset
2548
kono
parents: 67
diff changeset
2549 Note that this function intentionally invalidates profile. Both edges
kono
parents: 67
diff changeset
2550 out of LOOP_VECTORIZED must have 100% probability so the profile remains
kono
parents: 67
diff changeset
2551 consistent after the condition is folded in the vectorizer. */
kono
parents: 67
diff changeset
2552
kono
parents: 67
diff changeset
2553 static struct loop *
kono
parents: 67
diff changeset
2554 version_loop_for_if_conversion (struct loop *loop)
kono
parents: 67
diff changeset
2555 {
kono
parents: 67
diff changeset
2556 basic_block cond_bb;
kono
parents: 67
diff changeset
2557 tree cond = make_ssa_name (boolean_type_node);
kono
parents: 67
diff changeset
2558 struct loop *new_loop;
kono
parents: 67
diff changeset
2559 gimple *g;
kono
parents: 67
diff changeset
2560 gimple_stmt_iterator gsi;
kono
parents: 67
diff changeset
2561 unsigned int save_length;
kono
parents: 67
diff changeset
2562
kono
parents: 67
diff changeset
2563 g = gimple_build_call_internal (IFN_LOOP_VECTORIZED, 2,
kono
parents: 67
diff changeset
2564 build_int_cst (integer_type_node, loop->num),
kono
parents: 67
diff changeset
2565 integer_zero_node);
kono
parents: 67
diff changeset
2566 gimple_call_set_lhs (g, cond);
kono
parents: 67
diff changeset
2567
kono
parents: 67
diff changeset
2568 /* Save BB->aux around loop_version as that uses the same field. */
kono
parents: 67
diff changeset
2569 save_length = loop->inner ? loop->inner->num_nodes : loop->num_nodes;
kono
parents: 67
diff changeset
2570 void **saved_preds = XALLOCAVEC (void *, save_length);
kono
parents: 67
diff changeset
2571 for (unsigned i = 0; i < save_length; i++)
kono
parents: 67
diff changeset
2572 saved_preds[i] = ifc_bbs[i]->aux;
kono
parents: 67
diff changeset
2573
kono
parents: 67
diff changeset
2574 initialize_original_copy_tables ();
kono
parents: 67
diff changeset
2575 /* At this point we invalidate porfile confistency until IFN_LOOP_VECTORIZED
kono
parents: 67
diff changeset
2576 is re-merged in the vectorizer. */
kono
parents: 67
diff changeset
2577 new_loop = loop_version (loop, cond, &cond_bb,
kono
parents: 67
diff changeset
2578 profile_probability::always (),
kono
parents: 67
diff changeset
2579 profile_probability::always (),
kono
parents: 67
diff changeset
2580 profile_probability::always (),
kono
parents: 67
diff changeset
2581 profile_probability::always (), true);
kono
parents: 67
diff changeset
2582 free_original_copy_tables ();
kono
parents: 67
diff changeset
2583
kono
parents: 67
diff changeset
2584 for (unsigned i = 0; i < save_length; i++)
kono
parents: 67
diff changeset
2585 ifc_bbs[i]->aux = saved_preds[i];
kono
parents: 67
diff changeset
2586
kono
parents: 67
diff changeset
2587 if (new_loop == NULL)
kono
parents: 67
diff changeset
2588 return NULL;
kono
parents: 67
diff changeset
2589
kono
parents: 67
diff changeset
2590 new_loop->dont_vectorize = true;
kono
parents: 67
diff changeset
2591 new_loop->force_vectorize = false;
kono
parents: 67
diff changeset
2592 gsi = gsi_last_bb (cond_bb);
kono
parents: 67
diff changeset
2593 gimple_call_set_arg (g, 1, build_int_cst (integer_type_node, new_loop->num));
kono
parents: 67
diff changeset
2594 gsi_insert_before (&gsi, g, GSI_SAME_STMT);
kono
parents: 67
diff changeset
2595 update_ssa (TODO_update_ssa);
kono
parents: 67
diff changeset
2596 return new_loop;
kono
parents: 67
diff changeset
2597 }
kono
parents: 67
diff changeset
2598
kono
parents: 67
diff changeset
2599 /* Return true when LOOP satisfies the follow conditions that will
kono
parents: 67
diff changeset
2600 allow it to be recognized by the vectorizer for outer-loop
kono
parents: 67
diff changeset
2601 vectorization:
kono
parents: 67
diff changeset
2602 - The loop is not the root node of the loop tree.
kono
parents: 67
diff changeset
2603 - The loop has exactly one inner loop.
kono
parents: 67
diff changeset
2604 - The loop has a single exit.
kono
parents: 67
diff changeset
2605 - The loop header has a single successor, which is the inner
kono
parents: 67
diff changeset
2606 loop header.
kono
parents: 67
diff changeset
2607 - Each of the inner and outer loop latches have a single
kono
parents: 67
diff changeset
2608 predecessor.
kono
parents: 67
diff changeset
2609 - The loop exit block has a single predecessor, which is the
kono
parents: 67
diff changeset
2610 inner loop's exit block. */
kono
parents: 67
diff changeset
2611
kono
parents: 67
diff changeset
2612 static bool
kono
parents: 67
diff changeset
2613 versionable_outer_loop_p (struct loop *loop)
kono
parents: 67
diff changeset
2614 {
kono
parents: 67
diff changeset
2615 if (!loop_outer (loop)
kono
parents: 67
diff changeset
2616 || loop->dont_vectorize
kono
parents: 67
diff changeset
2617 || !loop->inner
kono
parents: 67
diff changeset
2618 || loop->inner->next
kono
parents: 67
diff changeset
2619 || !single_exit (loop)
kono
parents: 67
diff changeset
2620 || !single_succ_p (loop->header)
kono
parents: 67
diff changeset
2621 || single_succ (loop->header) != loop->inner->header
kono
parents: 67
diff changeset
2622 || !single_pred_p (loop->latch)
kono
parents: 67
diff changeset
2623 || !single_pred_p (loop->inner->latch))
kono
parents: 67
diff changeset
2624 return false;
kono
parents: 67
diff changeset
2625
kono
parents: 67
diff changeset
2626 basic_block outer_exit = single_pred (loop->latch);
kono
parents: 67
diff changeset
2627 basic_block inner_exit = single_pred (loop->inner->latch);
kono
parents: 67
diff changeset
2628
kono
parents: 67
diff changeset
2629 if (!single_pred_p (outer_exit) || single_pred (outer_exit) != inner_exit)
kono
parents: 67
diff changeset
2630 return false;
kono
parents: 67
diff changeset
2631
kono
parents: 67
diff changeset
2632 if (dump_file)
kono
parents: 67
diff changeset
2633 fprintf (dump_file, "Found vectorizable outer loop for versioning\n");
kono
parents: 67
diff changeset
2634
kono
parents: 67
diff changeset
2635 return true;
kono
parents: 67
diff changeset
2636 }
kono
parents: 67
diff changeset
2637
kono
parents: 67
diff changeset
2638 /* Performs splitting of critical edges. Skip splitting and return false
kono
parents: 67
diff changeset
2639 if LOOP will not be converted because:
kono
parents: 67
diff changeset
2640
kono
parents: 67
diff changeset
2641 - LOOP is not well formed.
kono
parents: 67
diff changeset
2642 - LOOP has PHI with more than MAX_PHI_ARG_NUM arguments.
kono
parents: 67
diff changeset
2643
kono
parents: 67
diff changeset
2644 Last restriction is valid only if AGGRESSIVE_IF_CONV is false. */
kono
parents: 67
diff changeset
2645
kono
parents: 67
diff changeset
2646 static bool
kono
parents: 67
diff changeset
2647 ifcvt_split_critical_edges (struct loop *loop, bool aggressive_if_conv)
kono
parents: 67
diff changeset
2648 {
kono
parents: 67
diff changeset
2649 basic_block *body;
kono
parents: 67
diff changeset
2650 basic_block bb;
kono
parents: 67
diff changeset
2651 unsigned int num = loop->num_nodes;
kono
parents: 67
diff changeset
2652 unsigned int i;
kono
parents: 67
diff changeset
2653 gimple *stmt;
kono
parents: 67
diff changeset
2654 edge e;
kono
parents: 67
diff changeset
2655 edge_iterator ei;
kono
parents: 67
diff changeset
2656 auto_vec<edge> critical_edges;
kono
parents: 67
diff changeset
2657
kono
parents: 67
diff changeset
2658 /* Loop is not well formed. */
kono
parents: 67
diff changeset
2659 if (num <= 2 || loop->inner || !single_exit (loop))
kono
parents: 67
diff changeset
2660 return false;
kono
parents: 67
diff changeset
2661
kono
parents: 67
diff changeset
2662 body = get_loop_body (loop);
kono
parents: 67
diff changeset
2663 for (i = 0; i < num; i++)
kono
parents: 67
diff changeset
2664 {
kono
parents: 67
diff changeset
2665 bb = body[i];
kono
parents: 67
diff changeset
2666 if (!aggressive_if_conv
kono
parents: 67
diff changeset
2667 && phi_nodes (bb)
kono
parents: 67
diff changeset
2668 && EDGE_COUNT (bb->preds) > MAX_PHI_ARG_NUM)
kono
parents: 67
diff changeset
2669 {
kono
parents: 67
diff changeset
2670 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents: 67
diff changeset
2671 fprintf (dump_file,
kono
parents: 67
diff changeset
2672 "BB %d has complicated PHI with more than %u args.\n",
kono
parents: 67
diff changeset
2673 bb->index, MAX_PHI_ARG_NUM);
kono
parents: 67
diff changeset
2674
kono
parents: 67
diff changeset
2675 free (body);
kono
parents: 67
diff changeset
2676 return false;
kono
parents: 67
diff changeset
2677 }
kono
parents: 67
diff changeset
2678 if (bb == loop->latch || bb_with_exit_edge_p (loop, bb))
kono
parents: 67
diff changeset
2679 continue;
kono
parents: 67
diff changeset
2680
kono
parents: 67
diff changeset
2681 stmt = last_stmt (bb);
kono
parents: 67
diff changeset
2682 /* Skip basic blocks not ending with conditional branch. */
kono
parents: 67
diff changeset
2683 if (!stmt || gimple_code (stmt) != GIMPLE_COND)
kono
parents: 67
diff changeset
2684 continue;
kono
parents: 67
diff changeset
2685
kono
parents: 67
diff changeset
2686 FOR_EACH_EDGE (e, ei, bb->succs)
kono
parents: 67
diff changeset
2687 if (EDGE_CRITICAL_P (e) && e->dest->loop_father == loop)
kono
parents: 67
diff changeset
2688 critical_edges.safe_push (e);
kono
parents: 67
diff changeset
2689 }
kono
parents: 67
diff changeset
2690 free (body);
kono
parents: 67
diff changeset
2691
kono
parents: 67
diff changeset
2692 while (critical_edges.length () > 0)
kono
parents: 67
diff changeset
2693 {
kono
parents: 67
diff changeset
2694 e = critical_edges.pop ();
kono
parents: 67
diff changeset
2695 /* Don't split if bb can be predicated along non-critical edge. */
kono
parents: 67
diff changeset
2696 if (EDGE_COUNT (e->dest->preds) > 2 || all_preds_critical_p (e->dest))
kono
parents: 67
diff changeset
2697 split_edge (e);
kono
parents: 67
diff changeset
2698 }
kono
parents: 67
diff changeset
2699
kono
parents: 67
diff changeset
2700 return true;
kono
parents: 67
diff changeset
2701 }
kono
parents: 67
diff changeset
2702
kono
parents: 67
diff changeset
2703 /* Delete redundant statements produced by predication which prevents
kono
parents: 67
diff changeset
2704 loop vectorization. */
kono
parents: 67
diff changeset
2705
kono
parents: 67
diff changeset
2706 static void
kono
parents: 67
diff changeset
2707 ifcvt_local_dce (basic_block bb)
kono
parents: 67
diff changeset
2708 {
kono
parents: 67
diff changeset
2709 gimple *stmt;
kono
parents: 67
diff changeset
2710 gimple *stmt1;
kono
parents: 67
diff changeset
2711 gimple *phi;
kono
parents: 67
diff changeset
2712 gimple_stmt_iterator gsi;
kono
parents: 67
diff changeset
2713 auto_vec<gimple *> worklist;
kono
parents: 67
diff changeset
2714 enum gimple_code code;
kono
parents: 67
diff changeset
2715 use_operand_p use_p;
kono
parents: 67
diff changeset
2716 imm_use_iterator imm_iter;
kono
parents: 67
diff changeset
2717
kono
parents: 67
diff changeset
2718 worklist.create (64);
kono
parents: 67
diff changeset
2719 /* Consider all phi as live statements. */
kono
parents: 67
diff changeset
2720 for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
kono
parents: 67
diff changeset
2721 {
kono
parents: 67
diff changeset
2722 phi = gsi_stmt (gsi);
kono
parents: 67
diff changeset
2723 gimple_set_plf (phi, GF_PLF_2, true);
kono
parents: 67
diff changeset
2724 worklist.safe_push (phi);
kono
parents: 67
diff changeset
2725 }
kono
parents: 67
diff changeset
2726 /* Consider load/store statements, CALL and COND as live. */
kono
parents: 67
diff changeset
2727 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
kono
parents: 67
diff changeset
2728 {
kono
parents: 67
diff changeset
2729 stmt = gsi_stmt (gsi);
kono
parents: 67
diff changeset
2730 if (gimple_store_p (stmt)
kono
parents: 67
diff changeset
2731 || gimple_assign_load_p (stmt)
kono
parents: 67
diff changeset
2732 || is_gimple_debug (stmt))
kono
parents: 67
diff changeset
2733 {
kono
parents: 67
diff changeset
2734 gimple_set_plf (stmt, GF_PLF_2, true);
kono
parents: 67
diff changeset
2735 worklist.safe_push (stmt);
kono
parents: 67
diff changeset
2736 continue;
kono
parents: 67
diff changeset
2737 }
kono
parents: 67
diff changeset
2738 code = gimple_code (stmt);
kono
parents: 67
diff changeset
2739 if (code == GIMPLE_COND || code == GIMPLE_CALL)
kono
parents: 67
diff changeset
2740 {
kono
parents: 67
diff changeset
2741 gimple_set_plf (stmt, GF_PLF_2, true);
kono
parents: 67
diff changeset
2742 worklist.safe_push (stmt);
kono
parents: 67
diff changeset
2743 continue;
kono
parents: 67
diff changeset
2744 }
kono
parents: 67
diff changeset
2745 gimple_set_plf (stmt, GF_PLF_2, false);
kono
parents: 67
diff changeset
2746
kono
parents: 67
diff changeset
2747 if (code == GIMPLE_ASSIGN)
kono
parents: 67
diff changeset
2748 {
kono
parents: 67
diff changeset
2749 tree lhs = gimple_assign_lhs (stmt);
kono
parents: 67
diff changeset
2750 FOR_EACH_IMM_USE_FAST (use_p, imm_iter, lhs)
kono
parents: 67
diff changeset
2751 {
kono
parents: 67
diff changeset
2752 stmt1 = USE_STMT (use_p);
kono
parents: 67
diff changeset
2753 if (gimple_bb (stmt1) != bb)
kono
parents: 67
diff changeset
2754 {
kono
parents: 67
diff changeset
2755 gimple_set_plf (stmt, GF_PLF_2, true);
kono
parents: 67
diff changeset
2756 worklist.safe_push (stmt);
kono
parents: 67
diff changeset
2757 break;
kono
parents: 67
diff changeset
2758 }
kono
parents: 67
diff changeset
2759 }
kono
parents: 67
diff changeset
2760 }
kono
parents: 67
diff changeset
2761 }
kono
parents: 67
diff changeset
2762 /* Propagate liveness through arguments of live stmt. */
kono
parents: 67
diff changeset
2763 while (worklist.length () > 0)
kono
parents: 67
diff changeset
2764 {
kono
parents: 67
diff changeset
2765 ssa_op_iter iter;
kono
parents: 67
diff changeset
2766 use_operand_p use_p;
kono
parents: 67
diff changeset
2767 tree use;
kono
parents: 67
diff changeset
2768
kono
parents: 67
diff changeset
2769 stmt = worklist.pop ();
kono
parents: 67
diff changeset
2770 FOR_EACH_PHI_OR_STMT_USE (use_p, stmt, iter, SSA_OP_USE)
kono
parents: 67
diff changeset
2771 {
kono
parents: 67
diff changeset
2772 use = USE_FROM_PTR (use_p);
kono
parents: 67
diff changeset
2773 if (TREE_CODE (use) != SSA_NAME)
kono
parents: 67
diff changeset
2774 continue;
kono
parents: 67
diff changeset
2775 stmt1 = SSA_NAME_DEF_STMT (use);
kono
parents: 67
diff changeset
2776 if (gimple_bb (stmt1) != bb
kono
parents: 67
diff changeset
2777 || gimple_plf (stmt1, GF_PLF_2))
kono
parents: 67
diff changeset
2778 continue;
kono
parents: 67
diff changeset
2779 gimple_set_plf (stmt1, GF_PLF_2, true);
kono
parents: 67
diff changeset
2780 worklist.safe_push (stmt1);
kono
parents: 67
diff changeset
2781 }
kono
parents: 67
diff changeset
2782 }
kono
parents: 67
diff changeset
2783 /* Delete dead statements. */
kono
parents: 67
diff changeset
2784 gsi = gsi_start_bb (bb);
kono
parents: 67
diff changeset
2785 while (!gsi_end_p (gsi))
kono
parents: 67
diff changeset
2786 {
kono
parents: 67
diff changeset
2787 stmt = gsi_stmt (gsi);
kono
parents: 67
diff changeset
2788 if (gimple_plf (stmt, GF_PLF_2))
kono
parents: 67
diff changeset
2789 {
kono
parents: 67
diff changeset
2790 gsi_next (&gsi);
kono
parents: 67
diff changeset
2791 continue;
kono
parents: 67
diff changeset
2792 }
kono
parents: 67
diff changeset
2793 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents: 67
diff changeset
2794 {
kono
parents: 67
diff changeset
2795 fprintf (dump_file, "Delete dead stmt in bb#%d\n", bb->index);
kono
parents: 67
diff changeset
2796 print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM);
kono
parents: 67
diff changeset
2797 }
kono
parents: 67
diff changeset
2798 gsi_remove (&gsi, true);
kono
parents: 67
diff changeset
2799 release_defs (stmt);
kono
parents: 67
diff changeset
2800 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2801 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2802
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
2803 /* If-convert LOOP when it is legal. For the moment this pass has no
111
kono
parents: 67
diff changeset
2804 profitability analysis. Returns non-zero todo flags when something
kono
parents: 67
diff changeset
2805 changed. */
kono
parents: 67
diff changeset
2806
kono
parents: 67
diff changeset
2807 unsigned int
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2808 tree_if_conversion (struct loop *loop)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2809 {
111
kono
parents: 67
diff changeset
2810 unsigned int todo = 0;
kono
parents: 67
diff changeset
2811 bool aggressive_if_conv;
kono
parents: 67
diff changeset
2812 struct loop *rloop;
kono
parents: 67
diff changeset
2813
kono
parents: 67
diff changeset
2814 again:
kono
parents: 67
diff changeset
2815 rloop = NULL;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2816 ifc_bbs = NULL;
111
kono
parents: 67
diff changeset
2817 any_pred_load_store = false;
kono
parents: 67
diff changeset
2818 any_complicated_phi = false;
kono
parents: 67
diff changeset
2819
kono
parents: 67
diff changeset
2820 /* Apply more aggressive if-conversion when loop or its outer loop were
kono
parents: 67
diff changeset
2821 marked with simd pragma. When that's the case, we try to if-convert
kono
parents: 67
diff changeset
2822 loop containing PHIs with more than MAX_PHI_ARG_NUM arguments. */
kono
parents: 67
diff changeset
2823 aggressive_if_conv = loop->force_vectorize;
kono
parents: 67
diff changeset
2824 if (!aggressive_if_conv)
kono
parents: 67
diff changeset
2825 {
kono
parents: 67
diff changeset
2826 struct loop *outer_loop = loop_outer (loop);
kono
parents: 67
diff changeset
2827 if (outer_loop && outer_loop->force_vectorize)
kono
parents: 67
diff changeset
2828 aggressive_if_conv = true;
kono
parents: 67
diff changeset
2829 }
kono
parents: 67
diff changeset
2830
kono
parents: 67
diff changeset
2831 if (!ifcvt_split_critical_edges (loop, aggressive_if_conv))
kono
parents: 67
diff changeset
2832 goto cleanup;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2833
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
2834 if (!if_convertible_loop_p (loop)
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
2835 || !dbg_cnt (if_conversion_tree))
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
2836 goto cleanup;
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
2837
111
kono
parents: 67
diff changeset
2838 if ((any_pred_load_store || any_complicated_phi)
kono
parents: 67
diff changeset
2839 && ((!flag_tree_loop_vectorize && !loop->force_vectorize)
kono
parents: 67
diff changeset
2840 || loop->dont_vectorize))
kono
parents: 67
diff changeset
2841 goto cleanup;
kono
parents: 67
diff changeset
2842
kono
parents: 67
diff changeset
2843 /* Since we have no cost model, always version loops unless the user
kono
parents: 67
diff changeset
2844 specified -ftree-loop-if-convert or unless versioning is required.
kono
parents: 67
diff changeset
2845 Either version this loop, or if the pattern is right for outer-loop
kono
parents: 67
diff changeset
2846 vectorization, version the outer loop. In the latter case we will
kono
parents: 67
diff changeset
2847 still if-convert the original inner loop. */
kono
parents: 67
diff changeset
2848 if (any_pred_load_store
kono
parents: 67
diff changeset
2849 || any_complicated_phi
kono
parents: 67
diff changeset
2850 || flag_tree_loop_if_convert != 1)
kono
parents: 67
diff changeset
2851 {
kono
parents: 67
diff changeset
2852 struct loop *vloop
kono
parents: 67
diff changeset
2853 = (versionable_outer_loop_p (loop_outer (loop))
kono
parents: 67
diff changeset
2854 ? loop_outer (loop) : loop);
kono
parents: 67
diff changeset
2855 struct loop *nloop = version_loop_for_if_conversion (vloop);
kono
parents: 67
diff changeset
2856 if (nloop == NULL)
kono
parents: 67
diff changeset
2857 goto cleanup;
kono
parents: 67
diff changeset
2858 if (vloop != loop)
kono
parents: 67
diff changeset
2859 {
kono
parents: 67
diff changeset
2860 /* If versionable_outer_loop_p decided to version the
kono
parents: 67
diff changeset
2861 outer loop, version also the inner loop of the non-vectorized
kono
parents: 67
diff changeset
2862 loop copy. So we transform:
kono
parents: 67
diff changeset
2863 loop1
kono
parents: 67
diff changeset
2864 loop2
kono
parents: 67
diff changeset
2865 into:
kono
parents: 67
diff changeset
2866 if (LOOP_VECTORIZED (1, 3))
kono
parents: 67
diff changeset
2867 {
kono
parents: 67
diff changeset
2868 loop1
kono
parents: 67
diff changeset
2869 loop2
kono
parents: 67
diff changeset
2870 }
kono
parents: 67
diff changeset
2871 else
kono
parents: 67
diff changeset
2872 loop3 (copy of loop1)
kono
parents: 67
diff changeset
2873 if (LOOP_VECTORIZED (4, 5))
kono
parents: 67
diff changeset
2874 loop4 (copy of loop2)
kono
parents: 67
diff changeset
2875 else
kono
parents: 67
diff changeset
2876 loop5 (copy of loop4) */
kono
parents: 67
diff changeset
2877 gcc_assert (nloop->inner && nloop->inner->next == NULL);
kono
parents: 67
diff changeset
2878 rloop = nloop->inner;
kono
parents: 67
diff changeset
2879 }
kono
parents: 67
diff changeset
2880 }
kono
parents: 67
diff changeset
2881
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
2882 /* Now all statements are if-convertible. Combine all the basic
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
2883 blocks into one huge basic block doing the if-conversion
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
2884 on-the-fly. */
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
2885 combine_blocks (loop);
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
2886
111
kono
parents: 67
diff changeset
2887 /* Delete dead predicate computations. */
kono
parents: 67
diff changeset
2888 ifcvt_local_dce (loop->header);
kono
parents: 67
diff changeset
2889
kono
parents: 67
diff changeset
2890 todo |= TODO_cleanup_cfg;
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
2891
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
2892 cleanup:
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
2893 if (ifc_bbs)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2894 {
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
2895 unsigned int i;
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
2896
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
2897 for (i = 0; i < loop->num_nodes; i++)
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
2898 free_bb_predicate (ifc_bbs[i]);
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
2899
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
2900 free (ifc_bbs);
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
2901 ifc_bbs = NULL;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2902 }
111
kono
parents: 67
diff changeset
2903 if (rloop != NULL)
kono
parents: 67
diff changeset
2904 {
kono
parents: 67
diff changeset
2905 loop = rloop;
kono
parents: 67
diff changeset
2906 goto again;
kono
parents: 67
diff changeset
2907 }
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
2908
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
2909 return todo;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2910 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2911
111
kono
parents: 67
diff changeset
2912 /* Tree if-conversion pass management. */
kono
parents: 67
diff changeset
2913
kono
parents: 67
diff changeset
2914 namespace {
kono
parents: 67
diff changeset
2915
kono
parents: 67
diff changeset
2916 const pass_data pass_data_if_conversion =
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2917 {
111
kono
parents: 67
diff changeset
2918 GIMPLE_PASS, /* type */
kono
parents: 67
diff changeset
2919 "ifcvt", /* name */
kono
parents: 67
diff changeset
2920 OPTGROUP_NONE, /* optinfo_flags */
kono
parents: 67
diff changeset
2921 TV_TREE_LOOP_IFCVT, /* tv_id */
kono
parents: 67
diff changeset
2922 ( PROP_cfg | PROP_ssa ), /* properties_required */
kono
parents: 67
diff changeset
2923 0, /* properties_provided */
kono
parents: 67
diff changeset
2924 0, /* properties_destroyed */
kono
parents: 67
diff changeset
2925 0, /* todo_flags_start */
kono
parents: 67
diff changeset
2926 0, /* todo_flags_finish */
kono
parents: 67
diff changeset
2927 };
kono
parents: 67
diff changeset
2928
kono
parents: 67
diff changeset
2929 class pass_if_conversion : public gimple_opt_pass
kono
parents: 67
diff changeset
2930 {
kono
parents: 67
diff changeset
2931 public:
kono
parents: 67
diff changeset
2932 pass_if_conversion (gcc::context *ctxt)
kono
parents: 67
diff changeset
2933 : gimple_opt_pass (pass_data_if_conversion, ctxt)
kono
parents: 67
diff changeset
2934 {}
kono
parents: 67
diff changeset
2935
kono
parents: 67
diff changeset
2936 /* opt_pass methods: */
kono
parents: 67
diff changeset
2937 virtual bool gate (function *);
kono
parents: 67
diff changeset
2938 virtual unsigned int execute (function *);
kono
parents: 67
diff changeset
2939
kono
parents: 67
diff changeset
2940 }; // class pass_if_conversion
kono
parents: 67
diff changeset
2941
kono
parents: 67
diff changeset
2942 bool
kono
parents: 67
diff changeset
2943 pass_if_conversion::gate (function *fun)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2944 {
111
kono
parents: 67
diff changeset
2945 return (((flag_tree_loop_vectorize || fun->has_force_vectorize_loops)
kono
parents: 67
diff changeset
2946 && flag_tree_loop_if_convert != 0)
kono
parents: 67
diff changeset
2947 || flag_tree_loop_if_convert == 1);
kono
parents: 67
diff changeset
2948 }
kono
parents: 67
diff changeset
2949
kono
parents: 67
diff changeset
2950 unsigned int
kono
parents: 67
diff changeset
2951 pass_if_conversion::execute (function *fun)
kono
parents: 67
diff changeset
2952 {
kono
parents: 67
diff changeset
2953 struct loop *loop;
kono
parents: 67
diff changeset
2954 unsigned todo = 0;
kono
parents: 67
diff changeset
2955
kono
parents: 67
diff changeset
2956 if (number_of_loops (fun) <= 1)
kono
parents: 67
diff changeset
2957 return 0;
kono
parents: 67
diff changeset
2958
kono
parents: 67
diff changeset
2959 FOR_EACH_LOOP (loop, 0)
kono
parents: 67
diff changeset
2960 if (flag_tree_loop_if_convert == 1
kono
parents: 67
diff changeset
2961 || ((flag_tree_loop_vectorize || loop->force_vectorize)
kono
parents: 67
diff changeset
2962 && !loop->dont_vectorize))
kono
parents: 67
diff changeset
2963 todo |= tree_if_conversion (loop);
kono
parents: 67
diff changeset
2964
kono
parents: 67
diff changeset
2965 if (flag_checking)
kono
parents: 67
diff changeset
2966 {
kono
parents: 67
diff changeset
2967 basic_block bb;
kono
parents: 67
diff changeset
2968 FOR_EACH_BB_FN (bb, fun)
kono
parents: 67
diff changeset
2969 gcc_assert (!bb->aux);
kono
parents: 67
diff changeset
2970 }
kono
parents: 67
diff changeset
2971
kono
parents: 67
diff changeset
2972 return todo;
kono
parents: 67
diff changeset
2973 }
kono
parents: 67
diff changeset
2974
kono
parents: 67
diff changeset
2975 } // anon namespace
kono
parents: 67
diff changeset
2976
kono
parents: 67
diff changeset
2977 gimple_opt_pass *
kono
parents: 67
diff changeset
2978 make_pass_if_conversion (gcc::context *ctxt)
kono
parents: 67
diff changeset
2979 {
kono
parents: 67
diff changeset
2980 return new pass_if_conversion (ctxt);
kono
parents: 67
diff changeset
2981 }