Mercurial > hg > truffle
annotate src/share/vm/opto/superword.cpp @ 7788:dbbe8ce3bfa5
commands: accept 'server0' as a vm, accept version number which have '-...' suffix (-internal, -ea...)
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Wed, 13 Feb 2013 18:33:54 +0100 |
parents | 410afdc6a07c |
children | ad736b4683b4 |
rev | line source |
---|---|
0 | 1 /* |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
2 * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1058
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1058
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1058
diff
changeset
|
21 * questions. |
0 | 22 */ |
23 | |
1972 | 24 #include "precompiled.hpp" |
25 #include "compiler/compileLog.hpp" | |
26 #include "libadt/vectset.hpp" | |
27 #include "memory/allocation.inline.hpp" | |
28 #include "opto/addnode.hpp" | |
29 #include "opto/callnode.hpp" | |
30 #include "opto/divnode.hpp" | |
31 #include "opto/matcher.hpp" | |
32 #include "opto/memnode.hpp" | |
33 #include "opto/mulnode.hpp" | |
34 #include "opto/opcodes.hpp" | |
35 #include "opto/superword.hpp" | |
36 #include "opto/vectornode.hpp" | |
0 | 37 |
38 // | |
39 // S U P E R W O R D T R A N S F O R M | |
40 //============================================================================= | |
41 | |
42 //------------------------------SuperWord--------------------------- | |
43 SuperWord::SuperWord(PhaseIdealLoop* phase) : | |
44 _phase(phase), | |
45 _igvn(phase->_igvn), | |
46 _arena(phase->C->comp_arena()), | |
47 _packset(arena(), 8, 0, NULL), // packs for the current block | |
48 _bb_idx(arena(), (int)(1.10 * phase->C->unique()), 0, 0), // node idx to index in bb | |
49 _block(arena(), 8, 0, NULL), // nodes in current block | |
50 _data_entry(arena(), 8, 0, NULL), // nodes with all inputs from outside | |
51 _mem_slice_head(arena(), 8, 0, NULL), // memory slice heads | |
52 _mem_slice_tail(arena(), 8, 0, NULL), // memory slice tails | |
53 _node_info(arena(), 8, 0, SWNodeInfo::initial), // info needed per node | |
54 _align_to_ref(NULL), // memory reference to align vectors to | |
55 _disjoint_ptrs(arena(), 8, 0, OrderedPair::initial), // runtime disambiguated pointer pairs | |
56 _dg(_arena), // dependence graph | |
57 _visited(arena()), // visited node set | |
58 _post_visited(arena()), // post visited node set | |
59 _n_idx_list(arena(), 8), // scratch list of (node,index) pairs | |
60 _stk(arena(), 8, 0, NULL), // scratch stack of nodes | |
61 _nlist(arena(), 8, 0, NULL), // scratch list of nodes | |
62 _lpt(NULL), // loop tree node | |
63 _lp(NULL), // LoopNode | |
64 _bb(NULL), // basic block | |
65 _iv(NULL) // induction var | |
66 {} | |
67 | |
68 //------------------------------transform_loop--------------------------- | |
69 void SuperWord::transform_loop(IdealLoopTree* lpt) { | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
70 assert(UseSuperWord, "should be"); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
71 // Do vectors exist on this architecture? |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
72 if (Matcher::vector_width_in_bytes(T_BYTE) < 2) return; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
73 |
0 | 74 assert(lpt->_head->is_CountedLoop(), "must be"); |
75 CountedLoopNode *cl = lpt->_head->as_CountedLoop(); | |
76 | |
3850
6987871cfb9b
7077439: Possible reference through NULL in loopPredicate.cpp:726
kvn
parents:
3842
diff
changeset
|
77 if (!cl->is_valid_counted_loop()) return; // skip malformed counted loop |
6987871cfb9b
7077439: Possible reference through NULL in loopPredicate.cpp:726
kvn
parents:
3842
diff
changeset
|
78 |
0 | 79 if (!cl->is_main_loop() ) return; // skip normal, pre, and post loops |
80 | |
81 // Check for no control flow in body (other than exit) | |
82 Node *cl_exit = cl->loopexit(); | |
83 if (cl_exit->in(0) != lpt->_head) return; | |
84 | |
105
a7d0f95410bd
6646020: assert(in_bb(n),"must be in block") in -Xcomp mode
never
parents:
72
diff
changeset
|
85 // Make sure the are no extra control users of the loop backedge |
a7d0f95410bd
6646020: assert(in_bb(n),"must be in block") in -Xcomp mode
never
parents:
72
diff
changeset
|
86 if (cl->back_control()->outcnt() != 1) { |
a7d0f95410bd
6646020: assert(in_bb(n),"must be in block") in -Xcomp mode
never
parents:
72
diff
changeset
|
87 return; |
a7d0f95410bd
6646020: assert(in_bb(n),"must be in block") in -Xcomp mode
never
parents:
72
diff
changeset
|
88 } |
a7d0f95410bd
6646020: assert(in_bb(n),"must be in block") in -Xcomp mode
never
parents:
72
diff
changeset
|
89 |
0 | 90 // Check for pre-loop ending with CountedLoopEnd(Bool(Cmp(x,Opaque1(limit)))) |
91 CountedLoopEndNode* pre_end = get_pre_loop_end(cl); | |
92 if (pre_end == NULL) return; | |
93 Node *pre_opaq1 = pre_end->limit(); | |
94 if (pre_opaq1->Opcode() != Op_Opaque1) return; | |
95 | |
96 init(); // initialize data structures | |
97 | |
98 set_lpt(lpt); | |
99 set_lp(cl); | |
100 | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
101 // For now, define one block which is the entire loop body |
0 | 102 set_bb(cl); |
103 | |
104 assert(_packset.length() == 0, "packset must be empty"); | |
105 SLP_extract(); | |
106 } | |
107 | |
108 //------------------------------SLP_extract--------------------------- | |
109 // Extract the superword level parallelism | |
110 // | |
111 // 1) A reverse post-order of nodes in the block is constructed. By scanning | |
112 // this list from first to last, all definitions are visited before their uses. | |
113 // | |
114 // 2) A point-to-point dependence graph is constructed between memory references. | |
115 // This simplies the upcoming "independence" checker. | |
116 // | |
117 // 3) The maximum depth in the node graph from the beginning of the block | |
118 // to each node is computed. This is used to prune the graph search | |
119 // in the independence checker. | |
120 // | |
121 // 4) For integer types, the necessary bit width is propagated backwards | |
122 // from stores to allow packed operations on byte, char, and short | |
123 // integers. This reverses the promotion to type "int" that javac | |
124 // did for operations like: char c1,c2,c3; c1 = c2 + c3. | |
125 // | |
126 // 5) One of the memory references is picked to be an aligned vector reference. | |
127 // The pre-loop trip count is adjusted to align this reference in the | |
128 // unrolled body. | |
129 // | |
130 // 6) The initial set of pack pairs is seeded with memory references. | |
131 // | |
132 // 7) The set of pack pairs is extended by following use->def and def->use links. | |
133 // | |
134 // 8) The pairs are combined into vector sized packs. | |
135 // | |
136 // 9) Reorder the memory slices to co-locate members of the memory packs. | |
137 // | |
138 // 10) Generate ideal vector nodes for the final set of packs and where necessary, | |
139 // inserting scalar promotion, vector creation from multiple scalars, and | |
140 // extraction of scalar values from vectors. | |
141 // | |
142 void SuperWord::SLP_extract() { | |
143 | |
144 // Ready the block | |
145 | |
146 construct_bb(); | |
147 | |
148 dependence_graph(); | |
149 | |
150 compute_max_depth(); | |
151 | |
152 compute_vector_element_type(); | |
153 | |
154 // Attempt vectorization | |
155 | |
156 find_adjacent_refs(); | |
157 | |
158 extend_packlist(); | |
159 | |
160 combine_packs(); | |
161 | |
162 construct_my_pack_map(); | |
163 | |
164 filter_packs(); | |
165 | |
166 schedule(); | |
167 | |
168 output(); | |
169 } | |
170 | |
171 //------------------------------find_adjacent_refs--------------------------- | |
172 // Find the adjacent memory references and create pack pairs for them. | |
173 // This is the initial set of packs that will then be extended by | |
174 // following use->def and def->use links. The align positions are | |
175 // assigned relative to the reference "align_to_ref" | |
176 void SuperWord::find_adjacent_refs() { | |
177 // Get list of memory operations | |
178 Node_List memops; | |
179 for (int i = 0; i < _block.length(); i++) { | |
180 Node* n = _block.at(i); | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
181 if (n->is_Mem() && !n->is_LoadStore() && in_bb(n) && |
29
d5fc211aea19
6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents:
0
diff
changeset
|
182 is_java_primitive(n->as_Mem()->memory_type())) { |
0 | 183 int align = memory_alignment(n->as_Mem(), 0); |
184 if (align != bottom_align) { | |
185 memops.push(n); | |
186 } | |
187 } | |
188 } | |
189 | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
190 Node_List align_to_refs; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
191 int best_iv_adjustment = 0; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
192 MemNode* best_align_to_mem_ref = NULL; |
0 | 193 |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
194 while (memops.size() != 0) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
195 // Find a memory reference to align to. |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
196 MemNode* mem_ref = find_align_to_ref(memops); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
197 if (mem_ref == NULL) break; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
198 align_to_refs.push(mem_ref); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
199 int iv_adjustment = get_iv_adjustment(mem_ref); |
0 | 200 |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
201 if (best_align_to_mem_ref == NULL) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
202 // Set memory reference which is the best from all memory operations |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
203 // to be used for alignment. The pre-loop trip count is modified to align |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
204 // this reference to a vector-aligned address. |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
205 best_align_to_mem_ref = mem_ref; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
206 best_iv_adjustment = iv_adjustment; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
207 } |
0 | 208 |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
209 SWPointer align_to_ref_p(mem_ref, this); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
210 // Set alignment relative to "align_to_ref" for all related memory operations. |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
211 for (int i = memops.size() - 1; i >= 0; i--) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
212 MemNode* s = memops.at(i)->as_Mem(); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
213 if (isomorphic(s, mem_ref)) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
214 SWPointer p2(s, this); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
215 if (p2.comparable(align_to_ref_p)) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
216 int align = memory_alignment(s, iv_adjustment); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
217 set_alignment(s, align); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
218 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
219 } |
0 | 220 } |
221 | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
222 // Create initial pack pairs of memory operations for which |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
223 // alignment is set and vectors will be aligned. |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
224 bool create_pack = true; |
6183
6f8f439e247d
7177923: SIGBUS on sparc in compiled code for java.util.Calendar.clear()
kvn
parents:
6179
diff
changeset
|
225 if (memory_alignment(mem_ref, best_iv_adjustment) == 0) { |
6f8f439e247d
7177923: SIGBUS on sparc in compiled code for java.util.Calendar.clear()
kvn
parents:
6179
diff
changeset
|
226 if (!Matcher::misaligned_vectors_ok()) { |
6f8f439e247d
7177923: SIGBUS on sparc in compiled code for java.util.Calendar.clear()
kvn
parents:
6179
diff
changeset
|
227 int vw = vector_width(mem_ref); |
6f8f439e247d
7177923: SIGBUS on sparc in compiled code for java.util.Calendar.clear()
kvn
parents:
6179
diff
changeset
|
228 int vw_best = vector_width(best_align_to_mem_ref); |
6f8f439e247d
7177923: SIGBUS on sparc in compiled code for java.util.Calendar.clear()
kvn
parents:
6179
diff
changeset
|
229 if (vw > vw_best) { |
6f8f439e247d
7177923: SIGBUS on sparc in compiled code for java.util.Calendar.clear()
kvn
parents:
6179
diff
changeset
|
230 // Do not vectorize a memory access with more elements per vector |
6f8f439e247d
7177923: SIGBUS on sparc in compiled code for java.util.Calendar.clear()
kvn
parents:
6179
diff
changeset
|
231 // if unaligned memory access is not allowed because number of |
6f8f439e247d
7177923: SIGBUS on sparc in compiled code for java.util.Calendar.clear()
kvn
parents:
6179
diff
changeset
|
232 // iterations in pre-loop will be not enough to align it. |
6f8f439e247d
7177923: SIGBUS on sparc in compiled code for java.util.Calendar.clear()
kvn
parents:
6179
diff
changeset
|
233 create_pack = false; |
6f8f439e247d
7177923: SIGBUS on sparc in compiled code for java.util.Calendar.clear()
kvn
parents:
6179
diff
changeset
|
234 } |
6f8f439e247d
7177923: SIGBUS on sparc in compiled code for java.util.Calendar.clear()
kvn
parents:
6179
diff
changeset
|
235 } |
6f8f439e247d
7177923: SIGBUS on sparc in compiled code for java.util.Calendar.clear()
kvn
parents:
6179
diff
changeset
|
236 } else { |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
237 if (same_velt_type(mem_ref, best_align_to_mem_ref)) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
238 // Can't allow vectorization of unaligned memory accesses with the |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
239 // same type since it could be overlapped accesses to the same array. |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
240 create_pack = false; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
241 } else { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
242 // Allow independent (different type) unaligned memory operations |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
243 // if HW supports them. |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
244 if (!Matcher::misaligned_vectors_ok()) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
245 create_pack = false; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
246 } else { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
247 // Check if packs of the same memory type but |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
248 // with a different alignment were created before. |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
249 for (uint i = 0; i < align_to_refs.size(); i++) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
250 MemNode* mr = align_to_refs.at(i)->as_Mem(); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
251 if (same_velt_type(mr, mem_ref) && |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
252 memory_alignment(mr, iv_adjustment) != 0) |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
253 create_pack = false; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
254 } |
0 | 255 } |
256 } | |
257 } | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
258 if (create_pack) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
259 for (uint i = 0; i < memops.size(); i++) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
260 Node* s1 = memops.at(i); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
261 int align = alignment(s1); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
262 if (align == top_align) continue; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
263 for (uint j = 0; j < memops.size(); j++) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
264 Node* s2 = memops.at(j); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
265 if (alignment(s2) == top_align) continue; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
266 if (s1 != s2 && are_adjacent_refs(s1, s2)) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
267 if (stmts_can_pack(s1, s2, align)) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
268 Node_List* pair = new Node_List(); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
269 pair->push(s1); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
270 pair->push(s2); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
271 _packset.append(pair); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
272 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
273 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
274 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
275 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
276 } else { // Don't create unaligned pack |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
277 // First, remove remaining memory ops of the same type from the list. |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
278 for (int i = memops.size() - 1; i >= 0; i--) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
279 MemNode* s = memops.at(i)->as_Mem(); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
280 if (same_velt_type(s, mem_ref)) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
281 memops.remove(i); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
282 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
283 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
284 |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
285 // Second, remove already constructed packs of the same type. |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
286 for (int i = _packset.length() - 1; i >= 0; i--) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
287 Node_List* p = _packset.at(i); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
288 MemNode* s = p->at(0)->as_Mem(); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
289 if (same_velt_type(s, mem_ref)) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
290 remove_pack_at(i); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
291 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
292 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
293 |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
294 // If needed find the best memory reference for loop alignment again. |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
295 if (same_velt_type(mem_ref, best_align_to_mem_ref)) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
296 // Put memory ops from remaining packs back on memops list for |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
297 // the best alignment search. |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
298 uint orig_msize = memops.size(); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
299 for (int i = 0; i < _packset.length(); i++) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
300 Node_List* p = _packset.at(i); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
301 MemNode* s = p->at(0)->as_Mem(); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
302 assert(!same_velt_type(s, mem_ref), "sanity"); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
303 memops.push(s); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
304 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
305 MemNode* best_align_to_mem_ref = find_align_to_ref(memops); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
306 if (best_align_to_mem_ref == NULL) break; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
307 best_iv_adjustment = get_iv_adjustment(best_align_to_mem_ref); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
308 // Restore list. |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
309 while (memops.size() > orig_msize) |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
310 (void)memops.pop(); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
311 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
312 } // unaligned memory accesses |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
313 |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
314 // Remove used mem nodes. |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
315 for (int i = memops.size() - 1; i >= 0; i--) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
316 MemNode* m = memops.at(i)->as_Mem(); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
317 if (alignment(m) != top_align) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
318 memops.remove(i); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
319 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
320 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
321 |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
322 } // while (memops.size() != 0 |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
323 set_align_to_ref(best_align_to_mem_ref); |
0 | 324 |
325 #ifndef PRODUCT | |
326 if (TraceSuperWord) { | |
327 tty->print_cr("\nAfter find_adjacent_refs"); | |
328 print_packset(); | |
329 } | |
330 #endif | |
331 } | |
332 | |
333 //------------------------------find_align_to_ref--------------------------- | |
334 // Find a memory reference to align the loop induction variable to. | |
335 // Looks first at stores then at loads, looking for a memory reference | |
336 // with the largest number of references similar to it. | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
337 MemNode* SuperWord::find_align_to_ref(Node_List &memops) { |
0 | 338 GrowableArray<int> cmp_ct(arena(), memops.size(), memops.size(), 0); |
339 | |
340 // Count number of comparable memory ops | |
341 for (uint i = 0; i < memops.size(); i++) { | |
342 MemNode* s1 = memops.at(i)->as_Mem(); | |
343 SWPointer p1(s1, this); | |
344 // Discard if pre loop can't align this reference | |
345 if (!ref_is_alignable(p1)) { | |
346 *cmp_ct.adr_at(i) = 0; | |
347 continue; | |
348 } | |
349 for (uint j = i+1; j < memops.size(); j++) { | |
350 MemNode* s2 = memops.at(j)->as_Mem(); | |
351 if (isomorphic(s1, s2)) { | |
352 SWPointer p2(s2, this); | |
353 if (p1.comparable(p2)) { | |
354 (*cmp_ct.adr_at(i))++; | |
355 (*cmp_ct.adr_at(j))++; | |
356 } | |
357 } | |
358 } | |
359 } | |
360 | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
361 // Find Store (or Load) with the greatest number of "comparable" references, |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
362 // biggest vector size, smallest data size and smallest iv offset. |
0 | 363 int max_ct = 0; |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
364 int max_vw = 0; |
0 | 365 int max_idx = -1; |
366 int min_size = max_jint; | |
367 int min_iv_offset = max_jint; | |
368 for (uint j = 0; j < memops.size(); j++) { | |
369 MemNode* s = memops.at(j)->as_Mem(); | |
370 if (s->is_Store()) { | |
6183
6f8f439e247d
7177923: SIGBUS on sparc in compiled code for java.util.Calendar.clear()
kvn
parents:
6179
diff
changeset
|
371 int vw = vector_width_in_bytes(s); |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
372 assert(vw > 1, "sanity"); |
0 | 373 SWPointer p(s, this); |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
374 if (cmp_ct.at(j) > max_ct || |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
375 cmp_ct.at(j) == max_ct && |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
376 (vw > max_vw || |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
377 vw == max_vw && |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
378 (data_size(s) < min_size || |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
379 data_size(s) == min_size && |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
380 (p.offset_in_bytes() < min_iv_offset)))) { |
0 | 381 max_ct = cmp_ct.at(j); |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
382 max_vw = vw; |
0 | 383 max_idx = j; |
384 min_size = data_size(s); | |
385 min_iv_offset = p.offset_in_bytes(); | |
386 } | |
387 } | |
388 } | |
389 // If no stores, look at loads | |
390 if (max_ct == 0) { | |
391 for (uint j = 0; j < memops.size(); j++) { | |
392 MemNode* s = memops.at(j)->as_Mem(); | |
393 if (s->is_Load()) { | |
6183
6f8f439e247d
7177923: SIGBUS on sparc in compiled code for java.util.Calendar.clear()
kvn
parents:
6179
diff
changeset
|
394 int vw = vector_width_in_bytes(s); |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
395 assert(vw > 1, "sanity"); |
0 | 396 SWPointer p(s, this); |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
397 if (cmp_ct.at(j) > max_ct || |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
398 cmp_ct.at(j) == max_ct && |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
399 (vw > max_vw || |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
400 vw == max_vw && |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
401 (data_size(s) < min_size || |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
402 data_size(s) == min_size && |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
403 (p.offset_in_bytes() < min_iv_offset)))) { |
0 | 404 max_ct = cmp_ct.at(j); |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
405 max_vw = vw; |
0 | 406 max_idx = j; |
407 min_size = data_size(s); | |
408 min_iv_offset = p.offset_in_bytes(); | |
409 } | |
410 } | |
411 } | |
412 } | |
413 | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
414 #ifdef ASSERT |
0 | 415 if (TraceSuperWord && Verbose) { |
416 tty->print_cr("\nVector memops after find_align_to_refs"); | |
417 for (uint i = 0; i < memops.size(); i++) { | |
418 MemNode* s = memops.at(i)->as_Mem(); | |
419 s->dump(); | |
420 } | |
421 } | |
422 #endif | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
423 |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
424 if (max_ct > 0) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
425 #ifdef ASSERT |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
426 if (TraceSuperWord) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
427 tty->print("\nVector align to node: "); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
428 memops.at(max_idx)->as_Mem()->dump(); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
429 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
430 #endif |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
431 return memops.at(max_idx)->as_Mem(); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
432 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
433 return NULL; |
0 | 434 } |
435 | |
436 //------------------------------ref_is_alignable--------------------------- | |
437 // Can the preloop align the reference to position zero in the vector? | |
438 bool SuperWord::ref_is_alignable(SWPointer& p) { | |
439 if (!p.has_iv()) { | |
440 return true; // no induction variable | |
441 } | |
442 CountedLoopEndNode* pre_end = get_pre_loop_end(lp()->as_CountedLoop()); | |
443 assert(pre_end->stride_is_con(), "pre loop stride is constant"); | |
444 int preloop_stride = pre_end->stride_con(); | |
445 | |
446 int span = preloop_stride * p.scale_in_bytes(); | |
447 | |
448 // Stride one accesses are alignable. | |
449 if (ABS(span) == p.memory_size()) | |
450 return true; | |
451 | |
452 // If initial offset from start of object is computable, | |
453 // compute alignment within the vector. | |
6183
6f8f439e247d
7177923: SIGBUS on sparc in compiled code for java.util.Calendar.clear()
kvn
parents:
6179
diff
changeset
|
454 int vw = vector_width_in_bytes(p.mem()); |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
455 assert(vw > 1, "sanity"); |
0 | 456 if (vw % span == 0) { |
457 Node* init_nd = pre_end->init_trip(); | |
458 if (init_nd->is_Con() && p.invar() == NULL) { | |
459 int init = init_nd->bottom_type()->is_int()->get_con(); | |
460 | |
461 int init_offset = init * p.scale_in_bytes() + p.offset_in_bytes(); | |
462 assert(init_offset >= 0, "positive offset from object start"); | |
463 | |
464 if (span > 0) { | |
465 return (vw - (init_offset % vw)) % span == 0; | |
466 } else { | |
467 assert(span < 0, "nonzero stride * scale"); | |
468 return (init_offset % vw) % -span == 0; | |
469 } | |
470 } | |
471 } | |
472 return false; | |
473 } | |
474 | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
475 //---------------------------get_iv_adjustment--------------------------- |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
476 // Calculate loop's iv adjustment for this memory ops. |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
477 int SuperWord::get_iv_adjustment(MemNode* mem_ref) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
478 SWPointer align_to_ref_p(mem_ref, this); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
479 int offset = align_to_ref_p.offset_in_bytes(); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
480 int scale = align_to_ref_p.scale_in_bytes(); |
6183
6f8f439e247d
7177923: SIGBUS on sparc in compiled code for java.util.Calendar.clear()
kvn
parents:
6179
diff
changeset
|
481 int vw = vector_width_in_bytes(mem_ref); |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
482 assert(vw > 1, "sanity"); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
483 int stride_sign = (scale * iv_stride()) > 0 ? 1 : -1; |
6794 | 484 // At least one iteration is executed in pre-loop by default. As result |
485 // several iterations are needed to align memory operations in main-loop even | |
486 // if offset is 0. | |
487 int iv_adjustment_in_bytes = (stride_sign * vw - (offset % vw)); | |
488 int elt_size = align_to_ref_p.memory_size(); | |
489 assert(((ABS(iv_adjustment_in_bytes) % elt_size) == 0), | |
490 err_msg_res("(%d) should be divisible by (%d)", iv_adjustment_in_bytes, elt_size)); | |
491 int iv_adjustment = iv_adjustment_in_bytes/elt_size; | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
492 |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
493 #ifndef PRODUCT |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
494 if (TraceSuperWord) |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
495 tty->print_cr("\noffset = %d iv_adjust = %d elt_size = %d scale = %d iv_stride = %d vect_size %d", |
6794 | 496 offset, iv_adjustment, elt_size, scale, iv_stride(), vw); |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
497 #endif |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
498 return iv_adjustment; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
499 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
500 |
0 | 501 //---------------------------dependence_graph--------------------------- |
502 // Construct dependency graph. | |
503 // Add dependence edges to load/store nodes for memory dependence | |
504 // A.out()->DependNode.in(1) and DependNode.out()->B.prec(x) | |
505 void SuperWord::dependence_graph() { | |
506 // First, assign a dependence node to each memory node | |
507 for (int i = 0; i < _block.length(); i++ ) { | |
508 Node *n = _block.at(i); | |
509 if (n->is_Mem() || n->is_Phi() && n->bottom_type() == Type::MEMORY) { | |
510 _dg.make_node(n); | |
511 } | |
512 } | |
513 | |
514 // For each memory slice, create the dependences | |
515 for (int i = 0; i < _mem_slice_head.length(); i++) { | |
516 Node* n = _mem_slice_head.at(i); | |
517 Node* n_tail = _mem_slice_tail.at(i); | |
518 | |
519 // Get slice in predecessor order (last is first) | |
520 mem_slice_preds(n_tail, n, _nlist); | |
521 | |
522 // Make the slice dependent on the root | |
523 DepMem* slice = _dg.dep(n); | |
524 _dg.make_edge(_dg.root(), slice); | |
525 | |
526 // Create a sink for the slice | |
527 DepMem* slice_sink = _dg.make_node(NULL); | |
528 _dg.make_edge(slice_sink, _dg.tail()); | |
529 | |
530 // Now visit each pair of memory ops, creating the edges | |
531 for (int j = _nlist.length() - 1; j >= 0 ; j--) { | |
532 Node* s1 = _nlist.at(j); | |
533 | |
534 // If no dependency yet, use slice | |
535 if (_dg.dep(s1)->in_cnt() == 0) { | |
536 _dg.make_edge(slice, s1); | |
537 } | |
538 SWPointer p1(s1->as_Mem(), this); | |
539 bool sink_dependent = true; | |
540 for (int k = j - 1; k >= 0; k--) { | |
541 Node* s2 = _nlist.at(k); | |
542 if (s1->is_Load() && s2->is_Load()) | |
543 continue; | |
544 SWPointer p2(s2->as_Mem(), this); | |
545 | |
546 int cmp = p1.cmp(p2); | |
547 if (SuperWordRTDepCheck && | |
548 p1.base() != p2.base() && p1.valid() && p2.valid()) { | |
549 // Create a runtime check to disambiguate | |
550 OrderedPair pp(p1.base(), p2.base()); | |
551 _disjoint_ptrs.append_if_missing(pp); | |
552 } else if (!SWPointer::not_equal(cmp)) { | |
553 // Possibly same address | |
554 _dg.make_edge(s1, s2); | |
555 sink_dependent = false; | |
556 } | |
557 } | |
558 if (sink_dependent) { | |
559 _dg.make_edge(s1, slice_sink); | |
560 } | |
561 } | |
562 #ifndef PRODUCT | |
563 if (TraceSuperWord) { | |
564 tty->print_cr("\nDependence graph for slice: %d", n->_idx); | |
565 for (int q = 0; q < _nlist.length(); q++) { | |
566 _dg.print(_nlist.at(q)); | |
567 } | |
568 tty->cr(); | |
569 } | |
570 #endif | |
571 _nlist.clear(); | |
572 } | |
573 | |
574 #ifndef PRODUCT | |
575 if (TraceSuperWord) { | |
576 tty->print_cr("\ndisjoint_ptrs: %s", _disjoint_ptrs.length() > 0 ? "" : "NONE"); | |
577 for (int r = 0; r < _disjoint_ptrs.length(); r++) { | |
578 _disjoint_ptrs.at(r).print(); | |
579 tty->cr(); | |
580 } | |
581 tty->cr(); | |
582 } | |
583 #endif | |
584 } | |
585 | |
586 //---------------------------mem_slice_preds--------------------------- | |
587 // Return a memory slice (node list) in predecessor order starting at "start" | |
588 void SuperWord::mem_slice_preds(Node* start, Node* stop, GrowableArray<Node*> &preds) { | |
589 assert(preds.length() == 0, "start empty"); | |
590 Node* n = start; | |
591 Node* prev = NULL; | |
592 while (true) { | |
593 assert(in_bb(n), "must be in block"); | |
594 for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) { | |
595 Node* out = n->fast_out(i); | |
596 if (out->is_Load()) { | |
597 if (in_bb(out)) { | |
598 preds.push(out); | |
599 } | |
600 } else { | |
601 // FIXME | |
602 if (out->is_MergeMem() && !in_bb(out)) { | |
603 // Either unrolling is causing a memory edge not to disappear, | |
604 // or need to run igvn.optimize() again before SLP | |
605 } else if (out->is_Phi() && out->bottom_type() == Type::MEMORY && !in_bb(out)) { | |
606 // Ditto. Not sure what else to check further. | |
667 | 607 } else if (out->Opcode() == Op_StoreCM && out->in(MemNode::OopStore) == n) { |
0 | 608 // StoreCM has an input edge used as a precedence edge. |
609 // Maybe an issue when oop stores are vectorized. | |
610 } else { | |
611 assert(out == prev || prev == NULL, "no branches off of store slice"); | |
612 } | |
613 } | |
614 } | |
615 if (n == stop) break; | |
616 preds.push(n); | |
617 prev = n; | |
618 n = n->in(MemNode::Memory); | |
619 } | |
620 } | |
621 | |
622 //------------------------------stmts_can_pack--------------------------- | |
605 | 623 // Can s1 and s2 be in a pack with s1 immediately preceding s2 and |
0 | 624 // s1 aligned at "align" |
625 bool SuperWord::stmts_can_pack(Node* s1, Node* s2, int align) { | |
987
00977607da34
6879921: CTW failure jdk6_18/hotspot/src/share/vm/utilities/globalDefinitions.cpp:268
cfang
parents:
985
diff
changeset
|
626 |
00977607da34
6879921: CTW failure jdk6_18/hotspot/src/share/vm/utilities/globalDefinitions.cpp:268
cfang
parents:
985
diff
changeset
|
627 // Do not use superword for non-primitives |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
628 BasicType bt1 = velt_basic_type(s1); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
629 BasicType bt2 = velt_basic_type(s2); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
630 if(!is_java_primitive(bt1) || !is_java_primitive(bt2)) |
987
00977607da34
6879921: CTW failure jdk6_18/hotspot/src/share/vm/utilities/globalDefinitions.cpp:268
cfang
parents:
985
diff
changeset
|
631 return false; |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
632 if (Matcher::max_vector_size(bt1) < 2) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
633 return false; // No vectors for this type |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
634 } |
987
00977607da34
6879921: CTW failure jdk6_18/hotspot/src/share/vm/utilities/globalDefinitions.cpp:268
cfang
parents:
985
diff
changeset
|
635 |
0 | 636 if (isomorphic(s1, s2)) { |
637 if (independent(s1, s2)) { | |
638 if (!exists_at(s1, 0) && !exists_at(s2, 1)) { | |
639 if (!s1->is_Mem() || are_adjacent_refs(s1, s2)) { | |
640 int s1_align = alignment(s1); | |
641 int s2_align = alignment(s2); | |
642 if (s1_align == top_align || s1_align == align) { | |
643 if (s2_align == top_align || s2_align == align + data_size(s1)) { | |
644 return true; | |
645 } | |
646 } | |
647 } | |
648 } | |
649 } | |
650 } | |
651 return false; | |
652 } | |
653 | |
654 //------------------------------exists_at--------------------------- | |
655 // Does s exist in a pack at position pos? | |
656 bool SuperWord::exists_at(Node* s, uint pos) { | |
657 for (int i = 0; i < _packset.length(); i++) { | |
658 Node_List* p = _packset.at(i); | |
659 if (p->at(pos) == s) { | |
660 return true; | |
661 } | |
662 } | |
663 return false; | |
664 } | |
665 | |
666 //------------------------------are_adjacent_refs--------------------------- | |
667 // Is s1 immediately before s2 in memory? | |
668 bool SuperWord::are_adjacent_refs(Node* s1, Node* s2) { | |
669 if (!s1->is_Mem() || !s2->is_Mem()) return false; | |
670 if (!in_bb(s1) || !in_bb(s2)) return false; | |
1585 | 671 |
672 // Do not use superword for non-primitives | |
673 if (!is_java_primitive(s1->as_Mem()->memory_type()) || | |
674 !is_java_primitive(s2->as_Mem()->memory_type())) { | |
675 return false; | |
676 } | |
677 | |
0 | 678 // FIXME - co_locate_pack fails on Stores in different mem-slices, so |
679 // only pack memops that are in the same alias set until that's fixed. | |
680 if (_phase->C->get_alias_index(s1->as_Mem()->adr_type()) != | |
681 _phase->C->get_alias_index(s2->as_Mem()->adr_type())) | |
682 return false; | |
683 SWPointer p1(s1->as_Mem(), this); | |
684 SWPointer p2(s2->as_Mem(), this); | |
685 if (p1.base() != p2.base() || !p1.comparable(p2)) return false; | |
686 int diff = p2.offset_in_bytes() - p1.offset_in_bytes(); | |
687 return diff == data_size(s1); | |
688 } | |
689 | |
690 //------------------------------isomorphic--------------------------- | |
691 // Are s1 and s2 similar? | |
692 bool SuperWord::isomorphic(Node* s1, Node* s2) { | |
693 if (s1->Opcode() != s2->Opcode()) return false; | |
694 if (s1->req() != s2->req()) return false; | |
695 if (s1->in(0) != s2->in(0)) return false; | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
696 if (!same_velt_type(s1, s2)) return false; |
0 | 697 return true; |
698 } | |
699 | |
700 //------------------------------independent--------------------------- | |
701 // Is there no data path from s1 to s2 or s2 to s1? | |
702 bool SuperWord::independent(Node* s1, Node* s2) { | |
703 // assert(s1->Opcode() == s2->Opcode(), "check isomorphic first"); | |
704 int d1 = depth(s1); | |
705 int d2 = depth(s2); | |
706 if (d1 == d2) return s1 != s2; | |
707 Node* deep = d1 > d2 ? s1 : s2; | |
708 Node* shallow = d1 > d2 ? s2 : s1; | |
709 | |
710 visited_clear(); | |
711 | |
712 return independent_path(shallow, deep); | |
713 } | |
714 | |
715 //------------------------------independent_path------------------------------ | |
716 // Helper for independent | |
717 bool SuperWord::independent_path(Node* shallow, Node* deep, uint dp) { | |
718 if (dp >= 1000) return false; // stop deep recursion | |
719 visited_set(deep); | |
720 int shal_depth = depth(shallow); | |
721 assert(shal_depth <= depth(deep), "must be"); | |
722 for (DepPreds preds(deep, _dg); !preds.done(); preds.next()) { | |
723 Node* pred = preds.current(); | |
724 if (in_bb(pred) && !visited_test(pred)) { | |
725 if (shallow == pred) { | |
726 return false; | |
727 } | |
728 if (shal_depth < depth(pred) && !independent_path(shallow, pred, dp+1)) { | |
729 return false; | |
730 } | |
731 } | |
732 } | |
733 return true; | |
734 } | |
735 | |
736 //------------------------------set_alignment--------------------------- | |
737 void SuperWord::set_alignment(Node* s1, Node* s2, int align) { | |
738 set_alignment(s1, align); | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
739 if (align == top_align || align == bottom_align) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
740 set_alignment(s2, align); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
741 } else { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
742 set_alignment(s2, align + data_size(s1)); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
743 } |
0 | 744 } |
745 | |
746 //------------------------------data_size--------------------------- | |
747 int SuperWord::data_size(Node* s) { | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
748 int bsize = type2aelembytes(velt_basic_type(s)); |
0 | 749 assert(bsize != 0, "valid size"); |
750 return bsize; | |
751 } | |
752 | |
753 //------------------------------extend_packlist--------------------------- | |
754 // Extend packset by following use->def and def->use links from pack members. | |
755 void SuperWord::extend_packlist() { | |
756 bool changed; | |
757 do { | |
758 changed = false; | |
759 for (int i = 0; i < _packset.length(); i++) { | |
760 Node_List* p = _packset.at(i); | |
761 changed |= follow_use_defs(p); | |
762 changed |= follow_def_uses(p); | |
763 } | |
764 } while (changed); | |
765 | |
766 #ifndef PRODUCT | |
767 if (TraceSuperWord) { | |
768 tty->print_cr("\nAfter extend_packlist"); | |
769 print_packset(); | |
770 } | |
771 #endif | |
772 } | |
773 | |
774 //------------------------------follow_use_defs--------------------------- | |
775 // Extend the packset by visiting operand definitions of nodes in pack p | |
776 bool SuperWord::follow_use_defs(Node_List* p) { | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
777 assert(p->size() == 2, "just checking"); |
0 | 778 Node* s1 = p->at(0); |
779 Node* s2 = p->at(1); | |
780 assert(s1->req() == s2->req(), "just checking"); | |
781 assert(alignment(s1) + data_size(s1) == alignment(s2), "just checking"); | |
782 | |
783 if (s1->is_Load()) return false; | |
784 | |
785 int align = alignment(s1); | |
786 bool changed = false; | |
787 int start = s1->is_Store() ? MemNode::ValueIn : 1; | |
788 int end = s1->is_Store() ? MemNode::ValueIn+1 : s1->req(); | |
789 for (int j = start; j < end; j++) { | |
790 Node* t1 = s1->in(j); | |
791 Node* t2 = s2->in(j); | |
792 if (!in_bb(t1) || !in_bb(t2)) | |
793 continue; | |
794 if (stmts_can_pack(t1, t2, align)) { | |
795 if (est_savings(t1, t2) >= 0) { | |
796 Node_List* pair = new Node_List(); | |
797 pair->push(t1); | |
798 pair->push(t2); | |
799 _packset.append(pair); | |
800 set_alignment(t1, t2, align); | |
801 changed = true; | |
802 } | |
803 } | |
804 } | |
805 return changed; | |
806 } | |
807 | |
808 //------------------------------follow_def_uses--------------------------- | |
809 // Extend the packset by visiting uses of nodes in pack p | |
810 bool SuperWord::follow_def_uses(Node_List* p) { | |
811 bool changed = false; | |
812 Node* s1 = p->at(0); | |
813 Node* s2 = p->at(1); | |
814 assert(p->size() == 2, "just checking"); | |
815 assert(s1->req() == s2->req(), "just checking"); | |
816 assert(alignment(s1) + data_size(s1) == alignment(s2), "just checking"); | |
817 | |
818 if (s1->is_Store()) return false; | |
819 | |
820 int align = alignment(s1); | |
821 int savings = -1; | |
822 Node* u1 = NULL; | |
823 Node* u2 = NULL; | |
824 for (DUIterator_Fast imax, i = s1->fast_outs(imax); i < imax; i++) { | |
825 Node* t1 = s1->fast_out(i); | |
826 if (!in_bb(t1)) continue; | |
827 for (DUIterator_Fast jmax, j = s2->fast_outs(jmax); j < jmax; j++) { | |
828 Node* t2 = s2->fast_out(j); | |
829 if (!in_bb(t2)) continue; | |
830 if (!opnd_positions_match(s1, t1, s2, t2)) | |
831 continue; | |
832 if (stmts_can_pack(t1, t2, align)) { | |
833 int my_savings = est_savings(t1, t2); | |
834 if (my_savings > savings) { | |
835 savings = my_savings; | |
836 u1 = t1; | |
837 u2 = t2; | |
838 } | |
839 } | |
840 } | |
841 } | |
842 if (savings >= 0) { | |
843 Node_List* pair = new Node_List(); | |
844 pair->push(u1); | |
845 pair->push(u2); | |
846 _packset.append(pair); | |
847 set_alignment(u1, u2, align); | |
848 changed = true; | |
849 } | |
850 return changed; | |
851 } | |
852 | |
853 //---------------------------opnd_positions_match------------------------- | |
854 // Is the use of d1 in u1 at the same operand position as d2 in u2? | |
855 bool SuperWord::opnd_positions_match(Node* d1, Node* u1, Node* d2, Node* u2) { | |
856 uint ct = u1->req(); | |
857 if (ct != u2->req()) return false; | |
858 uint i1 = 0; | |
859 uint i2 = 0; | |
860 do { | |
861 for (i1++; i1 < ct; i1++) if (u1->in(i1) == d1) break; | |
862 for (i2++; i2 < ct; i2++) if (u2->in(i2) == d2) break; | |
863 if (i1 != i2) { | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
864 if ((i1 == (3-i2)) && (u2->is_Add() || u2->is_Mul())) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
865 // Further analysis relies on operands position matching. |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
866 u2->swap_edges(i1, i2); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
867 } else { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
868 return false; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
869 } |
0 | 870 } |
871 } while (i1 < ct); | |
872 return true; | |
873 } | |
874 | |
875 //------------------------------est_savings--------------------------- | |
876 // Estimate the savings from executing s1 and s2 as a pack | |
877 int SuperWord::est_savings(Node* s1, Node* s2) { | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
878 int save_in = 2 - 1; // 2 operations per instruction in packed form |
0 | 879 |
880 // inputs | |
881 for (uint i = 1; i < s1->req(); i++) { | |
882 Node* x1 = s1->in(i); | |
883 Node* x2 = s2->in(i); | |
884 if (x1 != x2) { | |
885 if (are_adjacent_refs(x1, x2)) { | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
886 save_in += adjacent_profit(x1, x2); |
0 | 887 } else if (!in_packset(x1, x2)) { |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
888 save_in -= pack_cost(2); |
0 | 889 } else { |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
890 save_in += unpack_cost(2); |
0 | 891 } |
892 } | |
893 } | |
894 | |
895 // uses of result | |
896 uint ct = 0; | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
897 int save_use = 0; |
0 | 898 for (DUIterator_Fast imax, i = s1->fast_outs(imax); i < imax; i++) { |
899 Node* s1_use = s1->fast_out(i); | |
900 for (int j = 0; j < _packset.length(); j++) { | |
901 Node_List* p = _packset.at(j); | |
902 if (p->at(0) == s1_use) { | |
903 for (DUIterator_Fast kmax, k = s2->fast_outs(kmax); k < kmax; k++) { | |
904 Node* s2_use = s2->fast_out(k); | |
905 if (p->at(p->size()-1) == s2_use) { | |
906 ct++; | |
907 if (are_adjacent_refs(s1_use, s2_use)) { | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
908 save_use += adjacent_profit(s1_use, s2_use); |
0 | 909 } |
910 } | |
911 } | |
912 } | |
913 } | |
914 } | |
915 | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
916 if (ct < s1->outcnt()) save_use += unpack_cost(1); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
917 if (ct < s2->outcnt()) save_use += unpack_cost(1); |
0 | 918 |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
919 return MAX2(save_in, save_use); |
0 | 920 } |
921 | |
922 //------------------------------costs--------------------------- | |
923 int SuperWord::adjacent_profit(Node* s1, Node* s2) { return 2; } | |
924 int SuperWord::pack_cost(int ct) { return ct; } | |
925 int SuperWord::unpack_cost(int ct) { return ct; } | |
926 | |
927 //------------------------------combine_packs--------------------------- | |
928 // Combine packs A and B with A.last == B.first into A.first..,A.last,B.second,..B.last | |
929 void SuperWord::combine_packs() { | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
930 bool changed = true; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
931 // Combine packs regardless max vector size. |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
932 while (changed) { |
0 | 933 changed = false; |
934 for (int i = 0; i < _packset.length(); i++) { | |
935 Node_List* p1 = _packset.at(i); | |
936 if (p1 == NULL) continue; | |
937 for (int j = 0; j < _packset.length(); j++) { | |
938 Node_List* p2 = _packset.at(j); | |
939 if (p2 == NULL) continue; | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
940 if (i == j) continue; |
0 | 941 if (p1->at(p1->size()-1) == p2->at(0)) { |
942 for (uint k = 1; k < p2->size(); k++) { | |
943 p1->push(p2->at(k)); | |
944 } | |
945 _packset.at_put(j, NULL); | |
946 changed = true; | |
947 } | |
948 } | |
949 } | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
950 } |
0 | 951 |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
952 // Split packs which have size greater then max vector size. |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
953 for (int i = 0; i < _packset.length(); i++) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
954 Node_List* p1 = _packset.at(i); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
955 if (p1 != NULL) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
956 BasicType bt = velt_basic_type(p1->at(0)); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
957 uint max_vlen = Matcher::max_vector_size(bt); // Max elements in vector |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
958 assert(is_power_of_2(max_vlen), "sanity"); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
959 uint psize = p1->size(); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
960 if (!is_power_of_2(psize)) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
961 // Skip pack which can't be vector. |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
962 // case1: for(...) { a[i] = i; } elements values are different (i+x) |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
963 // case2: for(...) { a[i] = b[i+1]; } can't align both, load and store |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
964 _packset.at_put(i, NULL); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
965 continue; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
966 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
967 if (psize > max_vlen) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
968 Node_List* pack = new Node_List(); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
969 for (uint j = 0; j < psize; j++) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
970 pack->push(p1->at(j)); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
971 if (pack->size() >= max_vlen) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
972 assert(is_power_of_2(pack->size()), "sanity"); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
973 _packset.append(pack); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
974 pack = new Node_List(); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
975 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
976 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
977 _packset.at_put(i, NULL); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
978 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
979 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
980 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
981 |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
982 // Compress list. |
0 | 983 for (int i = _packset.length() - 1; i >= 0; i--) { |
984 Node_List* p1 = _packset.at(i); | |
985 if (p1 == NULL) { | |
986 _packset.remove_at(i); | |
987 } | |
988 } | |
989 | |
990 #ifndef PRODUCT | |
991 if (TraceSuperWord) { | |
992 tty->print_cr("\nAfter combine_packs"); | |
993 print_packset(); | |
994 } | |
995 #endif | |
996 } | |
997 | |
998 //-----------------------------construct_my_pack_map-------------------------- | |
999 // Construct the map from nodes to packs. Only valid after the | |
1000 // point where a node is only in one pack (after combine_packs). | |
1001 void SuperWord::construct_my_pack_map() { | |
1002 Node_List* rslt = NULL; | |
1003 for (int i = 0; i < _packset.length(); i++) { | |
1004 Node_List* p = _packset.at(i); | |
1005 for (uint j = 0; j < p->size(); j++) { | |
1006 Node* s = p->at(j); | |
1007 assert(my_pack(s) == NULL, "only in one pack"); | |
1008 set_my_pack(s, p); | |
1009 } | |
1010 } | |
1011 } | |
1012 | |
1013 //------------------------------filter_packs--------------------------- | |
1014 // Remove packs that are not implemented or not profitable. | |
1015 void SuperWord::filter_packs() { | |
1016 | |
1017 // Remove packs that are not implemented | |
1018 for (int i = _packset.length() - 1; i >= 0; i--) { | |
1019 Node_List* pk = _packset.at(i); | |
1020 bool impl = implemented(pk); | |
1021 if (!impl) { | |
1022 #ifndef PRODUCT | |
1023 if (TraceSuperWord && Verbose) { | |
1024 tty->print_cr("Unimplemented"); | |
1025 pk->at(0)->dump(); | |
1026 } | |
1027 #endif | |
1028 remove_pack_at(i); | |
1029 } | |
1030 } | |
1031 | |
1032 // Remove packs that are not profitable | |
1033 bool changed; | |
1034 do { | |
1035 changed = false; | |
1036 for (int i = _packset.length() - 1; i >= 0; i--) { | |
1037 Node_List* pk = _packset.at(i); | |
1038 bool prof = profitable(pk); | |
1039 if (!prof) { | |
1040 #ifndef PRODUCT | |
1041 if (TraceSuperWord && Verbose) { | |
1042 tty->print_cr("Unprofitable"); | |
1043 pk->at(0)->dump(); | |
1044 } | |
1045 #endif | |
1046 remove_pack_at(i); | |
1047 changed = true; | |
1048 } | |
1049 } | |
1050 } while (changed); | |
1051 | |
1052 #ifndef PRODUCT | |
1053 if (TraceSuperWord) { | |
1054 tty->print_cr("\nAfter filter_packs"); | |
1055 print_packset(); | |
1056 tty->cr(); | |
1057 } | |
1058 #endif | |
1059 } | |
1060 | |
1061 //------------------------------implemented--------------------------- | |
1062 // Can code be generated for pack p? | |
1063 bool SuperWord::implemented(Node_List* p) { | |
1064 Node* p0 = p->at(0); | |
6619
5af51c882207
7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents:
6617
diff
changeset
|
1065 return VectorNode::implemented(p0->Opcode(), p->size(), velt_basic_type(p0)); |
5af51c882207
7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents:
6617
diff
changeset
|
1066 } |
5af51c882207
7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents:
6617
diff
changeset
|
1067 |
5af51c882207
7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents:
6617
diff
changeset
|
1068 //------------------------------same_inputs-------------------------- |
5af51c882207
7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents:
6617
diff
changeset
|
1069 // For pack p, are all idx operands the same? |
5af51c882207
7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents:
6617
diff
changeset
|
1070 static bool same_inputs(Node_List* p, int idx) { |
5af51c882207
7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents:
6617
diff
changeset
|
1071 Node* p0 = p->at(0); |
5af51c882207
7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents:
6617
diff
changeset
|
1072 uint vlen = p->size(); |
5af51c882207
7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents:
6617
diff
changeset
|
1073 Node* p0_def = p0->in(idx); |
5af51c882207
7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents:
6617
diff
changeset
|
1074 for (uint i = 1; i < vlen; i++) { |
5af51c882207
7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents:
6617
diff
changeset
|
1075 Node* pi = p->at(i); |
5af51c882207
7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents:
6617
diff
changeset
|
1076 Node* pi_def = pi->in(idx); |
5af51c882207
7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents:
6617
diff
changeset
|
1077 if (p0_def != pi_def) |
5af51c882207
7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents:
6617
diff
changeset
|
1078 return false; |
6617 | 1079 } |
6619
5af51c882207
7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents:
6617
diff
changeset
|
1080 return true; |
0 | 1081 } |
1082 | |
1083 //------------------------------profitable--------------------------- | |
1084 // For pack p, are all operands and all uses (with in the block) vector? | |
1085 bool SuperWord::profitable(Node_List* p) { | |
1086 Node* p0 = p->at(0); | |
1087 uint start, end; | |
6619
5af51c882207
7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents:
6617
diff
changeset
|
1088 VectorNode::vector_operands(p0, &start, &end); |
0 | 1089 |
6803 | 1090 // Return false if some inputs are not vectors or vectors with different |
1091 // size or alignment. | |
1092 // Also, for now, return false if not scalar promotion case when inputs are | |
1093 // the same. Later, implement PackNode and allow differing, non-vector inputs | |
1094 // (maybe just the ones from outside the block.) | |
0 | 1095 for (uint i = start; i < end; i++) { |
6803 | 1096 if (!is_vector_use(p0, i)) |
1097 return false; | |
0 | 1098 } |
6619
5af51c882207
7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents:
6617
diff
changeset
|
1099 if (VectorNode::is_shift(p0)) { |
6803 | 1100 // For now, return false if shift count is vector or not scalar promotion |
1101 // case (different shift counts) because it is not supported yet. | |
1102 Node* cnt = p0->in(2); | |
1103 Node_List* cnt_pk = my_pack(cnt); | |
1104 if (cnt_pk != NULL) | |
6619
5af51c882207
7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents:
6617
diff
changeset
|
1105 return false; |
5af51c882207
7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents:
6617
diff
changeset
|
1106 if (!same_inputs(p, 2)) |
5af51c882207
7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents:
6617
diff
changeset
|
1107 return false; |
5af51c882207
7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents:
6617
diff
changeset
|
1108 } |
0 | 1109 if (!p0->is_Store()) { |
1110 // For now, return false if not all uses are vector. | |
1111 // Later, implement ExtractNode and allow non-vector uses (maybe | |
1112 // just the ones outside the block.) | |
1113 for (uint i = 0; i < p->size(); i++) { | |
1114 Node* def = p->at(i); | |
1115 for (DUIterator_Fast jmax, j = def->fast_outs(jmax); j < jmax; j++) { | |
1116 Node* use = def->fast_out(j); | |
1117 for (uint k = 0; k < use->req(); k++) { | |
1118 Node* n = use->in(k); | |
1119 if (def == n) { | |
1120 if (!is_vector_use(use, k)) { | |
1121 return false; | |
1122 } | |
1123 } | |
1124 } | |
1125 } | |
1126 } | |
1127 } | |
1128 return true; | |
1129 } | |
1130 | |
1131 //------------------------------schedule--------------------------- | |
1132 // Adjust the memory graph for the packed operations | |
1133 void SuperWord::schedule() { | |
1134 | |
1135 // Co-locate in the memory graph the members of each memory pack | |
1136 for (int i = 0; i < _packset.length(); i++) { | |
1137 co_locate_pack(_packset.at(i)); | |
1138 } | |
1139 } | |
1140 | |
667 | 1141 //-------------------------------remove_and_insert------------------- |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1142 // Remove "current" from its current position in the memory graph and insert |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1143 // it after the appropriate insertion point (lip or uip). |
667 | 1144 void SuperWord::remove_and_insert(MemNode *current, MemNode *prev, MemNode *lip, |
1145 Node *uip, Unique_Node_List &sched_before) { | |
1146 Node* my_mem = current->in(MemNode::Memory); | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1147 bool sched_up = sched_before.member(current); |
667 | 1148 |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1149 // remove current_store from its current position in the memmory graph |
667 | 1150 for (DUIterator i = current->outs(); current->has_out(i); i++) { |
1151 Node* use = current->out(i); | |
1152 if (use->is_Mem()) { | |
1153 assert(use->in(MemNode::Memory) == current, "must be"); | |
1154 if (use == prev) { // connect prev to my_mem | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1155 _igvn.replace_input_of(use, MemNode::Memory, my_mem); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1156 --i; //deleted this edge; rescan position |
667 | 1157 } else if (sched_before.member(use)) { |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1158 if (!sched_up) { // Will be moved together with current |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1159 _igvn.replace_input_of(use, MemNode::Memory, uip); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1160 --i; //deleted this edge; rescan position |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1161 } |
667 | 1162 } else { |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1163 if (sched_up) { // Will be moved together with current |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1164 _igvn.replace_input_of(use, MemNode::Memory, lip); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1165 --i; //deleted this edge; rescan position |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1166 } |
667 | 1167 } |
1168 } | |
1169 } | |
1170 | |
1171 Node *insert_pt = sched_up ? uip : lip; | |
1172 | |
1173 // all uses of insert_pt's memory state should use current's instead | |
1174 for (DUIterator i = insert_pt->outs(); insert_pt->has_out(i); i++) { | |
1175 Node* use = insert_pt->out(i); | |
1176 if (use->is_Mem()) { | |
1177 assert(use->in(MemNode::Memory) == insert_pt, "must be"); | |
6144
5e990493719e
7173340: C2: code cleanup: use PhaseIterGVN::replace_edge(Node*, int, Node*) where applicable
kvn
parents:
6045
diff
changeset
|
1178 _igvn.replace_input_of(use, MemNode::Memory, current); |
667 | 1179 --i; //deleted this edge; rescan position |
1180 } else if (!sched_up && use->is_Phi() && use->bottom_type() == Type::MEMORY) { | |
1181 uint pos; //lip (lower insert point) must be the last one in the memory slice | |
1182 for (pos=1; pos < use->req(); pos++) { | |
1183 if (use->in(pos) == insert_pt) break; | |
1184 } | |
6144
5e990493719e
7173340: C2: code cleanup: use PhaseIterGVN::replace_edge(Node*, int, Node*) where applicable
kvn
parents:
6045
diff
changeset
|
1185 _igvn.replace_input_of(use, pos, current); |
667 | 1186 --i; |
1187 } | |
1188 } | |
1189 | |
1190 //connect current to insert_pt | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1191 _igvn.replace_input_of(current, MemNode::Memory, insert_pt); |
667 | 1192 } |
1193 | |
1194 //------------------------------co_locate_pack---------------------------------- | |
1195 // To schedule a store pack, we need to move any sandwiched memory ops either before | |
1196 // or after the pack, based upon dependence information: | |
1197 // (1) If any store in the pack depends on the sandwiched memory op, the | |
1198 // sandwiched memory op must be scheduled BEFORE the pack; | |
1199 // (2) If a sandwiched memory op depends on any store in the pack, the | |
1200 // sandwiched memory op must be scheduled AFTER the pack; | |
1201 // (3) If a sandwiched memory op (say, memA) depends on another sandwiched | |
1202 // memory op (say memB), memB must be scheduled before memA. So, if memA is | |
1203 // scheduled before the pack, memB must also be scheduled before the pack; | |
1204 // (4) If there is no dependence restriction for a sandwiched memory op, we simply | |
1205 // schedule this store AFTER the pack | |
1206 // (5) We know there is no dependence cycle, so there in no other case; | |
1207 // (6) Finally, all memory ops in another single pack should be moved in the same direction. | |
1208 // | |
952 | 1209 // To schedule a load pack, we use the memory state of either the first or the last load in |
1210 // the pack, based on the dependence constraint. | |
0 | 1211 void SuperWord::co_locate_pack(Node_List* pk) { |
1212 if (pk->at(0)->is_Store()) { | |
1213 MemNode* first = executed_first(pk)->as_Mem(); | |
1214 MemNode* last = executed_last(pk)->as_Mem(); | |
667 | 1215 Unique_Node_List schedule_before_pack; |
1216 Unique_Node_List memops; | |
1217 | |
0 | 1218 MemNode* current = last->in(MemNode::Memory)->as_Mem(); |
667 | 1219 MemNode* previous = last; |
0 | 1220 while (true) { |
1221 assert(in_bb(current), "stay in block"); | |
667 | 1222 memops.push(previous); |
1223 for (DUIterator i = current->outs(); current->has_out(i); i++) { | |
1224 Node* use = current->out(i); | |
1225 if (use->is_Mem() && use != previous) | |
1226 memops.push(use); | |
1227 } | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1228 if (current == first) break; |
667 | 1229 previous = current; |
1230 current = current->in(MemNode::Memory)->as_Mem(); | |
1231 } | |
1232 | |
1233 // determine which memory operations should be scheduled before the pack | |
1234 for (uint i = 1; i < memops.size(); i++) { | |
1235 Node *s1 = memops.at(i); | |
1236 if (!in_pack(s1, pk) && !schedule_before_pack.member(s1)) { | |
1237 for (uint j = 0; j< i; j++) { | |
1238 Node *s2 = memops.at(j); | |
1239 if (!independent(s1, s2)) { | |
1240 if (in_pack(s2, pk) || schedule_before_pack.member(s2)) { | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1241 schedule_before_pack.push(s1); // s1 must be scheduled before |
667 | 1242 Node_List* mem_pk = my_pack(s1); |
1243 if (mem_pk != NULL) { | |
1244 for (uint ii = 0; ii < mem_pk->size(); ii++) { | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1245 Node* s = mem_pk->at(ii); // follow partner |
667 | 1246 if (memops.member(s) && !schedule_before_pack.member(s)) |
1247 schedule_before_pack.push(s); | |
1248 } | |
1249 } | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1250 break; |
667 | 1251 } |
1252 } | |
1253 } | |
1254 } | |
1255 } | |
1256 | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1257 Node* upper_insert_pt = first->in(MemNode::Memory); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1258 // Following code moves loads connected to upper_insert_pt below aliased stores. |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1259 // Collect such loads here and reconnect them back to upper_insert_pt later. |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1260 memops.clear(); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1261 for (DUIterator i = upper_insert_pt->outs(); upper_insert_pt->has_out(i); i++) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1262 Node* use = upper_insert_pt->out(i); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1263 if (!use->is_Store()) |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1264 memops.push(use); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1265 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1266 |
667 | 1267 MemNode* lower_insert_pt = last; |
1268 previous = last; //previous store in pk | |
1269 current = last->in(MemNode::Memory)->as_Mem(); | |
1270 | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1271 // start scheduling from "last" to "first" |
667 | 1272 while (true) { |
1273 assert(in_bb(current), "stay in block"); | |
1274 assert(in_pack(previous, pk), "previous stays in pack"); | |
0 | 1275 Node* my_mem = current->in(MemNode::Memory); |
667 | 1276 |
0 | 1277 if (in_pack(current, pk)) { |
667 | 1278 // Forward users of my memory state (except "previous) to my input memory state |
0 | 1279 for (DUIterator i = current->outs(); current->has_out(i); i++) { |
1280 Node* use = current->out(i); | |
667 | 1281 if (use->is_Mem() && use != previous) { |
0 | 1282 assert(use->in(MemNode::Memory) == current, "must be"); |
667 | 1283 if (schedule_before_pack.member(use)) { |
6144
5e990493719e
7173340: C2: code cleanup: use PhaseIterGVN::replace_edge(Node*, int, Node*) where applicable
kvn
parents:
6045
diff
changeset
|
1284 _igvn.replace_input_of(use, MemNode::Memory, upper_insert_pt); |
667 | 1285 } else { |
6144
5e990493719e
7173340: C2: code cleanup: use PhaseIterGVN::replace_edge(Node*, int, Node*) where applicable
kvn
parents:
6045
diff
changeset
|
1286 _igvn.replace_input_of(use, MemNode::Memory, lower_insert_pt); |
667 | 1287 } |
0 | 1288 --i; // deleted this edge; rescan position |
1289 } | |
1290 } | |
667 | 1291 previous = current; |
1292 } else { // !in_pack(current, pk) ==> a sandwiched store | |
1293 remove_and_insert(current, previous, lower_insert_pt, upper_insert_pt, schedule_before_pack); | |
0 | 1294 } |
667 | 1295 |
0 | 1296 if (current == first) break; |
1297 current = my_mem->as_Mem(); | |
667 | 1298 } // end while |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1299 |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1300 // Reconnect loads back to upper_insert_pt. |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1301 for (uint i = 0; i < memops.size(); i++) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1302 Node *ld = memops.at(i); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1303 if (ld->in(MemNode::Memory) != upper_insert_pt) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1304 _igvn.replace_input_of(ld, MemNode::Memory, upper_insert_pt); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1305 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1306 } |
667 | 1307 } else if (pk->at(0)->is_Load()) { //load |
952 | 1308 // all loads in the pack should have the same memory state. By default, |
1309 // we use the memory state of the last load. However, if any load could | |
1310 // not be moved down due to the dependence constraint, we use the memory | |
1311 // state of the first load. | |
1312 Node* last_mem = executed_last(pk)->in(MemNode::Memory); | |
1313 Node* first_mem = executed_first(pk)->in(MemNode::Memory); | |
1314 bool schedule_last = true; | |
1315 for (uint i = 0; i < pk->size(); i++) { | |
1316 Node* ld = pk->at(i); | |
1317 for (Node* current = last_mem; current != ld->in(MemNode::Memory); | |
1318 current=current->in(MemNode::Memory)) { | |
1319 assert(current != first_mem, "corrupted memory graph"); | |
1320 if(current->is_Mem() && !independent(current, ld)){ | |
1321 schedule_last = false; // a later store depends on this load | |
1322 break; | |
1323 } | |
1324 } | |
1325 } | |
1326 | |
1327 Node* mem_input = schedule_last ? last_mem : first_mem; | |
1328 _igvn.hash_delete(mem_input); | |
1329 // Give each load the same memory state | |
0 | 1330 for (uint i = 0; i < pk->size(); i++) { |
1331 LoadNode* ld = pk->at(i)->as_Load(); | |
6144
5e990493719e
7173340: C2: code cleanup: use PhaseIterGVN::replace_edge(Node*, int, Node*) where applicable
kvn
parents:
6045
diff
changeset
|
1332 _igvn.replace_input_of(ld, MemNode::Memory, mem_input); |
0 | 1333 } |
1334 } | |
1335 } | |
1336 | |
1337 //------------------------------output--------------------------- | |
1338 // Convert packs into vector node operations | |
1339 void SuperWord::output() { | |
1340 if (_packset.length() == 0) return; | |
1341 | |
2445 | 1342 #ifndef PRODUCT |
1343 if (TraceLoopOpts) { | |
1344 tty->print("SuperWord "); | |
1345 lpt()->dump_head(); | |
1346 } | |
1347 #endif | |
1348 | |
0 | 1349 // MUST ENSURE main loop's initial value is properly aligned: |
1350 // (iv_initial_value + min_iv_offset) % vector_width_in_bytes() == 0 | |
1351 | |
1352 align_initial_loop_index(align_to_ref()); | |
1353 | |
1354 // Insert extract (unpack) operations for scalar uses | |
1355 for (int i = 0; i < _packset.length(); i++) { | |
1356 insert_extracts(_packset.at(i)); | |
1357 } | |
1358 | |
6792
137868b7aa6f
7196199: java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect
kvn
parents:
6619
diff
changeset
|
1359 Compile* C = _phase->C; |
137868b7aa6f
7196199: java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect
kvn
parents:
6619
diff
changeset
|
1360 uint max_vlen_in_bytes = 0; |
0 | 1361 for (int i = 0; i < _block.length(); i++) { |
1362 Node* n = _block.at(i); | |
1363 Node_List* p = my_pack(n); | |
1364 if (p && n == executed_last(p)) { | |
1365 uint vlen = p->size(); | |
6792
137868b7aa6f
7196199: java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect
kvn
parents:
6619
diff
changeset
|
1366 uint vlen_in_bytes = 0; |
0 | 1367 Node* vn = NULL; |
1368 Node* low_adr = p->at(0); | |
1369 Node* first = executed_first(p); | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1370 int opc = n->Opcode(); |
0 | 1371 if (n->is_Load()) { |
1372 Node* ctl = n->in(MemNode::Control); | |
1373 Node* mem = first->in(MemNode::Memory); | |
1374 Node* adr = low_adr->in(MemNode::Address); | |
1375 const TypePtr* atyp = n->adr_type(); | |
6792
137868b7aa6f
7196199: java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect
kvn
parents:
6619
diff
changeset
|
1376 vn = LoadVectorNode::make(C, opc, ctl, mem, adr, atyp, vlen, velt_basic_type(n)); |
137868b7aa6f
7196199: java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect
kvn
parents:
6619
diff
changeset
|
1377 vlen_in_bytes = vn->as_LoadVector()->memory_size(); |
0 | 1378 } else if (n->is_Store()) { |
1379 // Promote value to be stored to vector | |
3842 | 1380 Node* val = vector_opd(p, MemNode::ValueIn); |
0 | 1381 Node* ctl = n->in(MemNode::Control); |
1382 Node* mem = first->in(MemNode::Memory); | |
1383 Node* adr = low_adr->in(MemNode::Address); | |
1384 const TypePtr* atyp = n->adr_type(); | |
6792
137868b7aa6f
7196199: java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect
kvn
parents:
6619
diff
changeset
|
1385 vn = StoreVectorNode::make(C, opc, ctl, mem, adr, atyp, val, vlen); |
137868b7aa6f
7196199: java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect
kvn
parents:
6619
diff
changeset
|
1386 vlen_in_bytes = vn->as_StoreVector()->memory_size(); |
0 | 1387 } else if (n->req() == 3) { |
1388 // Promote operands to vector | |
1389 Node* in1 = vector_opd(p, 1); | |
1390 Node* in2 = vector_opd(p, 2); | |
6614
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1391 if (VectorNode::is_invariant_vector(in1) && (n->is_Add() || n->is_Mul())) { |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1392 // Move invariant vector input into second position to avoid register spilling. |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1393 Node* tmp = in1; |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1394 in1 = in2; |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1395 in2 = tmp; |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1396 } |
6792
137868b7aa6f
7196199: java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect
kvn
parents:
6619
diff
changeset
|
1397 vn = VectorNode::make(C, opc, in1, in2, vlen, velt_basic_type(n)); |
137868b7aa6f
7196199: java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect
kvn
parents:
6619
diff
changeset
|
1398 vlen_in_bytes = vn->as_Vector()->length_in_bytes(); |
0 | 1399 } else { |
1400 ShouldNotReachHere(); | |
1401 } | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1402 assert(vn != NULL, "sanity"); |
6803 | 1403 _igvn.register_new_node_with_optimizer(vn); |
0 | 1404 _phase->set_ctrl(vn, _phase->get_ctrl(p->at(0))); |
1405 for (uint j = 0; j < p->size(); j++) { | |
1406 Node* pm = p->at(j); | |
1621
6027dddc26c6
6677629: PhaseIterGVN::subsume_node() should call hash_delete() and add_users_to_worklist()
kvn
parents:
1585
diff
changeset
|
1407 _igvn.replace_node(pm, vn); |
0 | 1408 } |
1409 _igvn._worklist.push(vn); | |
6792
137868b7aa6f
7196199: java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect
kvn
parents:
6619
diff
changeset
|
1410 |
137868b7aa6f
7196199: java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect
kvn
parents:
6619
diff
changeset
|
1411 if (vlen_in_bytes > max_vlen_in_bytes) { |
137868b7aa6f
7196199: java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect
kvn
parents:
6619
diff
changeset
|
1412 max_vlen_in_bytes = vlen_in_bytes; |
137868b7aa6f
7196199: java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect
kvn
parents:
6619
diff
changeset
|
1413 } |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1414 #ifdef ASSERT |
6183
6f8f439e247d
7177923: SIGBUS on sparc in compiled code for java.util.Calendar.clear()
kvn
parents:
6179
diff
changeset
|
1415 if (TraceNewVectors) { |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1416 tty->print("new Vector node: "); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1417 vn->dump(); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1418 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1419 #endif |
0 | 1420 } |
1421 } | |
6792
137868b7aa6f
7196199: java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect
kvn
parents:
6619
diff
changeset
|
1422 C->set_max_vector_size(max_vlen_in_bytes); |
0 | 1423 } |
1424 | |
1425 //------------------------------vector_opd--------------------------- | |
1426 // Create a vector operand for the nodes in pack p for operand: in(opd_idx) | |
3842 | 1427 Node* SuperWord::vector_opd(Node_List* p, int opd_idx) { |
0 | 1428 Node* p0 = p->at(0); |
1429 uint vlen = p->size(); | |
1430 Node* opd = p0->in(opd_idx); | |
1431 | |
6619
5af51c882207
7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents:
6617
diff
changeset
|
1432 if (same_inputs(p, opd_idx)) { |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1433 if (opd->is_Vector() || opd->is_LoadVector()) { |
6617 | 1434 assert(((opd_idx != 2) || !VectorNode::is_shift(p0)), "shift's count can't be vector"); |
3842 | 1435 return opd; // input is matching vector |
0 | 1436 } |
6614
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1437 if ((opd_idx == 2) && VectorNode::is_shift(p0)) { |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1438 Compile* C = _phase->C; |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1439 Node* cnt = opd; |
6823 | 1440 // Vector instructions do not mask shift count, do it here. |
6614
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1441 juint mask = (p0->bottom_type() == TypeInt::INT) ? (BitsPerInt - 1) : (BitsPerLong - 1); |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1442 const TypeInt* t = opd->find_int_type(); |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1443 if (t != NULL && t->is_con()) { |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1444 juint shift = t->get_con(); |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1445 if (shift > mask) { // Unsigned cmp |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1446 cnt = ConNode::make(C, TypeInt::make(shift & mask)); |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1447 } |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1448 } else { |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1449 if (t == NULL || t->_lo < 0 || t->_hi > (int)mask) { |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1450 cnt = ConNode::make(C, TypeInt::make(mask)); |
6803 | 1451 _igvn.register_new_node_with_optimizer(cnt); |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6803
diff
changeset
|
1452 cnt = new (C) AndINode(opd, cnt); |
6803 | 1453 _igvn.register_new_node_with_optimizer(cnt); |
6614
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1454 _phase->set_ctrl(cnt, _phase->get_ctrl(opd)); |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1455 } |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1456 assert(opd->bottom_type()->isa_int(), "int type only"); |
6823 | 1457 // Move non constant shift count into vector register. |
1458 cnt = VectorNode::shift_count(C, p0, cnt, vlen, velt_basic_type(p0)); | |
6614
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1459 } |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1460 if (cnt != opd) { |
6803 | 1461 _igvn.register_new_node_with_optimizer(cnt); |
6614
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1462 _phase->set_ctrl(cnt, _phase->get_ctrl(opd)); |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1463 } |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1464 return cnt; |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1465 } |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1466 assert(!opd->is_StoreVector(), "such vector is not expected here"); |
6045 | 1467 // Convert scalar input to vector with the same number of elements as |
1468 // p0's vector. Use p0's type because size of operand's container in | |
1469 // vector should match p0's size regardless operand's size. | |
1470 const Type* p0_t = velt_type(p0); | |
1471 VectorNode* vn = VectorNode::scalar2vector(_phase->C, opd, vlen, p0_t); | |
0 | 1472 |
6803 | 1473 _igvn.register_new_node_with_optimizer(vn); |
0 | 1474 _phase->set_ctrl(vn, _phase->get_ctrl(opd)); |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1475 #ifdef ASSERT |
6183
6f8f439e247d
7177923: SIGBUS on sparc in compiled code for java.util.Calendar.clear()
kvn
parents:
6179
diff
changeset
|
1476 if (TraceNewVectors) { |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1477 tty->print("new Vector node: "); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1478 vn->dump(); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1479 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1480 #endif |
0 | 1481 return vn; |
1482 } | |
1483 | |
1484 // Insert pack operation | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1485 BasicType bt = velt_basic_type(p0); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1486 PackNode* pk = PackNode::make(_phase->C, opd, vlen, bt); |
6045 | 1487 DEBUG_ONLY( const BasicType opd_bt = opd->bottom_type()->basic_type(); ) |
0 | 1488 |
1489 for (uint i = 1; i < vlen; i++) { | |
1490 Node* pi = p->at(i); | |
1491 Node* in = pi->in(opd_idx); | |
1492 assert(my_pack(in) == NULL, "Should already have been unpacked"); | |
6045 | 1493 assert(opd_bt == in->bottom_type()->basic_type(), "all same type"); |
6619
5af51c882207
7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents:
6617
diff
changeset
|
1494 pk->add_opd(in); |
0 | 1495 } |
6803 | 1496 _igvn.register_new_node_with_optimizer(pk); |
0 | 1497 _phase->set_ctrl(pk, _phase->get_ctrl(opd)); |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1498 #ifdef ASSERT |
6792
137868b7aa6f
7196199: java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect
kvn
parents:
6619
diff
changeset
|
1499 if (TraceNewVectors) { |
137868b7aa6f
7196199: java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect
kvn
parents:
6619
diff
changeset
|
1500 tty->print("new Vector node: "); |
137868b7aa6f
7196199: java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect
kvn
parents:
6619
diff
changeset
|
1501 pk->dump(); |
137868b7aa6f
7196199: java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect
kvn
parents:
6619
diff
changeset
|
1502 } |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1503 #endif |
0 | 1504 return pk; |
1505 } | |
1506 | |
1507 //------------------------------insert_extracts--------------------------- | |
1508 // If a use of pack p is not a vector use, then replace the | |
1509 // use with an extract operation. | |
1510 void SuperWord::insert_extracts(Node_List* p) { | |
1511 if (p->at(0)->is_Store()) return; | |
1512 assert(_n_idx_list.is_empty(), "empty (node,index) list"); | |
1513 | |
1514 // Inspect each use of each pack member. For each use that is | |
1515 // not a vector use, replace the use with an extract operation. | |
1516 | |
1517 for (uint i = 0; i < p->size(); i++) { | |
1518 Node* def = p->at(i); | |
1519 for (DUIterator_Fast jmax, j = def->fast_outs(jmax); j < jmax; j++) { | |
1520 Node* use = def->fast_out(j); | |
1521 for (uint k = 0; k < use->req(); k++) { | |
1522 Node* n = use->in(k); | |
1523 if (def == n) { | |
1524 if (!is_vector_use(use, k)) { | |
1525 _n_idx_list.push(use, k); | |
1526 } | |
1527 } | |
1528 } | |
1529 } | |
1530 } | |
1531 | |
1532 while (_n_idx_list.is_nonempty()) { | |
1533 Node* use = _n_idx_list.node(); | |
1534 int idx = _n_idx_list.index(); | |
1535 _n_idx_list.pop(); | |
1536 Node* def = use->in(idx); | |
1537 | |
1538 // Insert extract operation | |
1539 _igvn.hash_delete(def); | |
1540 int def_pos = alignment(def) / data_size(def); | |
1541 | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1542 Node* ex = ExtractNode::make(_phase->C, def, def_pos, velt_basic_type(def)); |
6803 | 1543 _igvn.register_new_node_with_optimizer(ex); |
0 | 1544 _phase->set_ctrl(ex, _phase->get_ctrl(def)); |
6144
5e990493719e
7173340: C2: code cleanup: use PhaseIterGVN::replace_edge(Node*, int, Node*) where applicable
kvn
parents:
6045
diff
changeset
|
1545 _igvn.replace_input_of(use, idx, ex); |
0 | 1546 _igvn._worklist.push(def); |
1547 | |
1548 bb_insert_after(ex, bb_idx(def)); | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1549 set_velt_type(ex, velt_type(def)); |
0 | 1550 } |
1551 } | |
1552 | |
1553 //------------------------------is_vector_use--------------------------- | |
1554 // Is use->in(u_idx) a vector use? | |
1555 bool SuperWord::is_vector_use(Node* use, int u_idx) { | |
1556 Node_List* u_pk = my_pack(use); | |
1557 if (u_pk == NULL) return false; | |
1558 Node* def = use->in(u_idx); | |
1559 Node_List* d_pk = my_pack(def); | |
1560 if (d_pk == NULL) { | |
1561 // check for scalar promotion | |
1562 Node* n = u_pk->at(0)->in(u_idx); | |
1563 for (uint i = 1; i < u_pk->size(); i++) { | |
1564 if (u_pk->at(i)->in(u_idx) != n) return false; | |
1565 } | |
1566 return true; | |
1567 } | |
1568 if (u_pk->size() != d_pk->size()) | |
1569 return false; | |
1570 for (uint i = 0; i < u_pk->size(); i++) { | |
1571 Node* ui = u_pk->at(i); | |
1572 Node* di = d_pk->at(i); | |
1573 if (ui->in(u_idx) != di || alignment(ui) != alignment(di)) | |
1574 return false; | |
1575 } | |
1576 return true; | |
1577 } | |
1578 | |
1579 //------------------------------construct_bb--------------------------- | |
1580 // Construct reverse postorder list of block members | |
1581 void SuperWord::construct_bb() { | |
1582 Node* entry = bb(); | |
1583 | |
1584 assert(_stk.length() == 0, "stk is empty"); | |
1585 assert(_block.length() == 0, "block is empty"); | |
1586 assert(_data_entry.length() == 0, "data_entry is empty"); | |
1587 assert(_mem_slice_head.length() == 0, "mem_slice_head is empty"); | |
1588 assert(_mem_slice_tail.length() == 0, "mem_slice_tail is empty"); | |
1589 | |
1590 // Find non-control nodes with no inputs from within block, | |
1591 // create a temporary map from node _idx to bb_idx for use | |
1592 // by the visited and post_visited sets, | |
1593 // and count number of nodes in block. | |
1594 int bb_ct = 0; | |
1595 for (uint i = 0; i < lpt()->_body.size(); i++ ) { | |
1596 Node *n = lpt()->_body.at(i); | |
1597 set_bb_idx(n, i); // Create a temporary map | |
1598 if (in_bb(n)) { | |
1599 bb_ct++; | |
1600 if (!n->is_CFG()) { | |
1601 bool found = false; | |
1602 for (uint j = 0; j < n->req(); j++) { | |
1603 Node* def = n->in(j); | |
1604 if (def && in_bb(def)) { | |
1605 found = true; | |
1606 break; | |
1607 } | |
1608 } | |
1609 if (!found) { | |
1610 assert(n != entry, "can't be entry"); | |
1611 _data_entry.push(n); | |
1612 } | |
1613 } | |
1614 } | |
1615 } | |
1616 | |
1617 // Find memory slices (head and tail) | |
1618 for (DUIterator_Fast imax, i = lp()->fast_outs(imax); i < imax; i++) { | |
1619 Node *n = lp()->fast_out(i); | |
1620 if (in_bb(n) && (n->is_Phi() && n->bottom_type() == Type::MEMORY)) { | |
1621 Node* n_tail = n->in(LoopNode::LoopBackControl); | |
253
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
235
diff
changeset
|
1622 if (n_tail != n->in(LoopNode::EntryControl)) { |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
235
diff
changeset
|
1623 _mem_slice_head.push(n); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
235
diff
changeset
|
1624 _mem_slice_tail.push(n_tail); |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
235
diff
changeset
|
1625 } |
0 | 1626 } |
1627 } | |
1628 | |
1629 // Create an RPO list of nodes in block | |
1630 | |
1631 visited_clear(); | |
1632 post_visited_clear(); | |
1633 | |
1634 // Push all non-control nodes with no inputs from within block, then control entry | |
1635 for (int j = 0; j < _data_entry.length(); j++) { | |
1636 Node* n = _data_entry.at(j); | |
1637 visited_set(n); | |
1638 _stk.push(n); | |
1639 } | |
1640 visited_set(entry); | |
1641 _stk.push(entry); | |
1642 | |
1643 // Do a depth first walk over out edges | |
1644 int rpo_idx = bb_ct - 1; | |
1645 int size; | |
1646 while ((size = _stk.length()) > 0) { | |
1647 Node* n = _stk.top(); // Leave node on stack | |
1648 if (!visited_test_set(n)) { | |
1649 // forward arc in graph | |
1650 } else if (!post_visited_test(n)) { | |
1651 // cross or back arc | |
1652 for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) { | |
1653 Node *use = n->fast_out(i); | |
1654 if (in_bb(use) && !visited_test(use) && | |
1655 // Don't go around backedge | |
1656 (!use->is_Phi() || n == entry)) { | |
1657 _stk.push(use); | |
1658 } | |
1659 } | |
1660 if (_stk.length() == size) { | |
1661 // There were no additional uses, post visit node now | |
1662 _stk.pop(); // Remove node from stack | |
1663 assert(rpo_idx >= 0, ""); | |
1664 _block.at_put_grow(rpo_idx, n); | |
1665 rpo_idx--; | |
1666 post_visited_set(n); | |
1667 assert(rpo_idx >= 0 || _stk.is_empty(), ""); | |
1668 } | |
1669 } else { | |
1670 _stk.pop(); // Remove post-visited node from stack | |
1671 } | |
1672 } | |
1673 | |
1674 // Create real map of block indices for nodes | |
1675 for (int j = 0; j < _block.length(); j++) { | |
1676 Node* n = _block.at(j); | |
1677 set_bb_idx(n, j); | |
1678 } | |
1679 | |
1680 initialize_bb(); // Ensure extra info is allocated. | |
1681 | |
1682 #ifndef PRODUCT | |
1683 if (TraceSuperWord) { | |
1684 print_bb(); | |
1685 tty->print_cr("\ndata entry nodes: %s", _data_entry.length() > 0 ? "" : "NONE"); | |
1686 for (int m = 0; m < _data_entry.length(); m++) { | |
1687 tty->print("%3d ", m); | |
1688 _data_entry.at(m)->dump(); | |
1689 } | |
1690 tty->print_cr("\nmemory slices: %s", _mem_slice_head.length() > 0 ? "" : "NONE"); | |
1691 for (int m = 0; m < _mem_slice_head.length(); m++) { | |
1692 tty->print("%3d ", m); _mem_slice_head.at(m)->dump(); | |
1693 tty->print(" "); _mem_slice_tail.at(m)->dump(); | |
1694 } | |
1695 } | |
1696 #endif | |
1697 assert(rpo_idx == -1 && bb_ct == _block.length(), "all block members found"); | |
1698 } | |
1699 | |
1700 //------------------------------initialize_bb--------------------------- | |
1701 // Initialize per node info | |
1702 void SuperWord::initialize_bb() { | |
1703 Node* last = _block.at(_block.length() - 1); | |
1704 grow_node_info(bb_idx(last)); | |
1705 } | |
1706 | |
1707 //------------------------------bb_insert_after--------------------------- | |
1708 // Insert n into block after pos | |
1709 void SuperWord::bb_insert_after(Node* n, int pos) { | |
1710 int n_pos = pos + 1; | |
1711 // Make room | |
1712 for (int i = _block.length() - 1; i >= n_pos; i--) { | |
1713 _block.at_put_grow(i+1, _block.at(i)); | |
1714 } | |
1715 for (int j = _node_info.length() - 1; j >= n_pos; j--) { | |
1716 _node_info.at_put_grow(j+1, _node_info.at(j)); | |
1717 } | |
1718 // Set value | |
1719 _block.at_put_grow(n_pos, n); | |
1720 _node_info.at_put_grow(n_pos, SWNodeInfo::initial); | |
1721 // Adjust map from node->_idx to _block index | |
1722 for (int i = n_pos; i < _block.length(); i++) { | |
1723 set_bb_idx(_block.at(i), i); | |
1724 } | |
1725 } | |
1726 | |
1727 //------------------------------compute_max_depth--------------------------- | |
1728 // Compute max depth for expressions from beginning of block | |
1729 // Use to prune search paths during test for independence. | |
1730 void SuperWord::compute_max_depth() { | |
1731 int ct = 0; | |
1732 bool again; | |
1733 do { | |
1734 again = false; | |
1735 for (int i = 0; i < _block.length(); i++) { | |
1736 Node* n = _block.at(i); | |
1737 if (!n->is_Phi()) { | |
1738 int d_orig = depth(n); | |
1739 int d_in = 0; | |
1740 for (DepPreds preds(n, _dg); !preds.done(); preds.next()) { | |
1741 Node* pred = preds.current(); | |
1742 if (in_bb(pred)) { | |
1743 d_in = MAX2(d_in, depth(pred)); | |
1744 } | |
1745 } | |
1746 if (d_in + 1 != d_orig) { | |
1747 set_depth(n, d_in + 1); | |
1748 again = true; | |
1749 } | |
1750 } | |
1751 } | |
1752 ct++; | |
1753 } while (again); | |
1754 #ifndef PRODUCT | |
1755 if (TraceSuperWord && Verbose) | |
1756 tty->print_cr("compute_max_depth iterated: %d times", ct); | |
1757 #endif | |
1758 } | |
1759 | |
1760 //-------------------------compute_vector_element_type----------------------- | |
1761 // Compute necessary vector element type for expressions | |
1762 // This propagates backwards a narrower integer type when the | |
1763 // upper bits of the value are not needed. | |
1764 // Example: char a,b,c; a = b + c; | |
1765 // Normally the type of the add is integer, but for packed character | |
1766 // operations the type of the add needs to be char. | |
1767 void SuperWord::compute_vector_element_type() { | |
1768 #ifndef PRODUCT | |
1769 if (TraceSuperWord && Verbose) | |
1770 tty->print_cr("\ncompute_velt_type:"); | |
1771 #endif | |
1772 | |
1773 // Initial type | |
1774 for (int i = 0; i < _block.length(); i++) { | |
1775 Node* n = _block.at(i); | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1776 set_velt_type(n, container_type(n)); |
0 | 1777 } |
1778 | |
6893
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1779 // Propagate integer narrowed type backwards through operations |
0 | 1780 // that don't depend on higher order bits |
1781 for (int i = _block.length() - 1; i >= 0; i--) { | |
1782 Node* n = _block.at(i); | |
1783 // Only integer types need be examined | |
6893
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1784 const Type* vtn = velt_type(n); |
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1785 if (vtn->basic_type() == T_INT) { |
0 | 1786 uint start, end; |
6619
5af51c882207
7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents:
6617
diff
changeset
|
1787 VectorNode::vector_operands(n, &start, &end); |
0 | 1788 |
1789 for (uint j = start; j < end; j++) { | |
1790 Node* in = n->in(j); | |
6614
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1791 // Don't propagate through a memory |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1792 if (!in->is_Mem() && in_bb(in) && velt_type(in)->basic_type() == T_INT && |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1793 data_size(n) < data_size(in)) { |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1794 bool same_type = true; |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1795 for (DUIterator_Fast kmax, k = in->fast_outs(kmax); k < kmax; k++) { |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1796 Node *use = in->fast_out(k); |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1797 if (!in_bb(use) || !same_velt_type(use, n)) { |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1798 same_type = false; |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1799 break; |
0 | 1800 } |
6614
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1801 } |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1802 if (same_type) { |
6893
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1803 // For right shifts of small integer types (bool, byte, char, short) |
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1804 // we need precise information about sign-ness. Only Load nodes have |
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1805 // this information because Store nodes are the same for signed and |
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1806 // unsigned values. And any arithmetic operation after a load may |
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1807 // expand a value to signed Int so such right shifts can't be used |
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1808 // because vector elements do not have upper bits of Int. |
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1809 const Type* vt = vtn; |
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1810 if (VectorNode::is_shift(in)) { |
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1811 Node* load = in->in(1); |
6896 | 1812 if (load->is_Load() && in_bb(load) && (velt_type(load)->basic_type() == T_INT)) { |
6893
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1813 vt = velt_type(load); |
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1814 } else if (in->Opcode() != Op_LShiftI) { |
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1815 // Widen type to Int to avoid creation of right shift vector |
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1816 // (align + data_size(s1) check in stmts_can_pack() will fail). |
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1817 // Note, left shifts work regardless type. |
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1818 vt = TypeInt::INT; |
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1819 } |
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1820 } |
6614
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1821 set_velt_type(in, vt); |
0 | 1822 } |
1823 } | |
1824 } | |
1825 } | |
1826 } | |
1827 #ifndef PRODUCT | |
1828 if (TraceSuperWord && Verbose) { | |
1829 for (int i = 0; i < _block.length(); i++) { | |
1830 Node* n = _block.at(i); | |
1831 velt_type(n)->dump(); | |
1832 tty->print("\t"); | |
1833 n->dump(); | |
1834 } | |
1835 } | |
1836 #endif | |
1837 } | |
1838 | |
1839 //------------------------------memory_alignment--------------------------- | |
1840 // Alignment within a vector memory reference | |
6794 | 1841 int SuperWord::memory_alignment(MemNode* s, int iv_adjust) { |
0 | 1842 SWPointer p(s, this); |
1843 if (!p.valid()) { | |
1844 return bottom_align; | |
1845 } | |
6183
6f8f439e247d
7177923: SIGBUS on sparc in compiled code for java.util.Calendar.clear()
kvn
parents:
6179
diff
changeset
|
1846 int vw = vector_width_in_bytes(s); |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1847 if (vw < 2) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1848 return bottom_align; // No vectors for this type |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1849 } |
0 | 1850 int offset = p.offset_in_bytes(); |
6794 | 1851 offset += iv_adjust*p.memory_size(); |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1852 int off_rem = offset % vw; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1853 int off_mod = off_rem >= 0 ? off_rem : off_rem + vw; |
0 | 1854 return off_mod; |
1855 } | |
1856 | |
1857 //---------------------------container_type--------------------------- | |
1858 // Smallest type containing range of values | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1859 const Type* SuperWord::container_type(Node* n) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1860 if (n->is_Mem()) { |
6893
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1861 BasicType bt = n->as_Mem()->memory_type(); |
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1862 if (n->is_Store() && (bt == T_CHAR)) { |
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1863 // Use T_SHORT type instead of T_CHAR for stored values because any |
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1864 // preceding arithmetic operation extends values to signed Int. |
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1865 bt = T_SHORT; |
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1866 } |
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1867 if (n->Opcode() == Op_LoadUB) { |
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1868 // Adjust type for unsigned byte loads, it is important for right shifts. |
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1869 // T_BOOLEAN is used because there is no basic type representing type |
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1870 // TypeInt::UBYTE. Use of T_BOOLEAN for vectors is fine because only |
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1871 // size (one byte) and sign is important. |
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1872 bt = T_BOOLEAN; |
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1873 } |
b2c669fd8114
8001183: incorrect results of char vectors right shift operaiton
kvn
parents:
6849
diff
changeset
|
1874 return Type::get_const_basic_type(bt); |
0 | 1875 } |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1876 const Type* t = _igvn.type(n); |
0 | 1877 if (t->basic_type() == T_INT) { |
6614
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1878 // A narrow type of arithmetic operations will be determined by |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1879 // propagating the type of memory operations. |
0 | 1880 return TypeInt::INT; |
1881 } | |
1882 return t; | |
1883 } | |
1884 | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1885 bool SuperWord::same_velt_type(Node* n1, Node* n2) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1886 const Type* vt1 = velt_type(n1); |
6794 | 1887 const Type* vt2 = velt_type(n2); |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1888 if (vt1->basic_type() == T_INT && vt2->basic_type() == T_INT) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1889 // Compare vectors element sizes for integer types. |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1890 return data_size(n1) == data_size(n2); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1891 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1892 return vt1 == vt2; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1893 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1894 |
0 | 1895 //------------------------------in_packset--------------------------- |
1896 // Are s1 and s2 in a pack pair and ordered as s1,s2? | |
1897 bool SuperWord::in_packset(Node* s1, Node* s2) { | |
1898 for (int i = 0; i < _packset.length(); i++) { | |
1899 Node_List* p = _packset.at(i); | |
1900 assert(p->size() == 2, "must be"); | |
1901 if (p->at(0) == s1 && p->at(p->size()-1) == s2) { | |
1902 return true; | |
1903 } | |
1904 } | |
1905 return false; | |
1906 } | |
1907 | |
1908 //------------------------------in_pack--------------------------- | |
1909 // Is s in pack p? | |
1910 Node_List* SuperWord::in_pack(Node* s, Node_List* p) { | |
1911 for (uint i = 0; i < p->size(); i++) { | |
1912 if (p->at(i) == s) { | |
1913 return p; | |
1914 } | |
1915 } | |
1916 return NULL; | |
1917 } | |
1918 | |
1919 //------------------------------remove_pack_at--------------------------- | |
1920 // Remove the pack at position pos in the packset | |
1921 void SuperWord::remove_pack_at(int pos) { | |
1922 Node_List* p = _packset.at(pos); | |
1923 for (uint i = 0; i < p->size(); i++) { | |
1924 Node* s = p->at(i); | |
1925 set_my_pack(s, NULL); | |
1926 } | |
1927 _packset.remove_at(pos); | |
1928 } | |
1929 | |
1930 //------------------------------executed_first--------------------------- | |
1931 // Return the node executed first in pack p. Uses the RPO block list | |
1932 // to determine order. | |
1933 Node* SuperWord::executed_first(Node_List* p) { | |
1934 Node* n = p->at(0); | |
1935 int n_rpo = bb_idx(n); | |
1936 for (uint i = 1; i < p->size(); i++) { | |
1937 Node* s = p->at(i); | |
1938 int s_rpo = bb_idx(s); | |
1939 if (s_rpo < n_rpo) { | |
1940 n = s; | |
1941 n_rpo = s_rpo; | |
1942 } | |
1943 } | |
1944 return n; | |
1945 } | |
1946 | |
1947 //------------------------------executed_last--------------------------- | |
1948 // Return the node executed last in pack p. | |
1949 Node* SuperWord::executed_last(Node_List* p) { | |
1950 Node* n = p->at(0); | |
1951 int n_rpo = bb_idx(n); | |
1952 for (uint i = 1; i < p->size(); i++) { | |
1953 Node* s = p->at(i); | |
1954 int s_rpo = bb_idx(s); | |
1955 if (s_rpo > n_rpo) { | |
1956 n = s; | |
1957 n_rpo = s_rpo; | |
1958 } | |
1959 } | |
1960 return n; | |
1961 } | |
1962 | |
1963 //----------------------------align_initial_loop_index--------------------------- | |
1964 // Adjust pre-loop limit so that in main loop, a load/store reference | |
1965 // to align_to_ref will be a position zero in the vector. | |
1966 // (iv + k) mod vector_align == 0 | |
1967 void SuperWord::align_initial_loop_index(MemNode* align_to_ref) { | |
1968 CountedLoopNode *main_head = lp()->as_CountedLoop(); | |
1969 assert(main_head->is_main_loop(), ""); | |
1970 CountedLoopEndNode* pre_end = get_pre_loop_end(main_head); | |
1971 assert(pre_end != NULL, ""); | |
1972 Node *pre_opaq1 = pre_end->limit(); | |
1973 assert(pre_opaq1->Opcode() == Op_Opaque1, ""); | |
1974 Opaque1Node *pre_opaq = (Opaque1Node*)pre_opaq1; | |
72
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
1975 Node *lim0 = pre_opaq->in(1); |
0 | 1976 |
1977 // Where we put new limit calculations | |
1978 Node *pre_ctrl = pre_end->loopnode()->in(LoopNode::EntryControl); | |
1979 | |
1980 // Ensure the original loop limit is available from the | |
1981 // pre-loop Opaque1 node. | |
1982 Node *orig_limit = pre_opaq->original_loop_limit(); | |
1983 assert(orig_limit != NULL && _igvn.type(orig_limit) != Type::TOP, ""); | |
1984 | |
1985 SWPointer align_to_ref_p(align_to_ref, this); | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
1986 assert(align_to_ref_p.valid(), "sanity"); |
0 | 1987 |
72
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
1988 // Given: |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
1989 // lim0 == original pre loop limit |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
1990 // V == v_align (power of 2) |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
1991 // invar == extra invariant piece of the address expression |
6614
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
1992 // e == offset [ +/- invar ] |
72
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
1993 // |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
1994 // When reassociating expressions involving '%' the basic rules are: |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
1995 // (a - b) % k == 0 => a % k == b % k |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
1996 // and: |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
1997 // (a + b) % k == 0 => a % k == (k - b) % k |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
1998 // |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
1999 // For stride > 0 && scale > 0, |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2000 // Derive the new pre-loop limit "lim" such that the two constraints: |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2001 // (1) lim = lim0 + N (where N is some positive integer < V) |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2002 // (2) (e + lim) % V == 0 |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2003 // are true. |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2004 // |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2005 // Substituting (1) into (2), |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2006 // (e + lim0 + N) % V == 0 |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2007 // solve for N: |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2008 // N = (V - (e + lim0)) % V |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2009 // substitute back into (1), so that new limit |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2010 // lim = lim0 + (V - (e + lim0)) % V |
0 | 2011 // |
72
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2012 // For stride > 0 && scale < 0 |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2013 // Constraints: |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2014 // lim = lim0 + N |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2015 // (e - lim) % V == 0 |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2016 // Solving for lim: |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2017 // (e - lim0 - N) % V == 0 |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2018 // N = (e - lim0) % V |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2019 // lim = lim0 + (e - lim0) % V |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2020 // |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2021 // For stride < 0 && scale > 0 |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2022 // Constraints: |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2023 // lim = lim0 - N |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2024 // (e + lim) % V == 0 |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2025 // Solving for lim: |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2026 // (e + lim0 - N) % V == 0 |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2027 // N = (e + lim0) % V |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2028 // lim = lim0 - (e + lim0) % V |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2029 // |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2030 // For stride < 0 && scale < 0 |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2031 // Constraints: |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2032 // lim = lim0 - N |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2033 // (e - lim) % V == 0 |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2034 // Solving for lim: |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2035 // (e - lim0 + N) % V == 0 |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2036 // N = (V - (e - lim0)) % V |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2037 // lim = lim0 - (V - (e - lim0)) % V |
0 | 2038 |
6183
6f8f439e247d
7177923: SIGBUS on sparc in compiled code for java.util.Calendar.clear()
kvn
parents:
6179
diff
changeset
|
2039 int vw = vector_width_in_bytes(align_to_ref); |
72
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2040 int stride = iv_stride(); |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2041 int scale = align_to_ref_p.scale_in_bytes(); |
0 | 2042 int elt_size = align_to_ref_p.memory_size(); |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
2043 int v_align = vw / elt_size; |
6183
6f8f439e247d
7177923: SIGBUS on sparc in compiled code for java.util.Calendar.clear()
kvn
parents:
6179
diff
changeset
|
2044 assert(v_align > 1, "sanity"); |
6614
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
2045 int offset = align_to_ref_p.offset_in_bytes() / elt_size; |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
2046 Node *offsn = _igvn.intcon(offset); |
72
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2047 |
6614
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
2048 Node *e = offsn; |
0 | 2049 if (align_to_ref_p.invar() != NULL) { |
6614
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
2050 // incorporate any extra invariant piece producing (offset +/- invar) >>> log2(elt) |
0 | 2051 Node* log2_elt = _igvn.intcon(exact_log2(elt_size)); |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6803
diff
changeset
|
2052 Node* aref = new (_phase->C) URShiftINode(align_to_ref_p.invar(), log2_elt); |
6803 | 2053 _igvn.register_new_node_with_optimizer(aref); |
0 | 2054 _phase->set_ctrl(aref, pre_ctrl); |
72
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2055 if (align_to_ref_p.negate_invar()) { |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6803
diff
changeset
|
2056 e = new (_phase->C) SubINode(e, aref); |
0 | 2057 } else { |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6803
diff
changeset
|
2058 e = new (_phase->C) AddINode(e, aref); |
0 | 2059 } |
6803 | 2060 _igvn.register_new_node_with_optimizer(e); |
72
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2061 _phase->set_ctrl(e, pre_ctrl); |
0 | 2062 } |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
2063 if (vw > ObjectAlignmentInBytes) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
2064 // incorporate base e +/- base && Mask >>> log2(elt) |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6803
diff
changeset
|
2065 Node* xbase = new(_phase->C) CastP2XNode(NULL, align_to_ref_p.base()); |
6803 | 2066 _igvn.register_new_node_with_optimizer(xbase); |
6614
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
2067 #ifdef _LP64 |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6803
diff
changeset
|
2068 xbase = new (_phase->C) ConvL2INode(xbase); |
6803 | 2069 _igvn.register_new_node_with_optimizer(xbase); |
6614
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
2070 #endif |
006050192a5a
6340864: Implement vectorization optimizations in hotspot-server
kvn
parents:
6183
diff
changeset
|
2071 Node* mask = _igvn.intcon(vw-1); |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6803
diff
changeset
|
2072 Node* masked_xbase = new (_phase->C) AndINode(xbase, mask); |
6803 | 2073 _igvn.register_new_node_with_optimizer(masked_xbase); |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
2074 Node* log2_elt = _igvn.intcon(exact_log2(elt_size)); |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6803
diff
changeset
|
2075 Node* bref = new (_phase->C) URShiftINode(masked_xbase, log2_elt); |
6803 | 2076 _igvn.register_new_node_with_optimizer(bref); |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
2077 _phase->set_ctrl(bref, pre_ctrl); |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6803
diff
changeset
|
2078 e = new (_phase->C) AddINode(e, bref); |
6803 | 2079 _igvn.register_new_node_with_optimizer(e); |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
2080 _phase->set_ctrl(e, pre_ctrl); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6144
diff
changeset
|
2081 } |
72
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2082 |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2083 // compute e +/- lim0 |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2084 if (scale < 0) { |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6803
diff
changeset
|
2085 e = new (_phase->C) SubINode(e, lim0); |
72
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2086 } else { |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6803
diff
changeset
|
2087 e = new (_phase->C) AddINode(e, lim0); |
72
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2088 } |
6803 | 2089 _igvn.register_new_node_with_optimizer(e); |
72
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2090 _phase->set_ctrl(e, pre_ctrl); |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2091 |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2092 if (stride * scale > 0) { |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2093 // compute V - (e +/- lim0) |
0 | 2094 Node* va = _igvn.intcon(v_align); |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6803
diff
changeset
|
2095 e = new (_phase->C) SubINode(va, e); |
6803 | 2096 _igvn.register_new_node_with_optimizer(e); |
72
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2097 _phase->set_ctrl(e, pre_ctrl); |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2098 } |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2099 // compute N = (exp) % V |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2100 Node* va_msk = _igvn.intcon(v_align - 1); |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6803
diff
changeset
|
2101 Node* N = new (_phase->C) AndINode(e, va_msk); |
6803 | 2102 _igvn.register_new_node_with_optimizer(N); |
72
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2103 _phase->set_ctrl(N, pre_ctrl); |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2104 |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2105 // substitute back into (1), so that new limit |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2106 // lim = lim0 + N |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2107 Node* lim; |
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2108 if (stride < 0) { |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6803
diff
changeset
|
2109 lim = new (_phase->C) SubINode(lim0, N); |
0 | 2110 } else { |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6803
diff
changeset
|
2111 lim = new (_phase->C) AddINode(lim0, N); |
0 | 2112 } |
6803 | 2113 _igvn.register_new_node_with_optimizer(lim); |
72
f705f25597eb
6663621: JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
never
parents:
29
diff
changeset
|
2114 _phase->set_ctrl(lim, pre_ctrl); |
0 | 2115 Node* constrained = |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6803
diff
changeset
|
2116 (stride > 0) ? (Node*) new (_phase->C) MinINode(lim, orig_limit) |
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6803
diff
changeset
|
2117 : (Node*) new (_phase->C) MaxINode(lim, orig_limit); |
6803 | 2118 _igvn.register_new_node_with_optimizer(constrained); |
0 | 2119 _phase->set_ctrl(constrained, pre_ctrl); |
2120 _igvn.hash_delete(pre_opaq); | |
2121 pre_opaq->set_req(1, constrained); | |
2122 } | |
2123 | |
2124 //----------------------------get_pre_loop_end--------------------------- | |
2125 // Find pre loop end from main loop. Returns null if none. | |
2126 CountedLoopEndNode* SuperWord::get_pre_loop_end(CountedLoopNode *cl) { | |
2127 Node *ctrl = cl->in(LoopNode::EntryControl); | |
2128 if (!ctrl->is_IfTrue() && !ctrl->is_IfFalse()) return NULL; | |
2129 Node *iffm = ctrl->in(0); | |
2130 if (!iffm->is_If()) return NULL; | |
2131 Node *p_f = iffm->in(0); | |
2132 if (!p_f->is_IfFalse()) return NULL; | |
2133 if (!p_f->in(0)->is_CountedLoopEnd()) return NULL; | |
2134 CountedLoopEndNode *pre_end = p_f->in(0)->as_CountedLoopEnd(); | |
2135 if (!pre_end->loopnode()->is_pre_loop()) return NULL; | |
2136 return pre_end; | |
2137 } | |
2138 | |
2139 | |
2140 //------------------------------init--------------------------- | |
2141 void SuperWord::init() { | |
2142 _dg.init(); | |
2143 _packset.clear(); | |
2144 _disjoint_ptrs.clear(); | |
2145 _block.clear(); | |
2146 _data_entry.clear(); | |
2147 _mem_slice_head.clear(); | |
2148 _mem_slice_tail.clear(); | |
2149 _node_info.clear(); | |
2150 _align_to_ref = NULL; | |
2151 _lpt = NULL; | |
2152 _lp = NULL; | |
2153 _bb = NULL; | |
2154 _iv = NULL; | |
2155 } | |
2156 | |
2157 //------------------------------print_packset--------------------------- | |
2158 void SuperWord::print_packset() { | |
2159 #ifndef PRODUCT | |
2160 tty->print_cr("packset"); | |
2161 for (int i = 0; i < _packset.length(); i++) { | |
2162 tty->print_cr("Pack: %d", i); | |
2163 Node_List* p = _packset.at(i); | |
2164 print_pack(p); | |
2165 } | |
2166 #endif | |
2167 } | |
2168 | |
2169 //------------------------------print_pack--------------------------- | |
2170 void SuperWord::print_pack(Node_List* p) { | |
2171 for (uint i = 0; i < p->size(); i++) { | |
2172 print_stmt(p->at(i)); | |
2173 } | |
2174 } | |
2175 | |
2176 //------------------------------print_bb--------------------------- | |
2177 void SuperWord::print_bb() { | |
2178 #ifndef PRODUCT | |
2179 tty->print_cr("\nBlock"); | |
2180 for (int i = 0; i < _block.length(); i++) { | |
2181 Node* n = _block.at(i); | |
2182 tty->print("%d ", i); | |
2183 if (n) { | |
2184 n->dump(); | |
2185 } | |
2186 } | |
2187 #endif | |
2188 } | |
2189 | |
2190 //------------------------------print_stmt--------------------------- | |
2191 void SuperWord::print_stmt(Node* s) { | |
2192 #ifndef PRODUCT | |
2193 tty->print(" align: %d \t", alignment(s)); | |
2194 s->dump(); | |
2195 #endif | |
2196 } | |
2197 | |
2198 //------------------------------blank--------------------------- | |
2199 char* SuperWord::blank(uint depth) { | |
2200 static char blanks[101]; | |
2201 assert(depth < 101, "too deep"); | |
2202 for (uint i = 0; i < depth; i++) blanks[i] = ' '; | |
2203 blanks[depth] = '\0'; | |
2204 return blanks; | |
2205 } | |
2206 | |
2207 | |
2208 //==============================SWPointer=========================== | |
2209 | |
2210 //----------------------------SWPointer------------------------ | |
2211 SWPointer::SWPointer(MemNode* mem, SuperWord* slp) : | |
2212 _mem(mem), _slp(slp), _base(NULL), _adr(NULL), | |
2213 _scale(0), _offset(0), _invar(NULL), _negate_invar(false) { | |
2214 | |
2215 Node* adr = mem->in(MemNode::Address); | |
2216 if (!adr->is_AddP()) { | |
2217 assert(!valid(), "too complex"); | |
2218 return; | |
2219 } | |
2220 // Match AddP(base, AddP(ptr, k*iv [+ invariant]), constant) | |
2221 Node* base = adr->in(AddPNode::Base); | |
1058
73a726751507
6852078: HSX 14/16 in jdk 5.0: api/javax_management api/org_omg jck tests crashes or make tnameserv crash
cfang
parents:
987
diff
changeset
|
2222 //unsafe reference could not be aligned appropriately without runtime checking |
73a726751507
6852078: HSX 14/16 in jdk 5.0: api/javax_management api/org_omg jck tests crashes or make tnameserv crash
cfang
parents:
987
diff
changeset
|
2223 if (base == NULL || base->bottom_type() == Type::TOP) { |
73a726751507
6852078: HSX 14/16 in jdk 5.0: api/javax_management api/org_omg jck tests crashes or make tnameserv crash
cfang
parents:
987
diff
changeset
|
2224 assert(!valid(), "unsafe access"); |
73a726751507
6852078: HSX 14/16 in jdk 5.0: api/javax_management api/org_omg jck tests crashes or make tnameserv crash
cfang
parents:
987
diff
changeset
|
2225 return; |
73a726751507
6852078: HSX 14/16 in jdk 5.0: api/javax_management api/org_omg jck tests crashes or make tnameserv crash
cfang
parents:
987
diff
changeset
|
2226 } |
0 | 2227 for (int i = 0; i < 3; i++) { |
2228 if (!scaled_iv_plus_offset(adr->in(AddPNode::Offset))) { | |
2229 assert(!valid(), "too complex"); | |
2230 return; | |
2231 } | |
2232 adr = adr->in(AddPNode::Address); | |
2233 if (base == adr || !adr->is_AddP()) { | |
2234 break; // stop looking at addp's | |
2235 } | |
2236 } | |
2237 _base = base; | |
2238 _adr = adr; | |
2239 assert(valid(), "Usable"); | |
2240 } | |
2241 | |
2242 // Following is used to create a temporary object during | |
2243 // the pattern match of an address expression. | |
2244 SWPointer::SWPointer(SWPointer* p) : | |
2245 _mem(p->_mem), _slp(p->_slp), _base(NULL), _adr(NULL), | |
2246 _scale(0), _offset(0), _invar(NULL), _negate_invar(false) {} | |
2247 | |
2248 //------------------------scaled_iv_plus_offset-------------------- | |
2249 // Match: k*iv + offset | |
2250 // where: k is a constant that maybe zero, and | |
2251 // offset is (k2 [+/- invariant]) where k2 maybe zero and invariant is optional | |
2252 bool SWPointer::scaled_iv_plus_offset(Node* n) { | |
2253 if (scaled_iv(n)) { | |
2254 return true; | |
2255 } | |
2256 if (offset_plus_k(n)) { | |
2257 return true; | |
2258 } | |
2259 int opc = n->Opcode(); | |
2260 if (opc == Op_AddI) { | |
2261 if (scaled_iv(n->in(1)) && offset_plus_k(n->in(2))) { | |
2262 return true; | |
2263 } | |
2264 if (scaled_iv(n->in(2)) && offset_plus_k(n->in(1))) { | |
2265 return true; | |
2266 } | |
2267 } else if (opc == Op_SubI) { | |
2268 if (scaled_iv(n->in(1)) && offset_plus_k(n->in(2), true)) { | |
2269 return true; | |
2270 } | |
2271 if (scaled_iv(n->in(2)) && offset_plus_k(n->in(1))) { | |
2272 _scale *= -1; | |
2273 return true; | |
2274 } | |
2275 } | |
2276 return false; | |
2277 } | |
2278 | |
2279 //----------------------------scaled_iv------------------------ | |
2280 // Match: k*iv where k is a constant that's not zero | |
2281 bool SWPointer::scaled_iv(Node* n) { | |
2282 if (_scale != 0) { | |
2283 return false; // already found a scale | |
2284 } | |
2285 if (n == iv()) { | |
2286 _scale = 1; | |
2287 return true; | |
2288 } | |
2289 int opc = n->Opcode(); | |
2290 if (opc == Op_MulI) { | |
2291 if (n->in(1) == iv() && n->in(2)->is_Con()) { | |
2292 _scale = n->in(2)->get_int(); | |
2293 return true; | |
2294 } else if (n->in(2) == iv() && n->in(1)->is_Con()) { | |
2295 _scale = n->in(1)->get_int(); | |
2296 return true; | |
2297 } | |
2298 } else if (opc == Op_LShiftI) { | |
2299 if (n->in(1) == iv() && n->in(2)->is_Con()) { | |
2300 _scale = 1 << n->in(2)->get_int(); | |
2301 return true; | |
2302 } | |
2303 } else if (opc == Op_ConvI2L) { | |
2304 if (scaled_iv_plus_offset(n->in(1))) { | |
2305 return true; | |
2306 } | |
2307 } else if (opc == Op_LShiftL) { | |
2308 if (!has_iv() && _invar == NULL) { | |
2309 // Need to preserve the current _offset value, so | |
2310 // create a temporary object for this expression subtree. | |
2311 // Hacky, so should re-engineer the address pattern match. | |
2312 SWPointer tmp(this); | |
2313 if (tmp.scaled_iv_plus_offset(n->in(1))) { | |
2314 if (tmp._invar == NULL) { | |
2315 int mult = 1 << n->in(2)->get_int(); | |
2316 _scale = tmp._scale * mult; | |
2317 _offset += tmp._offset * mult; | |
2318 return true; | |
2319 } | |
2320 } | |
2321 } | |
2322 } | |
2323 return false; | |
2324 } | |
2325 | |
2326 //----------------------------offset_plus_k------------------------ | |
2327 // Match: offset is (k [+/- invariant]) | |
2328 // where k maybe zero and invariant is optional, but not both. | |
2329 bool SWPointer::offset_plus_k(Node* n, bool negate) { | |
2330 int opc = n->Opcode(); | |
2331 if (opc == Op_ConI) { | |
2332 _offset += negate ? -(n->get_int()) : n->get_int(); | |
2333 return true; | |
2334 } else if (opc == Op_ConL) { | |
2335 // Okay if value fits into an int | |
2336 const TypeLong* t = n->find_long_type(); | |
2337 if (t->higher_equal(TypeLong::INT)) { | |
2338 jlong loff = n->get_long(); | |
2339 jint off = (jint)loff; | |
2340 _offset += negate ? -off : loff; | |
2341 return true; | |
2342 } | |
2343 return false; | |
2344 } | |
2345 if (_invar != NULL) return false; // already have an invariant | |
2346 if (opc == Op_AddI) { | |
2347 if (n->in(2)->is_Con() && invariant(n->in(1))) { | |
2348 _negate_invar = negate; | |
2349 _invar = n->in(1); | |
2350 _offset += negate ? -(n->in(2)->get_int()) : n->in(2)->get_int(); | |
2351 return true; | |
2352 } else if (n->in(1)->is_Con() && invariant(n->in(2))) { | |
2353 _offset += negate ? -(n->in(1)->get_int()) : n->in(1)->get_int(); | |
2354 _negate_invar = negate; | |
2355 _invar = n->in(2); | |
2356 return true; | |
2357 } | |
2358 } | |
2359 if (opc == Op_SubI) { | |
2360 if (n->in(2)->is_Con() && invariant(n->in(1))) { | |
2361 _negate_invar = negate; | |
2362 _invar = n->in(1); | |
2363 _offset += !negate ? -(n->in(2)->get_int()) : n->in(2)->get_int(); | |
2364 return true; | |
2365 } else if (n->in(1)->is_Con() && invariant(n->in(2))) { | |
2366 _offset += negate ? -(n->in(1)->get_int()) : n->in(1)->get_int(); | |
2367 _negate_invar = !negate; | |
2368 _invar = n->in(2); | |
2369 return true; | |
2370 } | |
2371 } | |
2372 if (invariant(n)) { | |
2373 _negate_invar = negate; | |
2374 _invar = n; | |
2375 return true; | |
2376 } | |
2377 return false; | |
2378 } | |
2379 | |
2380 //----------------------------print------------------------ | |
2381 void SWPointer::print() { | |
2382 #ifndef PRODUCT | |
2383 tty->print("base: %d adr: %d scale: %d offset: %d invar: %c%d\n", | |
2384 _base != NULL ? _base->_idx : 0, | |
2385 _adr != NULL ? _adr->_idx : 0, | |
2386 _scale, _offset, | |
2387 _negate_invar?'-':'+', | |
2388 _invar != NULL ? _invar->_idx : 0); | |
2389 #endif | |
2390 } | |
2391 | |
2392 // ========================= OrderedPair ===================== | |
2393 | |
2394 const OrderedPair OrderedPair::initial; | |
2395 | |
2396 // ========================= SWNodeInfo ===================== | |
2397 | |
2398 const SWNodeInfo SWNodeInfo::initial; | |
2399 | |
2400 | |
2401 // ============================ DepGraph =========================== | |
2402 | |
2403 //------------------------------make_node--------------------------- | |
2404 // Make a new dependence graph node for an ideal node. | |
2405 DepMem* DepGraph::make_node(Node* node) { | |
2406 DepMem* m = new (_arena) DepMem(node); | |
2407 if (node != NULL) { | |
2408 assert(_map.at_grow(node->_idx) == NULL, "one init only"); | |
2409 _map.at_put_grow(node->_idx, m); | |
2410 } | |
2411 return m; | |
2412 } | |
2413 | |
2414 //------------------------------make_edge--------------------------- | |
2415 // Make a new dependence graph edge from dpred -> dsucc | |
2416 DepEdge* DepGraph::make_edge(DepMem* dpred, DepMem* dsucc) { | |
2417 DepEdge* e = new (_arena) DepEdge(dpred, dsucc, dsucc->in_head(), dpred->out_head()); | |
2418 dpred->set_out_head(e); | |
2419 dsucc->set_in_head(e); | |
2420 return e; | |
2421 } | |
2422 | |
2423 // ========================== DepMem ======================== | |
2424 | |
2425 //------------------------------in_cnt--------------------------- | |
2426 int DepMem::in_cnt() { | |
2427 int ct = 0; | |
2428 for (DepEdge* e = _in_head; e != NULL; e = e->next_in()) ct++; | |
2429 return ct; | |
2430 } | |
2431 | |
2432 //------------------------------out_cnt--------------------------- | |
2433 int DepMem::out_cnt() { | |
2434 int ct = 0; | |
2435 for (DepEdge* e = _out_head; e != NULL; e = e->next_out()) ct++; | |
2436 return ct; | |
2437 } | |
2438 | |
2439 //------------------------------print----------------------------- | |
2440 void DepMem::print() { | |
2441 #ifndef PRODUCT | |
2442 tty->print(" DepNode %d (", _node->_idx); | |
2443 for (DepEdge* p = _in_head; p != NULL; p = p->next_in()) { | |
2444 Node* pred = p->pred()->node(); | |
2445 tty->print(" %d", pred != NULL ? pred->_idx : 0); | |
2446 } | |
2447 tty->print(") ["); | |
2448 for (DepEdge* s = _out_head; s != NULL; s = s->next_out()) { | |
2449 Node* succ = s->succ()->node(); | |
2450 tty->print(" %d", succ != NULL ? succ->_idx : 0); | |
2451 } | |
2452 tty->print_cr(" ]"); | |
2453 #endif | |
2454 } | |
2455 | |
2456 // =========================== DepEdge ========================= | |
2457 | |
2458 //------------------------------DepPreds--------------------------- | |
2459 void DepEdge::print() { | |
2460 #ifndef PRODUCT | |
2461 tty->print_cr("DepEdge: %d [ %d ]", _pred->node()->_idx, _succ->node()->_idx); | |
2462 #endif | |
2463 } | |
2464 | |
2465 // =========================== DepPreds ========================= | |
2466 // Iterator over predecessor edges in the dependence graph. | |
2467 | |
2468 //------------------------------DepPreds--------------------------- | |
2469 DepPreds::DepPreds(Node* n, DepGraph& dg) { | |
2470 _n = n; | |
2471 _done = false; | |
2472 if (_n->is_Store() || _n->is_Load()) { | |
2473 _next_idx = MemNode::Address; | |
2474 _end_idx = n->req(); | |
2475 _dep_next = dg.dep(_n)->in_head(); | |
2476 } else if (_n->is_Mem()) { | |
2477 _next_idx = 0; | |
2478 _end_idx = 0; | |
2479 _dep_next = dg.dep(_n)->in_head(); | |
2480 } else { | |
2481 _next_idx = 1; | |
2482 _end_idx = _n->req(); | |
2483 _dep_next = NULL; | |
2484 } | |
2485 next(); | |
2486 } | |
2487 | |
2488 //------------------------------next--------------------------- | |
2489 void DepPreds::next() { | |
2490 if (_dep_next != NULL) { | |
2491 _current = _dep_next->pred()->node(); | |
2492 _dep_next = _dep_next->next_in(); | |
2493 } else if (_next_idx < _end_idx) { | |
2494 _current = _n->in(_next_idx++); | |
2495 } else { | |
2496 _done = true; | |
2497 } | |
2498 } | |
2499 | |
2500 // =========================== DepSuccs ========================= | |
2501 // Iterator over successor edges in the dependence graph. | |
2502 | |
2503 //------------------------------DepSuccs--------------------------- | |
2504 DepSuccs::DepSuccs(Node* n, DepGraph& dg) { | |
2505 _n = n; | |
2506 _done = false; | |
2507 if (_n->is_Load()) { | |
2508 _next_idx = 0; | |
2509 _end_idx = _n->outcnt(); | |
2510 _dep_next = dg.dep(_n)->out_head(); | |
2511 } else if (_n->is_Mem() || _n->is_Phi() && _n->bottom_type() == Type::MEMORY) { | |
2512 _next_idx = 0; | |
2513 _end_idx = 0; | |
2514 _dep_next = dg.dep(_n)->out_head(); | |
2515 } else { | |
2516 _next_idx = 0; | |
2517 _end_idx = _n->outcnt(); | |
2518 _dep_next = NULL; | |
2519 } | |
2520 next(); | |
2521 } | |
2522 | |
2523 //-------------------------------next--------------------------- | |
2524 void DepSuccs::next() { | |
2525 if (_dep_next != NULL) { | |
2526 _current = _dep_next->succ()->node(); | |
2527 _dep_next = _dep_next->next_out(); | |
2528 } else if (_next_idx < _end_idx) { | |
2529 _current = _n->raw_out(_next_idx++); | |
2530 } else { | |
2531 _done = true; | |
2532 } | |
2533 } |