annotate src/share/vm/opto/reg_split.cpp @ 12872:98692a2d36d7

8013830: [parfait] Uninitialised pointer 'Reachblock' may be used as argument Summary: Replace uninitialised pointer with NULL at argument. Reviewed-by: kvn, roland, twisti
author adlertz
date Wed, 09 Oct 2013 13:00:20 +0200
parents 650868c062a9
children 1856ea98184a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 3842
diff changeset
2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 628
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 628
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: 628
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1730
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1730
diff changeset
26 #include "libadt/vectset.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1730
diff changeset
27 #include "memory/allocation.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1730
diff changeset
28 #include "opto/addnode.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1730
diff changeset
29 #include "opto/c2compiler.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1730
diff changeset
30 #include "opto/callnode.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1730
diff changeset
31 #include "opto/cfgnode.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1730
diff changeset
32 #include "opto/chaitin.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1730
diff changeset
33 #include "opto/loopnode.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1730
diff changeset
34 #include "opto/machnode.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
35
a61af66fc99e Initial load
duke
parents:
diff changeset
36 //------------------------------Split--------------------------------------
605
98cb887364d3 6810672: Comment typos
twisti
parents: 566
diff changeset
37 // Walk the graph in RPO and for each lrg which spills, propagate reaching
98cb887364d3 6810672: Comment typos
twisti
parents: 566
diff changeset
38 // definitions. During propagation, split the live range around regions of
0
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // High Register Pressure (HRP). If a Def is in a region of Low Register
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // Pressure (LRP), it will not get spilled until we encounter a region of
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // HRP between it and one of its uses. We will spill at the transition
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // point between LRP and HRP. Uses in the HRP region will use the spilled
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // Def. The first Use outside the HRP region will generate a SpillCopy to
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // hoist the live range back up into a register, and all subsequent uses
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // will use that new Def until another HRP region is encountered. Defs in
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // HRP regions will get trailing SpillCopies to push the LRG down into the
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // stack immediately.
a61af66fc99e Initial load
duke
parents:
diff changeset
48 //
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // As a side effect, unlink from (hence make dead) coalesced copies.
a61af66fc99e Initial load
duke
parents:
diff changeset
50 //
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 static const char out_of_nodes[] = "out of nodes during split";
a61af66fc99e Initial load
duke
parents:
diff changeset
53
10395
b274ac1dbe11 8005956: C2: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG defined in this block
adlertz
parents: 10111
diff changeset
54 static bool contains_no_live_range_input(const Node* def) {
b274ac1dbe11 8005956: C2: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG defined in this block
adlertz
parents: 10111
diff changeset
55 for (uint i = 1; i < def->req(); ++i) {
b274ac1dbe11 8005956: C2: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG defined in this block
adlertz
parents: 10111
diff changeset
56 if (def->in(i) != NULL && def->in_RegMask(i).is_NotEmpty()) {
b274ac1dbe11 8005956: C2: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG defined in this block
adlertz
parents: 10111
diff changeset
57 return false;
b274ac1dbe11 8005956: C2: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG defined in this block
adlertz
parents: 10111
diff changeset
58 }
b274ac1dbe11 8005956: C2: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG defined in this block
adlertz
parents: 10111
diff changeset
59 }
b274ac1dbe11 8005956: C2: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG defined in this block
adlertz
parents: 10111
diff changeset
60 return true;
b274ac1dbe11 8005956: C2: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG defined in this block
adlertz
parents: 10111
diff changeset
61 }
b274ac1dbe11 8005956: C2: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG defined in this block
adlertz
parents: 10111
diff changeset
62
0
a61af66fc99e Initial load
duke
parents:
diff changeset
63 //------------------------------get_spillcopy_wide-----------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // Get a SpillCopy node with wide-enough masks. Use the 'wide-mask', the
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // wide ideal-register spill-mask if possible. If the 'wide-mask' does
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // not cover the input (or output), use the input (or output) mask instead.
a61af66fc99e Initial load
duke
parents:
diff changeset
67 Node *PhaseChaitin::get_spillcopy_wide( Node *def, Node *use, uint uidx ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // If ideal reg doesn't exist we've got a bad schedule happening
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // that is forcing us to spill something that isn't spillable.
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // Bail rather than abort
a61af66fc99e Initial load
duke
parents:
diff changeset
71 int ireg = def->ideal_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
72 if( ireg == 0 || ireg == Op_RegFlags ) {
415
4d9884b01ba6 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 337
diff changeset
73 assert(false, "attempted to spill a non-spillable item");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
74 C->record_method_not_compilable("attempted to spill a non-spillable item");
a61af66fc99e Initial load
duke
parents:
diff changeset
75 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
76 }
a61af66fc99e Initial load
duke
parents:
diff changeset
77 if (C->check_node_count(NodeLimitFudgeFactor, out_of_nodes)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
78 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
79 }
a61af66fc99e Initial load
duke
parents:
diff changeset
80 const RegMask *i_mask = &def->out_RegMask();
a61af66fc99e Initial load
duke
parents:
diff changeset
81 const RegMask *w_mask = C->matcher()->idealreg2spillmask[ireg];
a61af66fc99e Initial load
duke
parents:
diff changeset
82 const RegMask *o_mask = use ? &use->in_RegMask(uidx) : w_mask;
a61af66fc99e Initial load
duke
parents:
diff changeset
83 const RegMask *w_i_mask = w_mask->overlap( *i_mask ) ? w_mask : i_mask;
a61af66fc99e Initial load
duke
parents:
diff changeset
84 const RegMask *w_o_mask;
a61af66fc99e Initial load
duke
parents:
diff changeset
85
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 3842
diff changeset
86 int num_regs = RegMask::num_registers(ireg);
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 3842
diff changeset
87 bool is_vect = RegMask::is_vector(ireg);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
88 if( w_mask->overlap( *o_mask ) && // Overlap AND
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 3842
diff changeset
89 ((num_regs == 1) // Single use or aligned
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 3842
diff changeset
90 || is_vect // or vector
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 3842
diff changeset
91 || !is_vect && o_mask->is_aligned_pairs()) ) {
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 3842
diff changeset
92 assert(!is_vect || o_mask->is_aligned_sets(num_regs), "vectors are aligned");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // Don't come here for mis-aligned doubles
a61af66fc99e Initial load
duke
parents:
diff changeset
94 w_o_mask = w_mask;
a61af66fc99e Initial load
duke
parents:
diff changeset
95 } else { // wide ideal mask does not overlap with o_mask
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // Mis-aligned doubles come here and XMM->FPR moves on x86.
a61af66fc99e Initial load
duke
parents:
diff changeset
97 w_o_mask = o_mask; // Must target desired registers
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // Does the ideal-reg-mask overlap with o_mask? I.e., can I use
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // a reg-reg move or do I need a trip across register classes
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // (and thus through memory)?
a61af66fc99e Initial load
duke
parents:
diff changeset
101 if( !C->matcher()->idealreg2regmask[ireg]->overlap( *o_mask) && o_mask->is_UP() )
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // Here we assume a trip through memory is required.
a61af66fc99e Initial load
duke
parents:
diff changeset
103 w_i_mask = &C->FIRST_STACK_mask();
a61af66fc99e Initial load
duke
parents:
diff changeset
104 }
a61af66fc99e Initial load
duke
parents:
diff changeset
105 return new (C) MachSpillCopyNode( def, *w_i_mask, *w_o_mask );
a61af66fc99e Initial load
duke
parents:
diff changeset
106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 //------------------------------insert_proj------------------------------------
605
98cb887364d3 6810672: Comment typos
twisti
parents: 566
diff changeset
109 // Insert the spill at chosen location. Skip over any intervening Proj's or
0
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // Phis. Skip over a CatchNode and projs, inserting in the fall-through block
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // instead. Update high-pressure indices. Create a new live range.
a61af66fc99e Initial load
duke
parents:
diff changeset
112 void PhaseChaitin::insert_proj( Block *b, uint i, Node *spill, uint maxlrg ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // Skip intervening ProjNodes. Do not insert between a ProjNode and
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // its definer.
12167
650868c062a9 8023691: Create interface for nodes in class Block
adlertz
parents: 12075
diff changeset
115 while( i < b->number_of_nodes() &&
650868c062a9 8023691: Create interface for nodes in class Block
adlertz
parents: 12075
diff changeset
116 (b->get_node(i)->is_Proj() ||
650868c062a9 8023691: Create interface for nodes in class Block
adlertz
parents: 12075
diff changeset
117 b->get_node(i)->is_Phi() ) )
0
a61af66fc99e Initial load
duke
parents:
diff changeset
118 i++;
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // Do not insert between a call and his Catch
12167
650868c062a9 8023691: Create interface for nodes in class Block
adlertz
parents: 12075
diff changeset
121 if( b->get_node(i)->is_Catch() ) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // Put the instruction at the top of the fall-thru block.
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // Find the fall-thru projection
a61af66fc99e Initial load
duke
parents:
diff changeset
124 while( 1 ) {
12167
650868c062a9 8023691: Create interface for nodes in class Block
adlertz
parents: 12075
diff changeset
125 const CatchProjNode *cp = b->get_node(++i)->as_CatchProj();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
126 if( cp->_con == CatchProjNode::fall_through_index )
a61af66fc99e Initial load
duke
parents:
diff changeset
127 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
129 int sidx = i - b->end_idx()-1;
a61af66fc99e Initial load
duke
parents:
diff changeset
130 b = b->_succs[sidx]; // Switch to successor block
a61af66fc99e Initial load
duke
parents:
diff changeset
131 i = 1; // Right at start of block
a61af66fc99e Initial load
duke
parents:
diff changeset
132 }
a61af66fc99e Initial load
duke
parents:
diff changeset
133
12167
650868c062a9 8023691: Create interface for nodes in class Block
adlertz
parents: 12075
diff changeset
134 b->insert_node(spill, i); // Insert node in block
12023
d1034bd8cefc 8022284: Hide internal data structure in PhaseCFG
adlertz
parents: 10395
diff changeset
135 _cfg.map_node_to_block(spill, b); // Update node->block mapping to reflect
0
a61af66fc99e Initial load
duke
parents:
diff changeset
136 // Adjust the point where we go hi-pressure
a61af66fc99e Initial load
duke
parents:
diff changeset
137 if( i <= b->_ihrp_index ) b->_ihrp_index++;
a61af66fc99e Initial load
duke
parents:
diff changeset
138 if( i <= b->_fhrp_index ) b->_fhrp_index++;
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140 // Assign a new Live Range Number to the SpillCopy and grow
a61af66fc99e Initial load
duke
parents:
diff changeset
141 // the node->live range mapping.
a61af66fc99e Initial load
duke
parents:
diff changeset
142 new_lrg(spill,maxlrg);
a61af66fc99e Initial load
duke
parents:
diff changeset
143 }
a61af66fc99e Initial load
duke
parents:
diff changeset
144
a61af66fc99e Initial load
duke
parents:
diff changeset
145 //------------------------------split_DEF--------------------------------------
605
98cb887364d3 6810672: Comment typos
twisti
parents: 566
diff changeset
146 // There are four categories of Split; UP/DOWN x DEF/USE
0
a61af66fc99e Initial load
duke
parents:
diff changeset
147 // Only three of these really occur as DOWN/USE will always color
a61af66fc99e Initial load
duke
parents:
diff changeset
148 // Any Split with a DEF cannot CISC-Spill now. Thus we need
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // two helper routines, one for Split DEFS (insert after instruction),
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // one for Split USES (insert before instruction). DEF insertion
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // happens inside Split, where the Leaveblock array is updated.
a61af66fc99e Initial load
duke
parents:
diff changeset
152 uint PhaseChaitin::split_DEF( Node *def, Block *b, int loc, uint maxlrg, Node **Reachblock, Node **debug_defs, GrowableArray<uint> splits, int slidx ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
153 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
154 // Increment the counter for this lrg
a61af66fc99e Initial load
duke
parents:
diff changeset
155 splits.at_put(slidx, splits.at(slidx)+1);
a61af66fc99e Initial load
duke
parents:
diff changeset
156 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
157 // If we are spilling the memory op for an implicit null check, at the
a61af66fc99e Initial load
duke
parents:
diff changeset
158 // null check location (ie - null check is in HRP block) we need to do
a61af66fc99e Initial load
duke
parents:
diff changeset
159 // the null-check first, then spill-down in the following block.
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // (The implicit_null_check function ensures the use is also dominated
a61af66fc99e Initial load
duke
parents:
diff changeset
161 // by the branch-not-taken block.)
a61af66fc99e Initial load
duke
parents:
diff changeset
162 Node *be = b->end();
12167
650868c062a9 8023691: Create interface for nodes in class Block
adlertz
parents: 12075
diff changeset
163 if( be->is_MachNullCheck() && be->in(1) == def && def == b->get_node(loc)) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
164 // Spill goes in the branch-not-taken block
12167
650868c062a9 8023691: Create interface for nodes in class Block
adlertz
parents: 12075
diff changeset
165 b = b->_succs[b->get_node(b->end_idx()+1)->Opcode() == Op_IfTrue];
0
a61af66fc99e Initial load
duke
parents:
diff changeset
166 loc = 0; // Just past the Region
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168 assert( loc >= 0, "must insert past block head" );
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 // Get a def-side SpillCopy
a61af66fc99e Initial load
duke
parents:
diff changeset
171 Node *spill = get_spillcopy_wide(def,NULL,0);
a61af66fc99e Initial load
duke
parents:
diff changeset
172 // Did we fail to split?, then bail
a61af66fc99e Initial load
duke
parents:
diff changeset
173 if (!spill) {
a61af66fc99e Initial load
duke
parents:
diff changeset
174 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
175 }
a61af66fc99e Initial load
duke
parents:
diff changeset
176
a61af66fc99e Initial load
duke
parents:
diff changeset
177 // Insert the spill at chosen location
a61af66fc99e Initial load
duke
parents:
diff changeset
178 insert_proj( b, loc+1, spill, maxlrg++);
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180 // Insert new node into Reaches array
a61af66fc99e Initial load
duke
parents:
diff changeset
181 Reachblock[slidx] = spill;
a61af66fc99e Initial load
duke
parents:
diff changeset
182 // Update debug list of reaching down definitions by adding this one
a61af66fc99e Initial load
duke
parents:
diff changeset
183 debug_defs[slidx] = spill;
a61af66fc99e Initial load
duke
parents:
diff changeset
184
a61af66fc99e Initial load
duke
parents:
diff changeset
185 // return updated count of live ranges
a61af66fc99e Initial load
duke
parents:
diff changeset
186 return maxlrg;
a61af66fc99e Initial load
duke
parents:
diff changeset
187 }
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 //------------------------------split_USE--------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
190 // Splits at uses can involve redeffing the LRG, so no CISC Spilling there.
a61af66fc99e Initial load
duke
parents:
diff changeset
191 // Debug uses want to know if def is already stack enabled.
a61af66fc99e Initial load
duke
parents:
diff changeset
192 uint PhaseChaitin::split_USE( Node *def, Block *b, Node *use, uint useidx, uint maxlrg, bool def_down, bool cisc_sp, GrowableArray<uint> splits, int slidx ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
193 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
194 // Increment the counter for this lrg
a61af66fc99e Initial load
duke
parents:
diff changeset
195 splits.at_put(slidx, splits.at(slidx)+1);
a61af66fc99e Initial load
duke
parents:
diff changeset
196 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
197
a61af66fc99e Initial load
duke
parents:
diff changeset
198 // Some setup stuff for handling debug node uses
a61af66fc99e Initial load
duke
parents:
diff changeset
199 JVMState* jvms = use->jvms();
a61af66fc99e Initial load
duke
parents:
diff changeset
200 uint debug_start = jvms ? jvms->debug_start() : 999999;
a61af66fc99e Initial load
duke
parents:
diff changeset
201 uint debug_end = jvms ? jvms->debug_end() : 999999;
a61af66fc99e Initial load
duke
parents:
diff changeset
202
a61af66fc99e Initial load
duke
parents:
diff changeset
203 //-------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
204 // Check for use of debug info
a61af66fc99e Initial load
duke
parents:
diff changeset
205 if (useidx >= debug_start && useidx < debug_end) {
a61af66fc99e Initial load
duke
parents:
diff changeset
206 // Actually it's perfectly legal for constant debug info to appear
a61af66fc99e Initial load
duke
parents:
diff changeset
207 // just unlikely. In this case the optimizer left a ConI of a 4
a61af66fc99e Initial load
duke
parents:
diff changeset
208 // as both inputs to a Phi with only a debug use. It's a single-def
a61af66fc99e Initial load
duke
parents:
diff changeset
209 // live range of a rematerializable value. The live range spills,
a61af66fc99e Initial load
duke
parents:
diff changeset
210 // rematerializes and now the ConI directly feeds into the debug info.
a61af66fc99e Initial load
duke
parents:
diff changeset
211 // assert(!def->is_Con(), "constant debug info already constructed directly");
a61af66fc99e Initial load
duke
parents:
diff changeset
212
a61af66fc99e Initial load
duke
parents:
diff changeset
213 // Special split handling for Debug Info
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // If DEF is DOWN, just hook the edge and return
a61af66fc99e Initial load
duke
parents:
diff changeset
215 // If DEF is UP, Split it DOWN for this USE.
a61af66fc99e Initial load
duke
parents:
diff changeset
216 if( def->is_Mach() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
217 if( def_down ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
218 // DEF is DOWN, so connect USE directly to the DEF
a61af66fc99e Initial load
duke
parents:
diff changeset
219 use->set_req(useidx, def);
a61af66fc99e Initial load
duke
parents:
diff changeset
220 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
221 // Block and index where the use occurs.
12023
d1034bd8cefc 8022284: Hide internal data structure in PhaseCFG
adlertz
parents: 10395
diff changeset
222 Block *b = _cfg.get_block_for_node(use);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
223 // Put the clone just prior to use
a61af66fc99e Initial load
duke
parents:
diff changeset
224 int bindex = b->find_node(use);
a61af66fc99e Initial load
duke
parents:
diff changeset
225 // DEF is UP, so must copy it DOWN and hook in USE
a61af66fc99e Initial load
duke
parents:
diff changeset
226 // Insert SpillCopy before the USE, which uses DEF as its input,
a61af66fc99e Initial load
duke
parents:
diff changeset
227 // and defs a new live range, which is used by this node.
a61af66fc99e Initial load
duke
parents:
diff changeset
228 Node *spill = get_spillcopy_wide(def,use,useidx);
a61af66fc99e Initial load
duke
parents:
diff changeset
229 // did we fail to split?
a61af66fc99e Initial load
duke
parents:
diff changeset
230 if (!spill) {
a61af66fc99e Initial load
duke
parents:
diff changeset
231 // Bail
a61af66fc99e Initial load
duke
parents:
diff changeset
232 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
233 }
a61af66fc99e Initial load
duke
parents:
diff changeset
234 // insert into basic block
a61af66fc99e Initial load
duke
parents:
diff changeset
235 insert_proj( b, bindex, spill, maxlrg++ );
a61af66fc99e Initial load
duke
parents:
diff changeset
236 // Use the new split
a61af66fc99e Initial load
duke
parents:
diff changeset
237 use->set_req(useidx,spill);
a61af66fc99e Initial load
duke
parents:
diff changeset
238 }
a61af66fc99e Initial load
duke
parents:
diff changeset
239 // No further split handling needed for this use
a61af66fc99e Initial load
duke
parents:
diff changeset
240 return maxlrg;
a61af66fc99e Initial load
duke
parents:
diff changeset
241 } // End special splitting for debug info live range
a61af66fc99e Initial load
duke
parents:
diff changeset
242 } // If debug info
a61af66fc99e Initial load
duke
parents:
diff changeset
243
a61af66fc99e Initial load
duke
parents:
diff changeset
244 // CISC-SPILLING
a61af66fc99e Initial load
duke
parents:
diff changeset
245 // Finally, check to see if USE is CISC-Spillable, and if so,
a61af66fc99e Initial load
duke
parents:
diff changeset
246 // gather_lrg_masks will add the flags bit to its mask, and
a61af66fc99e Initial load
duke
parents:
diff changeset
247 // no use side copy is needed. This frees up the live range
a61af66fc99e Initial load
duke
parents:
diff changeset
248 // register choices without causing copy coalescing, etc.
a61af66fc99e Initial load
duke
parents:
diff changeset
249 if( UseCISCSpill && cisc_sp ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
250 int inp = use->cisc_operand();
a61af66fc99e Initial load
duke
parents:
diff changeset
251 if( inp != AdlcVMDeps::Not_cisc_spillable )
a61af66fc99e Initial load
duke
parents:
diff changeset
252 // Convert operand number to edge index number
a61af66fc99e Initial load
duke
parents:
diff changeset
253 inp = use->as_Mach()->operand_index(inp);
a61af66fc99e Initial load
duke
parents:
diff changeset
254 if( inp == (int)useidx ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
255 use->set_req(useidx, def);
a61af66fc99e Initial load
duke
parents:
diff changeset
256 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
257 if( TraceCISCSpill ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
258 tty->print(" set_split: ");
a61af66fc99e Initial load
duke
parents:
diff changeset
259 use->dump();
a61af66fc99e Initial load
duke
parents:
diff changeset
260 }
a61af66fc99e Initial load
duke
parents:
diff changeset
261 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
262 return maxlrg;
a61af66fc99e Initial load
duke
parents:
diff changeset
263 }
a61af66fc99e Initial load
duke
parents:
diff changeset
264 }
a61af66fc99e Initial load
duke
parents:
diff changeset
265
a61af66fc99e Initial load
duke
parents:
diff changeset
266 //-------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
267 // Insert a Copy before the use
a61af66fc99e Initial load
duke
parents:
diff changeset
268
a61af66fc99e Initial load
duke
parents:
diff changeset
269 // Block and index where the use occurs.
a61af66fc99e Initial load
duke
parents:
diff changeset
270 int bindex;
a61af66fc99e Initial load
duke
parents:
diff changeset
271 // Phi input spill-copys belong at the end of the prior block
a61af66fc99e Initial load
duke
parents:
diff changeset
272 if( use->is_Phi() ) {
12023
d1034bd8cefc 8022284: Hide internal data structure in PhaseCFG
adlertz
parents: 10395
diff changeset
273 b = _cfg.get_block_for_node(b->pred(useidx));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
274 bindex = b->end_idx();
a61af66fc99e Initial load
duke
parents:
diff changeset
275 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
276 // Put the clone just prior to use
a61af66fc99e Initial load
duke
parents:
diff changeset
277 bindex = b->find_node(use);
a61af66fc99e Initial load
duke
parents:
diff changeset
278 }
a61af66fc99e Initial load
duke
parents:
diff changeset
279
a61af66fc99e Initial load
duke
parents:
diff changeset
280 Node *spill = get_spillcopy_wide( def, use, useidx );
a61af66fc99e Initial load
duke
parents:
diff changeset
281 if( !spill ) return 0; // Bailed out
a61af66fc99e Initial load
duke
parents:
diff changeset
282 // Insert SpillCopy before the USE, which uses the reaching DEF as
a61af66fc99e Initial load
duke
parents:
diff changeset
283 // its input, and defs a new live range, which is used by this node.
a61af66fc99e Initial load
duke
parents:
diff changeset
284 insert_proj( b, bindex, spill, maxlrg++ );
a61af66fc99e Initial load
duke
parents:
diff changeset
285 // Use the spill/clone
a61af66fc99e Initial load
duke
parents:
diff changeset
286 use->set_req(useidx,spill);
a61af66fc99e Initial load
duke
parents:
diff changeset
287
a61af66fc99e Initial load
duke
parents:
diff changeset
288 // return updated live range count
a61af66fc99e Initial load
duke
parents:
diff changeset
289 return maxlrg;
a61af66fc99e Initial load
duke
parents:
diff changeset
290 }
a61af66fc99e Initial load
duke
parents:
diff changeset
291
1693
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
292 //------------------------------clone_node----------------------------
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
293 // Clone node with anti dependence check.
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
294 Node* clone_node(Node* def, Block *b, Compile* C) {
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
295 if (def->needs_anti_dependence_check()) {
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
296 #ifdef ASSERT
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
297 if (Verbose) {
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
298 tty->print_cr("RA attempts to clone node with anti_dependence:");
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
299 def->dump(-1); tty->cr();
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
300 tty->print_cr("into block:");
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
301 b->dump();
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
302 }
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
303 #endif
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
304 if (C->subsume_loads() == true && !C->failing()) {
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
305 // Retry with subsume_loads == false
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
306 // If this is the first failure, the sentinel string will "stick"
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
307 // to the Compile object, and the C2Compiler will see it and retry.
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
308 C->record_failure(C2Compiler::retry_no_subsuming_loads());
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
309 } else {
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
310 // Bailout without retry
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
311 C->record_method_not_compilable("RA Split failed: attempt to clone node with anti_dependence");
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
312 }
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
313 return 0;
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
314 }
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
315 return def->clone();
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
316 }
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
317
0
a61af66fc99e Initial load
duke
parents:
diff changeset
318 //------------------------------split_Rematerialize----------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
319 // Clone a local copy of the def.
a61af66fc99e Initial load
duke
parents:
diff changeset
320 Node *PhaseChaitin::split_Rematerialize( Node *def, Block *b, uint insidx, uint &maxlrg, GrowableArray<uint> splits, int slidx, uint *lrg2reach, Node **Reachblock, bool walkThru ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
321 // The input live ranges will be stretched to the site of the new
a61af66fc99e Initial load
duke
parents:
diff changeset
322 // instruction. They might be stretched past a def and will thus
a61af66fc99e Initial load
duke
parents:
diff changeset
323 // have the old and new values of the same live range alive at the
a61af66fc99e Initial load
duke
parents:
diff changeset
324 // same time - a definite no-no. Split out private copies of
a61af66fc99e Initial load
duke
parents:
diff changeset
325 // the inputs.
a61af66fc99e Initial load
duke
parents:
diff changeset
326 if( def->req() > 1 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
327 for( uint i = 1; i < def->req(); i++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
328 Node *in = def->in(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
329 // Check for single-def (LRG cannot redefined)
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
330 uint lidx = _lrg_map.live_range_id(in);
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
331 if (lidx >= _lrg_map.max_lrg_id()) {
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
332 continue; // Value is a recent spill-copy
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
333 }
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
334 if (lrgs(lidx).is_singledef()) {
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
335 continue;
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
336 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
337
12023
d1034bd8cefc 8022284: Hide internal data structure in PhaseCFG
adlertz
parents: 10395
diff changeset
338 Block *b_def = _cfg.get_block_for_node(def);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
339 int idx_def = b_def->find_node(def);
a61af66fc99e Initial load
duke
parents:
diff changeset
340 Node *in_spill = get_spillcopy_wide( in, def, i );
a61af66fc99e Initial load
duke
parents:
diff changeset
341 if( !in_spill ) return 0; // Bailed out
a61af66fc99e Initial load
duke
parents:
diff changeset
342 insert_proj(b_def,idx_def,in_spill,maxlrg++);
a61af66fc99e Initial load
duke
parents:
diff changeset
343 if( b_def == b )
a61af66fc99e Initial load
duke
parents:
diff changeset
344 insidx++;
a61af66fc99e Initial load
duke
parents:
diff changeset
345 def->set_req(i,in_spill);
a61af66fc99e Initial load
duke
parents:
diff changeset
346 }
a61af66fc99e Initial load
duke
parents:
diff changeset
347 }
a61af66fc99e Initial load
duke
parents:
diff changeset
348
1693
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
349 Node *spill = clone_node(def, b, C);
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
350 if (spill == NULL || C->check_node_count(NodeLimitFudgeFactor, out_of_nodes)) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
351 // Check when generating nodes
a61af66fc99e Initial load
duke
parents:
diff changeset
352 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
353 }
a61af66fc99e Initial load
duke
parents:
diff changeset
354
a61af66fc99e Initial load
duke
parents:
diff changeset
355 // See if any inputs are currently being spilled, and take the
a61af66fc99e Initial load
duke
parents:
diff changeset
356 // latest copy of spilled inputs.
a61af66fc99e Initial load
duke
parents:
diff changeset
357 if( spill->req() > 1 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
358 for( uint i = 1; i < spill->req(); i++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
359 Node *in = spill->in(i);
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
360 uint lidx = _lrg_map.find_id(in);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
361
a61af66fc99e Initial load
duke
parents:
diff changeset
362 // Walk backwards thru spill copy node intermediates
295
ea18057223c4 6732194: Data corruption dependent on -server/-client/-Xbatch
never
parents: 0
diff changeset
363 if (walkThru) {
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
364 while (in->is_SpillCopy() && lidx >= _lrg_map.max_lrg_id()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
365 in = in->in(1);
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
366 lidx = _lrg_map.find_id(in);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
367 }
a61af66fc99e Initial load
duke
parents:
diff changeset
368
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
369 if (lidx < _lrg_map.max_lrg_id() && lrgs(lidx).is_multidef()) {
295
ea18057223c4 6732194: Data corruption dependent on -server/-client/-Xbatch
never
parents: 0
diff changeset
370 // walkThru found a multidef LRG, which is unsafe to use, so
ea18057223c4 6732194: Data corruption dependent on -server/-client/-Xbatch
never
parents: 0
diff changeset
371 // just keep the original def used in the clone.
ea18057223c4 6732194: Data corruption dependent on -server/-client/-Xbatch
never
parents: 0
diff changeset
372 in = spill->in(i);
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
373 lidx = _lrg_map.find_id(in);
295
ea18057223c4 6732194: Data corruption dependent on -server/-client/-Xbatch
never
parents: 0
diff changeset
374 }
ea18057223c4 6732194: Data corruption dependent on -server/-client/-Xbatch
never
parents: 0
diff changeset
375 }
ea18057223c4 6732194: Data corruption dependent on -server/-client/-Xbatch
never
parents: 0
diff changeset
376
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
377 if (lidx < _lrg_map.max_lrg_id() && lrgs(lidx).reg() >= LRG::SPILL_REG) {
12872
98692a2d36d7 8013830: [parfait] Uninitialised pointer 'Reachblock' may be used as argument
adlertz
parents: 12167
diff changeset
378 assert(Reachblock != NULL, "Reachblock must be non-NULL");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
379 Node *rdef = Reachblock[lrg2reach[lidx]];
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
380 if (rdef) {
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
381 spill->set_req(i, rdef);
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
382 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
383 }
a61af66fc99e Initial load
duke
parents:
diff changeset
384 }
a61af66fc99e Initial load
duke
parents:
diff changeset
385 }
a61af66fc99e Initial load
duke
parents:
diff changeset
386
a61af66fc99e Initial load
duke
parents:
diff changeset
387
a61af66fc99e Initial load
duke
parents:
diff changeset
388 assert( spill->out_RegMask().is_UP(), "rematerialize to a reg" );
a61af66fc99e Initial load
duke
parents:
diff changeset
389 // Rematerialized op is def->spilled+1
a61af66fc99e Initial load
duke
parents:
diff changeset
390 set_was_spilled(spill);
a61af66fc99e Initial load
duke
parents:
diff changeset
391 if( _spilled_once.test(def->_idx) )
a61af66fc99e Initial load
duke
parents:
diff changeset
392 set_was_spilled(spill);
a61af66fc99e Initial load
duke
parents:
diff changeset
393
a61af66fc99e Initial load
duke
parents:
diff changeset
394 insert_proj( b, insidx, spill, maxlrg++ );
a61af66fc99e Initial load
duke
parents:
diff changeset
395 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
396 // Increment the counter for this lrg
a61af66fc99e Initial load
duke
parents:
diff changeset
397 splits.at_put(slidx, splits.at(slidx)+1);
a61af66fc99e Initial load
duke
parents:
diff changeset
398 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
399 // See if the cloned def kills any flags, and copy those kills as well
a61af66fc99e Initial load
duke
parents:
diff changeset
400 uint i = insidx+1;
12075
4b2838704fd5 8021898: Broken JIT compiler optimization for loop unswitching
kvn
parents: 12071
diff changeset
401 int found_projs = clone_projs( b, i, def, spill, maxlrg);
4b2838704fd5 8021898: Broken JIT compiler optimization for loop unswitching
kvn
parents: 12071
diff changeset
402 if (found_projs > 0) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
403 // Adjust the point where we go hi-pressure
12075
4b2838704fd5 8021898: Broken JIT compiler optimization for loop unswitching
kvn
parents: 12071
diff changeset
404 if (i <= b->_ihrp_index) {
4b2838704fd5 8021898: Broken JIT compiler optimization for loop unswitching
kvn
parents: 12071
diff changeset
405 b->_ihrp_index += found_projs;
4b2838704fd5 8021898: Broken JIT compiler optimization for loop unswitching
kvn
parents: 12071
diff changeset
406 }
4b2838704fd5 8021898: Broken JIT compiler optimization for loop unswitching
kvn
parents: 12071
diff changeset
407 if (i <= b->_fhrp_index) {
4b2838704fd5 8021898: Broken JIT compiler optimization for loop unswitching
kvn
parents: 12071
diff changeset
408 b->_fhrp_index += found_projs;
4b2838704fd5 8021898: Broken JIT compiler optimization for loop unswitching
kvn
parents: 12071
diff changeset
409 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
410 }
a61af66fc99e Initial load
duke
parents:
diff changeset
411
a61af66fc99e Initial load
duke
parents:
diff changeset
412 return spill;
a61af66fc99e Initial load
duke
parents:
diff changeset
413 }
a61af66fc99e Initial load
duke
parents:
diff changeset
414
a61af66fc99e Initial load
duke
parents:
diff changeset
415 //------------------------------is_high_pressure-------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
416 // Function to compute whether or not this live range is "high pressure"
a61af66fc99e Initial load
duke
parents:
diff changeset
417 // in this block - whether it spills eagerly or not.
a61af66fc99e Initial load
duke
parents:
diff changeset
418 bool PhaseChaitin::is_high_pressure( Block *b, LRG *lrg, uint insidx ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
419 if( lrg->_was_spilled1 ) return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
420 // Forced spilling due to conflict? Then split only at binding uses
a61af66fc99e Initial load
duke
parents:
diff changeset
421 // or defs, not for supposed capacity problems.
a61af66fc99e Initial load
duke
parents:
diff changeset
422 // CNC - Turned off 7/8/99, causes too much spilling
a61af66fc99e Initial load
duke
parents:
diff changeset
423 // if( lrg->_is_bound ) return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
424
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 3842
diff changeset
425 // Use float pressure numbers for vectors.
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 3842
diff changeset
426 bool is_float_or_vector = lrg->_is_float || lrg->_is_vector;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
427 // Not yet reached the high-pressure cutoff point, so low pressure
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 3842
diff changeset
428 uint hrp_idx = is_float_or_vector ? b->_fhrp_index : b->_ihrp_index;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
429 if( insidx < hrp_idx ) return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
430 // Register pressure for the block as a whole depends on reg class
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 3842
diff changeset
431 int block_pres = is_float_or_vector ? b->_freg_pressure : b->_reg_pressure;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
432 // Bound live ranges will split at the binding points first;
a61af66fc99e Initial load
duke
parents:
diff changeset
433 // Intermediate splits should assume the live range's register set
a61af66fc99e Initial load
duke
parents:
diff changeset
434 // got "freed up" and that num_regs will become INT_PRESSURE.
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 3842
diff changeset
435 int bound_pres = is_float_or_vector ? FLOATPRESSURE : INTPRESSURE;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
436 // Effective register pressure limit.
a61af66fc99e Initial load
duke
parents:
diff changeset
437 int lrg_pres = (lrg->get_invalid_mask_size() > lrg->num_regs())
a61af66fc99e Initial load
duke
parents:
diff changeset
438 ? (lrg->get_invalid_mask_size() >> (lrg->num_regs()-1)) : bound_pres;
a61af66fc99e Initial load
duke
parents:
diff changeset
439 // High pressure if block pressure requires more register freedom
a61af66fc99e Initial load
duke
parents:
diff changeset
440 // than live range has.
a61af66fc99e Initial load
duke
parents:
diff changeset
441 return block_pres >= lrg_pres;
a61af66fc99e Initial load
duke
parents:
diff changeset
442 }
a61af66fc99e Initial load
duke
parents:
diff changeset
443
a61af66fc99e Initial load
duke
parents:
diff changeset
444
a61af66fc99e Initial load
duke
parents:
diff changeset
445 //------------------------------prompt_use---------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
446 // True if lidx is used before any real register is def'd in the block
a61af66fc99e Initial load
duke
parents:
diff changeset
447 bool PhaseChaitin::prompt_use( Block *b, uint lidx ) {
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
448 if (lrgs(lidx)._was_spilled2) {
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
449 return false;
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
450 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
451
a61af66fc99e Initial load
duke
parents:
diff changeset
452 // Scan block for 1st use.
a61af66fc99e Initial load
duke
parents:
diff changeset
453 for( uint i = 1; i <= b->end_idx(); i++ ) {
12167
650868c062a9 8023691: Create interface for nodes in class Block
adlertz
parents: 12075
diff changeset
454 Node *n = b->get_node(i);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
455 // Ignore PHI use, these can be up or down
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
456 if (n->is_Phi()) {
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
457 continue;
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
458 }
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
459 for (uint j = 1; j < n->req(); j++) {
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
460 if (_lrg_map.find_id(n->in(j)) == lidx) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
461 return true; // Found 1st use!
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
462 }
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
463 }
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
464 if (n->out_RegMask().is_NotEmpty()) {
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
465 return false;
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
466 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
467 }
a61af66fc99e Initial load
duke
parents:
diff changeset
468 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
469 }
a61af66fc99e Initial load
duke
parents:
diff changeset
470
a61af66fc99e Initial load
duke
parents:
diff changeset
471 //------------------------------Split--------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
472 //----------Split Routine----------
a61af66fc99e Initial load
duke
parents:
diff changeset
473 // ***** NEW SPLITTING HEURISTIC *****
a61af66fc99e Initial load
duke
parents:
diff changeset
474 // DEFS: If the DEF is in a High Register Pressure(HRP) Block, split there.
a61af66fc99e Initial load
duke
parents:
diff changeset
475 // Else, no split unless there is a HRP block between a DEF and
a61af66fc99e Initial load
duke
parents:
diff changeset
476 // one of its uses, and then split at the HRP block.
a61af66fc99e Initial load
duke
parents:
diff changeset
477 //
a61af66fc99e Initial load
duke
parents:
diff changeset
478 // USES: If USE is in HRP, split at use to leave main LRG on stack.
a61af66fc99e Initial load
duke
parents:
diff changeset
479 // Else, hoist LRG back up to register only (ie - split is also DEF)
a61af66fc99e Initial load
duke
parents:
diff changeset
480 // We will compute a new maxlrg as we go
6632
a1c7f6472621 7148109: C2 compiler consumes too much heap resources
kvn
parents: 6179
diff changeset
481 uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
482 NOT_PRODUCT( Compile::TracePhase t3("regAllocSplit", &_t_regAllocSplit, TimeCompiler); )
a61af66fc99e Initial load
duke
parents:
diff changeset
483
6632
a1c7f6472621 7148109: C2 compiler consumes too much heap resources
kvn
parents: 6179
diff changeset
484 // Free thread local resources used by this method on exit.
a1c7f6472621 7148109: C2 compiler consumes too much heap resources
kvn
parents: 6179
diff changeset
485 ResourceMark rm(split_arena);
a1c7f6472621 7148109: C2 compiler consumes too much heap resources
kvn
parents: 6179
diff changeset
486
0
a61af66fc99e Initial load
duke
parents:
diff changeset
487 uint bidx, pidx, slidx, insidx, inpidx, twoidx;
a61af66fc99e Initial load
duke
parents:
diff changeset
488 uint non_phi = 1, spill_cnt = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
489 Node **Reachblock;
a61af66fc99e Initial load
duke
parents:
diff changeset
490 Node *n1, *n2, *n3;
a61af66fc99e Initial load
duke
parents:
diff changeset
491 Node_List *defs,*phis;
a61af66fc99e Initial load
duke
parents:
diff changeset
492 bool *UPblock;
a61af66fc99e Initial load
duke
parents:
diff changeset
493 bool u1, u2, u3;
a61af66fc99e Initial load
duke
parents:
diff changeset
494 Block *b, *pred;
a61af66fc99e Initial load
duke
parents:
diff changeset
495 PhiNode *phi;
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
496 GrowableArray<uint> lidxs(split_arena, maxlrg, 0, 0);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
497
a61af66fc99e Initial load
duke
parents:
diff changeset
498 // Array of counters to count splits per live range
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
499 GrowableArray<uint> splits(split_arena, maxlrg, 0, 0);
6632
a1c7f6472621 7148109: C2 compiler consumes too much heap resources
kvn
parents: 6179
diff changeset
500
a1c7f6472621 7148109: C2 compiler consumes too much heap resources
kvn
parents: 6179
diff changeset
501 #define NEW_SPLIT_ARRAY(type, size)\
a1c7f6472621 7148109: C2 compiler consumes too much heap resources
kvn
parents: 6179
diff changeset
502 (type*) split_arena->allocate_bytes((size) * sizeof(type))
0
a61af66fc99e Initial load
duke
parents:
diff changeset
503
a61af66fc99e Initial load
duke
parents:
diff changeset
504 //----------Setup Code----------
a61af66fc99e Initial load
duke
parents:
diff changeset
505 // Create a convenient mapping from lrg numbers to reaches/leaves indices
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
506 uint *lrg2reach = NEW_SPLIT_ARRAY(uint, maxlrg);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
507 // Keep track of DEFS & Phis for later passes
a61af66fc99e Initial load
duke
parents:
diff changeset
508 defs = new Node_List();
a61af66fc99e Initial load
duke
parents:
diff changeset
509 phis = new Node_List();
a61af66fc99e Initial load
duke
parents:
diff changeset
510 // Gather info on which LRG's are spilling, and build maps
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
511 for (bidx = 1; bidx < maxlrg; bidx++) {
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
512 if (lrgs(bidx).alive() && lrgs(bidx).reg() >= LRG::SPILL_REG) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
513 assert(!lrgs(bidx).mask().is_AllStack(),"AllStack should color");
a61af66fc99e Initial load
duke
parents:
diff changeset
514 lrg2reach[bidx] = spill_cnt;
a61af66fc99e Initial load
duke
parents:
diff changeset
515 spill_cnt++;
a61af66fc99e Initial load
duke
parents:
diff changeset
516 lidxs.append(bidx);
a61af66fc99e Initial load
duke
parents:
diff changeset
517 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
518 // Initialize the split counts to zero
a61af66fc99e Initial load
duke
parents:
diff changeset
519 splits.append(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
520 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
521 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
522 if( PrintOpto && WizardMode && lrgs(bidx)._was_spilled1 )
a61af66fc99e Initial load
duke
parents:
diff changeset
523 tty->print_cr("Warning, 2nd spill of L%d",bidx);
a61af66fc99e Initial load
duke
parents:
diff changeset
524 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
525 }
a61af66fc99e Initial load
duke
parents:
diff changeset
526 }
a61af66fc99e Initial load
duke
parents:
diff changeset
527
a61af66fc99e Initial load
duke
parents:
diff changeset
528 // Create side arrays for propagating reaching defs info.
a61af66fc99e Initial load
duke
parents:
diff changeset
529 // Each block needs a node pointer for each spilling live range for the
a61af66fc99e Initial load
duke
parents:
diff changeset
530 // Def which is live into the block. Phi nodes handle multiple input
a61af66fc99e Initial load
duke
parents:
diff changeset
531 // Defs by querying the output of their predecessor blocks and resolving
a61af66fc99e Initial load
duke
parents:
diff changeset
532 // them to a single Def at the phi. The pointer is updated for each
a61af66fc99e Initial load
duke
parents:
diff changeset
533 // Def in the block, and then becomes the output for the block when
a61af66fc99e Initial load
duke
parents:
diff changeset
534 // processing of the block is complete. We also need to track whether
a61af66fc99e Initial load
duke
parents:
diff changeset
535 // a Def is UP or DOWN. UP means that it should get a register (ie -
a61af66fc99e Initial load
duke
parents:
diff changeset
536 // it is always in LRP regions), and DOWN means that it is probably
a61af66fc99e Initial load
duke
parents:
diff changeset
537 // on the stack (ie - it crosses HRP regions).
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
538 Node ***Reaches = NEW_SPLIT_ARRAY( Node**, _cfg.number_of_blocks() + 1);
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
539 bool **UP = NEW_SPLIT_ARRAY( bool*, _cfg.number_of_blocks() + 1);
6632
a1c7f6472621 7148109: C2 compiler consumes too much heap resources
kvn
parents: 6179
diff changeset
540 Node **debug_defs = NEW_SPLIT_ARRAY( Node*, spill_cnt );
a1c7f6472621 7148109: C2 compiler consumes too much heap resources
kvn
parents: 6179
diff changeset
541 VectorSet **UP_entry= NEW_SPLIT_ARRAY( VectorSet*, spill_cnt );
0
a61af66fc99e Initial load
duke
parents:
diff changeset
542
a61af66fc99e Initial load
duke
parents:
diff changeset
543 // Initialize Reaches & UP
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
544 for (bidx = 0; bidx < _cfg.number_of_blocks() + 1; bidx++) {
6632
a1c7f6472621 7148109: C2 compiler consumes too much heap resources
kvn
parents: 6179
diff changeset
545 Reaches[bidx] = NEW_SPLIT_ARRAY( Node*, spill_cnt );
a1c7f6472621 7148109: C2 compiler consumes too much heap resources
kvn
parents: 6179
diff changeset
546 UP[bidx] = NEW_SPLIT_ARRAY( bool, spill_cnt );
0
a61af66fc99e Initial load
duke
parents:
diff changeset
547 Node **Reachblock = Reaches[bidx];
a61af66fc99e Initial load
duke
parents:
diff changeset
548 bool *UPblock = UP[bidx];
a61af66fc99e Initial load
duke
parents:
diff changeset
549 for( slidx = 0; slidx < spill_cnt; slidx++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
550 UPblock[slidx] = true; // Assume they start in registers
a61af66fc99e Initial load
duke
parents:
diff changeset
551 Reachblock[slidx] = NULL; // Assume that no def is present
a61af66fc99e Initial load
duke
parents:
diff changeset
552 }
a61af66fc99e Initial load
duke
parents:
diff changeset
553 }
a61af66fc99e Initial load
duke
parents:
diff changeset
554
6632
a1c7f6472621 7148109: C2 compiler consumes too much heap resources
kvn
parents: 6179
diff changeset
555 #undef NEW_SPLIT_ARRAY
a1c7f6472621 7148109: C2 compiler consumes too much heap resources
kvn
parents: 6179
diff changeset
556
0
a61af66fc99e Initial load
duke
parents:
diff changeset
557 // Initialize to array of empty vectorsets
a61af66fc99e Initial load
duke
parents:
diff changeset
558 for( slidx = 0; slidx < spill_cnt; slidx++ )
6632
a1c7f6472621 7148109: C2 compiler consumes too much heap resources
kvn
parents: 6179
diff changeset
559 UP_entry[slidx] = new VectorSet(split_arena);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
560
a61af66fc99e Initial load
duke
parents:
diff changeset
561 //----------PASS 1----------
a61af66fc99e Initial load
duke
parents:
diff changeset
562 //----------Propagation & Node Insertion Code----------
a61af66fc99e Initial load
duke
parents:
diff changeset
563 // Walk the Blocks in RPO for DEF & USE info
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
564 for( bidx = 0; bidx < _cfg.number_of_blocks(); bidx++ ) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
565
a61af66fc99e Initial load
duke
parents:
diff changeset
566 if (C->check_node_count(spill_cnt, out_of_nodes)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
567 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
568 }
a61af66fc99e Initial load
duke
parents:
diff changeset
569
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
570 b = _cfg.get_block(bidx);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
571 // Reaches & UP arrays for this block
a61af66fc99e Initial load
duke
parents:
diff changeset
572 Reachblock = Reaches[b->_pre_order];
a61af66fc99e Initial load
duke
parents:
diff changeset
573 UPblock = UP[b->_pre_order];
a61af66fc99e Initial load
duke
parents:
diff changeset
574 // Reset counter of start of non-Phi nodes in block
a61af66fc99e Initial load
duke
parents:
diff changeset
575 non_phi = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
576 //----------Block Entry Handling----------
a61af66fc99e Initial load
duke
parents:
diff changeset
577 // Check for need to insert a new phi
a61af66fc99e Initial load
duke
parents:
diff changeset
578 // Cycle through this block's predecessors, collecting Reaches
a61af66fc99e Initial load
duke
parents:
diff changeset
579 // info for each spilled LRG. If they are identical, no phi is
a61af66fc99e Initial load
duke
parents:
diff changeset
580 // needed. If they differ, check for a phi, and insert if missing,
a61af66fc99e Initial load
duke
parents:
diff changeset
581 // or update edges if present. Set current block's Reaches set to
a61af66fc99e Initial load
duke
parents:
diff changeset
582 // be either the phi's or the reaching def, as appropriate.
a61af66fc99e Initial load
duke
parents:
diff changeset
583 // If no Phi is needed, check if the LRG needs to spill on entry
a61af66fc99e Initial load
duke
parents:
diff changeset
584 // to the block due to HRP.
a61af66fc99e Initial load
duke
parents:
diff changeset
585 for( slidx = 0; slidx < spill_cnt; slidx++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
586 // Grab the live range number
a61af66fc99e Initial load
duke
parents:
diff changeset
587 uint lidx = lidxs.at(slidx);
a61af66fc99e Initial load
duke
parents:
diff changeset
588 // Do not bother splitting or putting in Phis for single-def
a61af66fc99e Initial load
duke
parents:
diff changeset
589 // rematerialized live ranges. This happens alot to constants
a61af66fc99e Initial load
duke
parents:
diff changeset
590 // with long live ranges.
295
ea18057223c4 6732194: Data corruption dependent on -server/-client/-Xbatch
never
parents: 0
diff changeset
591 if( lrgs(lidx).is_singledef() &&
0
a61af66fc99e Initial load
duke
parents:
diff changeset
592 lrgs(lidx)._def->rematerialize() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
593 // reset the Reaches & UP entries
a61af66fc99e Initial load
duke
parents:
diff changeset
594 Reachblock[slidx] = lrgs(lidx)._def;
a61af66fc99e Initial load
duke
parents:
diff changeset
595 UPblock[slidx] = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
596 // Record following instruction in case 'n' rematerializes and
a61af66fc99e Initial load
duke
parents:
diff changeset
597 // kills flags
12023
d1034bd8cefc 8022284: Hide internal data structure in PhaseCFG
adlertz
parents: 10395
diff changeset
598 Block *pred1 = _cfg.get_block_for_node(b->pred(1));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
599 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
600 }
a61af66fc99e Initial load
duke
parents:
diff changeset
601
a61af66fc99e Initial load
duke
parents:
diff changeset
602 // Initialize needs_phi and needs_split
a61af66fc99e Initial load
duke
parents:
diff changeset
603 bool needs_phi = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
604 bool needs_split = false;
330
1c6e3bfb543a 6746892: Register Allocator does not process a data phi with one unique input correctly
kvn
parents: 295
diff changeset
605 bool has_phi = false;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
606 // Walk the predecessor blocks to check inputs for that live range
a61af66fc99e Initial load
duke
parents:
diff changeset
607 // Grab predecessor block header
a61af66fc99e Initial load
duke
parents:
diff changeset
608 n1 = b->pred(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
609 // Grab the appropriate reaching def info for inpidx
12023
d1034bd8cefc 8022284: Hide internal data structure in PhaseCFG
adlertz
parents: 10395
diff changeset
610 pred = _cfg.get_block_for_node(n1);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
611 pidx = pred->_pre_order;
a61af66fc99e Initial load
duke
parents:
diff changeset
612 Node **Ltmp = Reaches[pidx];
a61af66fc99e Initial load
duke
parents:
diff changeset
613 bool *Utmp = UP[pidx];
a61af66fc99e Initial load
duke
parents:
diff changeset
614 n1 = Ltmp[slidx];
a61af66fc99e Initial load
duke
parents:
diff changeset
615 u1 = Utmp[slidx];
a61af66fc99e Initial load
duke
parents:
diff changeset
616 // Initialize node for saving type info
a61af66fc99e Initial load
duke
parents:
diff changeset
617 n3 = n1;
a61af66fc99e Initial load
duke
parents:
diff changeset
618 u3 = u1;
a61af66fc99e Initial load
duke
parents:
diff changeset
619
a61af66fc99e Initial load
duke
parents:
diff changeset
620 // Compare inputs to see if a Phi is needed
a61af66fc99e Initial load
duke
parents:
diff changeset
621 for( inpidx = 2; inpidx < b->num_preds(); inpidx++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
622 // Grab predecessor block headers
a61af66fc99e Initial load
duke
parents:
diff changeset
623 n2 = b->pred(inpidx);
a61af66fc99e Initial load
duke
parents:
diff changeset
624 // Grab the appropriate reaching def info for inpidx
12023
d1034bd8cefc 8022284: Hide internal data structure in PhaseCFG
adlertz
parents: 10395
diff changeset
625 pred = _cfg.get_block_for_node(n2);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
626 pidx = pred->_pre_order;
a61af66fc99e Initial load
duke
parents:
diff changeset
627 Ltmp = Reaches[pidx];
a61af66fc99e Initial load
duke
parents:
diff changeset
628 Utmp = UP[pidx];
a61af66fc99e Initial load
duke
parents:
diff changeset
629 n2 = Ltmp[slidx];
a61af66fc99e Initial load
duke
parents:
diff changeset
630 u2 = Utmp[slidx];
a61af66fc99e Initial load
duke
parents:
diff changeset
631 // For each LRG, decide if a phi is necessary
a61af66fc99e Initial load
duke
parents:
diff changeset
632 if( n1 != n2 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
633 needs_phi = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
634 }
a61af66fc99e Initial load
duke
parents:
diff changeset
635 // See if the phi has mismatched inputs, UP vs. DOWN
a61af66fc99e Initial load
duke
parents:
diff changeset
636 if( n1 && n2 && (u1 != u2) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
637 needs_split = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
638 }
a61af66fc99e Initial load
duke
parents:
diff changeset
639 // Move n2/u2 to n1/u1 for next iteration
a61af66fc99e Initial load
duke
parents:
diff changeset
640 n1 = n2;
a61af66fc99e Initial load
duke
parents:
diff changeset
641 u1 = u2;
a61af66fc99e Initial load
duke
parents:
diff changeset
642 // Preserve a non-NULL predecessor for later type referencing
a61af66fc99e Initial load
duke
parents:
diff changeset
643 if( (n3 == NULL) && (n2 != NULL) ){
a61af66fc99e Initial load
duke
parents:
diff changeset
644 n3 = n2;
a61af66fc99e Initial load
duke
parents:
diff changeset
645 u3 = u2;
a61af66fc99e Initial load
duke
parents:
diff changeset
646 }
a61af66fc99e Initial load
duke
parents:
diff changeset
647 } // End for all potential Phi inputs
a61af66fc99e Initial load
duke
parents:
diff changeset
648
330
1c6e3bfb543a 6746892: Register Allocator does not process a data phi with one unique input correctly
kvn
parents: 295
diff changeset
649 // check block for appropriate phinode & update edges
1c6e3bfb543a 6746892: Register Allocator does not process a data phi with one unique input correctly
kvn
parents: 295
diff changeset
650 for( insidx = 1; insidx <= b->end_idx(); insidx++ ) {
12167
650868c062a9 8023691: Create interface for nodes in class Block
adlertz
parents: 12075
diff changeset
651 n1 = b->get_node(insidx);
330
1c6e3bfb543a 6746892: Register Allocator does not process a data phi with one unique input correctly
kvn
parents: 295
diff changeset
652 // bail if this is not a phi
1c6e3bfb543a 6746892: Register Allocator does not process a data phi with one unique input correctly
kvn
parents: 295
diff changeset
653 phi = n1->is_Phi() ? n1->as_Phi() : NULL;
1c6e3bfb543a 6746892: Register Allocator does not process a data phi with one unique input correctly
kvn
parents: 295
diff changeset
654 if( phi == NULL ) {
1c6e3bfb543a 6746892: Register Allocator does not process a data phi with one unique input correctly
kvn
parents: 295
diff changeset
655 // Keep track of index of first non-PhiNode instruction in block
1c6e3bfb543a 6746892: Register Allocator does not process a data phi with one unique input correctly
kvn
parents: 295
diff changeset
656 non_phi = insidx;
1c6e3bfb543a 6746892: Register Allocator does not process a data phi with one unique input correctly
kvn
parents: 295
diff changeset
657 // break out of the for loop as we have handled all phi nodes
1c6e3bfb543a 6746892: Register Allocator does not process a data phi with one unique input correctly
kvn
parents: 295
diff changeset
658 break;
1c6e3bfb543a 6746892: Register Allocator does not process a data phi with one unique input correctly
kvn
parents: 295
diff changeset
659 }
1c6e3bfb543a 6746892: Register Allocator does not process a data phi with one unique input correctly
kvn
parents: 295
diff changeset
660 // must be looking at a phi
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
661 if (_lrg_map.find_id(n1) == lidxs.at(slidx)) {
330
1c6e3bfb543a 6746892: Register Allocator does not process a data phi with one unique input correctly
kvn
parents: 295
diff changeset
662 // found the necessary phi
1c6e3bfb543a 6746892: Register Allocator does not process a data phi with one unique input correctly
kvn
parents: 295
diff changeset
663 needs_phi = false;
1c6e3bfb543a 6746892: Register Allocator does not process a data phi with one unique input correctly
kvn
parents: 295
diff changeset
664 has_phi = true;
1c6e3bfb543a 6746892: Register Allocator does not process a data phi with one unique input correctly
kvn
parents: 295
diff changeset
665 // initialize the Reaches entry for this LRG
1c6e3bfb543a 6746892: Register Allocator does not process a data phi with one unique input correctly
kvn
parents: 295
diff changeset
666 Reachblock[slidx] = phi;
1c6e3bfb543a 6746892: Register Allocator does not process a data phi with one unique input correctly
kvn
parents: 295
diff changeset
667 break;
1c6e3bfb543a 6746892: Register Allocator does not process a data phi with one unique input correctly
kvn
parents: 295
diff changeset
668 } // end if found correct phi
1c6e3bfb543a 6746892: Register Allocator does not process a data phi with one unique input correctly
kvn
parents: 295
diff changeset
669 } // end for all phi's
1c6e3bfb543a 6746892: Register Allocator does not process a data phi with one unique input correctly
kvn
parents: 295
diff changeset
670
1c6e3bfb543a 6746892: Register Allocator does not process a data phi with one unique input correctly
kvn
parents: 295
diff changeset
671 // If a phi is needed or exist, check for it
1c6e3bfb543a 6746892: Register Allocator does not process a data phi with one unique input correctly
kvn
parents: 295
diff changeset
672 if( needs_phi || has_phi ) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
673 // add new phinode if one not already found
a61af66fc99e Initial load
duke
parents:
diff changeset
674 if( needs_phi ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
675 // create a new phi node and insert it into the block
a61af66fc99e Initial load
duke
parents:
diff changeset
676 // type is taken from left over pointer to a predecessor
a61af66fc99e Initial load
duke
parents:
diff changeset
677 assert(n3,"No non-NULL reaching DEF for a Phi");
6804
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6725
diff changeset
678 phi = new (C) PhiNode(b->head(), n3->bottom_type());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
679 // initialize the Reaches entry for this LRG
a61af66fc99e Initial load
duke
parents:
diff changeset
680 Reachblock[slidx] = phi;
a61af66fc99e Initial load
duke
parents:
diff changeset
681
a61af66fc99e Initial load
duke
parents:
diff changeset
682 // add node to block & node_to_block mapping
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
683 insert_proj(b, insidx++, phi, maxlrg++);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
684 non_phi++;
a61af66fc99e Initial load
duke
parents:
diff changeset
685 // Reset new phi's mapping to be the spilling live range
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
686 _lrg_map.map(phi->_idx, lidx);
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
687 assert(_lrg_map.find_id(phi) == lidx, "Bad update on Union-Find mapping");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
688 } // end if not found correct phi
a61af66fc99e Initial load
duke
parents:
diff changeset
689 // Here you have either found or created the Phi, so record it
a61af66fc99e Initial load
duke
parents:
diff changeset
690 assert(phi != NULL,"Must have a Phi Node here");
a61af66fc99e Initial load
duke
parents:
diff changeset
691 phis->push(phi);
a61af66fc99e Initial load
duke
parents:
diff changeset
692 // PhiNodes should either force the LRG UP or DOWN depending
a61af66fc99e Initial load
duke
parents:
diff changeset
693 // on its inputs and the register pressure in the Phi's block.
a61af66fc99e Initial load
duke
parents:
diff changeset
694 UPblock[slidx] = true; // Assume new DEF is UP
a61af66fc99e Initial load
duke
parents:
diff changeset
695 // If entering a high-pressure area with no immediate use,
a61af66fc99e Initial load
duke
parents:
diff changeset
696 // assume Phi is DOWN
a61af66fc99e Initial load
duke
parents:
diff changeset
697 if( is_high_pressure( b, &lrgs(lidx), b->end_idx()) && !prompt_use(b,lidx) )
a61af66fc99e Initial load
duke
parents:
diff changeset
698 UPblock[slidx] = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
699 // If we are not split up/down and all inputs are down, then we
a61af66fc99e Initial load
duke
parents:
diff changeset
700 // are down
a61af66fc99e Initial load
duke
parents:
diff changeset
701 if( !needs_split && !u3 )
a61af66fc99e Initial load
duke
parents:
diff changeset
702 UPblock[slidx] = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
703 } // end if phi is needed
a61af66fc99e Initial load
duke
parents:
diff changeset
704
a61af66fc99e Initial load
duke
parents:
diff changeset
705 // Do not need a phi, so grab the reaching DEF
a61af66fc99e Initial load
duke
parents:
diff changeset
706 else {
a61af66fc99e Initial load
duke
parents:
diff changeset
707 // Grab predecessor block header
a61af66fc99e Initial load
duke
parents:
diff changeset
708 n1 = b->pred(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
709 // Grab the appropriate reaching def info for k
12023
d1034bd8cefc 8022284: Hide internal data structure in PhaseCFG
adlertz
parents: 10395
diff changeset
710 pred = _cfg.get_block_for_node(n1);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
711 pidx = pred->_pre_order;
a61af66fc99e Initial load
duke
parents:
diff changeset
712 Node **Ltmp = Reaches[pidx];
a61af66fc99e Initial load
duke
parents:
diff changeset
713 bool *Utmp = UP[pidx];
a61af66fc99e Initial load
duke
parents:
diff changeset
714 // reset the Reaches & UP entries
a61af66fc99e Initial load
duke
parents:
diff changeset
715 Reachblock[slidx] = Ltmp[slidx];
a61af66fc99e Initial load
duke
parents:
diff changeset
716 UPblock[slidx] = Utmp[slidx];
a61af66fc99e Initial load
duke
parents:
diff changeset
717 } // end else no Phi is needed
a61af66fc99e Initial load
duke
parents:
diff changeset
718 } // end for all spilling live ranges
a61af66fc99e Initial load
duke
parents:
diff changeset
719 // DEBUG
a61af66fc99e Initial load
duke
parents:
diff changeset
720 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
721 if(trace_spilling()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
722 tty->print("/`\nBlock %d: ", b->_pre_order);
a61af66fc99e Initial load
duke
parents:
diff changeset
723 tty->print("Reaching Definitions after Phi handling\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
724 for( uint x = 0; x < spill_cnt; x++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
725 tty->print("Spill Idx %d: UP %d: Node\n",x,UPblock[x]);
a61af66fc99e Initial load
duke
parents:
diff changeset
726 if( Reachblock[x] )
a61af66fc99e Initial load
duke
parents:
diff changeset
727 Reachblock[x]->dump();
a61af66fc99e Initial load
duke
parents:
diff changeset
728 else
a61af66fc99e Initial load
duke
parents:
diff changeset
729 tty->print("Undefined\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
730 }
a61af66fc99e Initial load
duke
parents:
diff changeset
731 }
a61af66fc99e Initial load
duke
parents:
diff changeset
732 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
733
a61af66fc99e Initial load
duke
parents:
diff changeset
734 //----------Non-Phi Node Splitting----------
a61af66fc99e Initial load
duke
parents:
diff changeset
735 // Since phi-nodes have now been handled, the Reachblock array for this
a61af66fc99e Initial load
duke
parents:
diff changeset
736 // block is initialized with the correct starting value for the defs which
a61af66fc99e Initial load
duke
parents:
diff changeset
737 // reach non-phi instructions in this block. Thus, process non-phi
a61af66fc99e Initial load
duke
parents:
diff changeset
738 // instructions normally, inserting SpillCopy nodes for all spill
a61af66fc99e Initial load
duke
parents:
diff changeset
739 // locations.
a61af66fc99e Initial load
duke
parents:
diff changeset
740
a61af66fc99e Initial load
duke
parents:
diff changeset
741 // Memoize any DOWN reaching definitions for use as DEBUG info
a61af66fc99e Initial load
duke
parents:
diff changeset
742 for( insidx = 0; insidx < spill_cnt; insidx++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
743 debug_defs[insidx] = (UPblock[insidx]) ? NULL : Reachblock[insidx];
a61af66fc99e Initial load
duke
parents:
diff changeset
744 if( UPblock[insidx] ) // Memoize UP decision at block start
a61af66fc99e Initial load
duke
parents:
diff changeset
745 UP_entry[insidx]->set( b->_pre_order );
a61af66fc99e Initial load
duke
parents:
diff changeset
746 }
a61af66fc99e Initial load
duke
parents:
diff changeset
747
a61af66fc99e Initial load
duke
parents:
diff changeset
748 //----------Walk Instructions in the Block and Split----------
a61af66fc99e Initial load
duke
parents:
diff changeset
749 // For all non-phi instructions in the block
a61af66fc99e Initial load
duke
parents:
diff changeset
750 for( insidx = 1; insidx <= b->end_idx(); insidx++ ) {
12167
650868c062a9 8023691: Create interface for nodes in class Block
adlertz
parents: 12075
diff changeset
751 Node *n = b->get_node(insidx);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
752 // Find the defining Node's live range index
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
753 uint defidx = _lrg_map.find_id(n);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
754 uint cnt = n->req();
a61af66fc99e Initial load
duke
parents:
diff changeset
755
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
756 if (n->is_Phi()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
757 // Skip phi nodes after removing dead copies.
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
758 if (defidx < _lrg_map.max_lrg_id()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
759 // Check for useless Phis. These appear if we spill, then
a61af66fc99e Initial load
duke
parents:
diff changeset
760 // coalesce away copies. Dont touch Phis in spilling live
a61af66fc99e Initial load
duke
parents:
diff changeset
761 // ranges; they are busy getting modifed in this pass.
a61af66fc99e Initial load
duke
parents:
diff changeset
762 if( lrgs(defidx).reg() < LRG::SPILL_REG ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
763 uint i;
a61af66fc99e Initial load
duke
parents:
diff changeset
764 Node *u = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
765 // Look for the Phi merging 2 unique inputs
a61af66fc99e Initial load
duke
parents:
diff changeset
766 for( i = 1; i < cnt; i++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
767 // Ignore repeats and self
a61af66fc99e Initial load
duke
parents:
diff changeset
768 if( n->in(i) != u && n->in(i) != n ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
769 // Found a unique input
a61af66fc99e Initial load
duke
parents:
diff changeset
770 if( u != NULL ) // If it's the 2nd, bail out
a61af66fc99e Initial load
duke
parents:
diff changeset
771 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
772 u = n->in(i); // Else record it
a61af66fc99e Initial load
duke
parents:
diff changeset
773 }
a61af66fc99e Initial load
duke
parents:
diff changeset
774 }
a61af66fc99e Initial load
duke
parents:
diff changeset
775 assert( u, "at least 1 valid input expected" );
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
776 if (i >= cnt) { // Found one unique input
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
777 assert(_lrg_map.find_id(n) == _lrg_map.find_id(u), "should be the same lrg");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
778 n->replace_by(u); // Then replace with unique input
7196
2aff40cb4703 7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents: 6804
diff changeset
779 n->disconnect_inputs(NULL, C);
12167
650868c062a9 8023691: Create interface for nodes in class Block
adlertz
parents: 12075
diff changeset
780 b->remove_node(insidx);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
781 insidx--;
a61af66fc99e Initial load
duke
parents:
diff changeset
782 b->_ihrp_index--;
a61af66fc99e Initial load
duke
parents:
diff changeset
783 b->_fhrp_index--;
a61af66fc99e Initial load
duke
parents:
diff changeset
784 }
a61af66fc99e Initial load
duke
parents:
diff changeset
785 }
a61af66fc99e Initial load
duke
parents:
diff changeset
786 }
a61af66fc99e Initial load
duke
parents:
diff changeset
787 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
788 }
a61af66fc99e Initial load
duke
parents:
diff changeset
789 assert( insidx > b->_ihrp_index ||
a61af66fc99e Initial load
duke
parents:
diff changeset
790 (b->_reg_pressure < (uint)INTPRESSURE) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
791 b->_ihrp_index > 4000000 ||
a61af66fc99e Initial load
duke
parents:
diff changeset
792 b->_ihrp_index >= b->end_idx() ||
12167
650868c062a9 8023691: Create interface for nodes in class Block
adlertz
parents: 12075
diff changeset
793 !b->get_node(b->_ihrp_index)->is_Proj(), "" );
0
a61af66fc99e Initial load
duke
parents:
diff changeset
794 assert( insidx > b->_fhrp_index ||
a61af66fc99e Initial load
duke
parents:
diff changeset
795 (b->_freg_pressure < (uint)FLOATPRESSURE) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
796 b->_fhrp_index > 4000000 ||
a61af66fc99e Initial load
duke
parents:
diff changeset
797 b->_fhrp_index >= b->end_idx() ||
12167
650868c062a9 8023691: Create interface for nodes in class Block
adlertz
parents: 12075
diff changeset
798 !b->get_node(b->_fhrp_index)->is_Proj(), "" );
0
a61af66fc99e Initial load
duke
parents:
diff changeset
799
a61af66fc99e Initial load
duke
parents:
diff changeset
800 // ********** Handle Crossing HRP Boundry **********
a61af66fc99e Initial load
duke
parents:
diff changeset
801 if( (insidx == b->_ihrp_index) || (insidx == b->_fhrp_index) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
802 for( slidx = 0; slidx < spill_cnt; slidx++ ) {
605
98cb887364d3 6810672: Comment typos
twisti
parents: 566
diff changeset
803 // Check for need to split at HRP boundary - split if UP
0
a61af66fc99e Initial load
duke
parents:
diff changeset
804 n1 = Reachblock[slidx];
a61af66fc99e Initial load
duke
parents:
diff changeset
805 // bail out if no reaching DEF
a61af66fc99e Initial load
duke
parents:
diff changeset
806 if( n1 == NULL ) continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
807 // bail out if live range is 'isolated' around inner loop
a61af66fc99e Initial load
duke
parents:
diff changeset
808 uint lidx = lidxs.at(slidx);
a61af66fc99e Initial load
duke
parents:
diff changeset
809 // If live range is currently UP
a61af66fc99e Initial load
duke
parents:
diff changeset
810 if( UPblock[slidx] ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
811 // set location to insert spills at
a61af66fc99e Initial load
duke
parents:
diff changeset
812 // SPLIT DOWN HERE - NO CISC SPILL
a61af66fc99e Initial load
duke
parents:
diff changeset
813 if( is_high_pressure( b, &lrgs(lidx), insidx ) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
814 !n1->rematerialize() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
815 // If there is already a valid stack definition available, use it
a61af66fc99e Initial load
duke
parents:
diff changeset
816 if( debug_defs[slidx] != NULL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
817 Reachblock[slidx] = debug_defs[slidx];
a61af66fc99e Initial load
duke
parents:
diff changeset
818 }
a61af66fc99e Initial load
duke
parents:
diff changeset
819 else {
a61af66fc99e Initial load
duke
parents:
diff changeset
820 // Insert point is just past last use or def in the block
a61af66fc99e Initial load
duke
parents:
diff changeset
821 int insert_point = insidx-1;
a61af66fc99e Initial load
duke
parents:
diff changeset
822 while( insert_point > 0 ) {
12167
650868c062a9 8023691: Create interface for nodes in class Block
adlertz
parents: 12075
diff changeset
823 Node *n = b->get_node(insert_point);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
824 // Hit top of block? Quit going backwards
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
825 if (n->is_Phi()) {
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
826 break;
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
827 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
828 // Found a def? Better split after it.
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
829 if (_lrg_map.live_range_id(n) == lidx) {
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
830 break;
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
831 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
832 // Look for a use
a61af66fc99e Initial load
duke
parents:
diff changeset
833 uint i;
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
834 for( i = 1; i < n->req(); i++ ) {
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
835 if (_lrg_map.live_range_id(n->in(i)) == lidx) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
836 break;
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
837 }
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
838 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
839 // Found a use? Better split after it.
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
840 if (i < n->req()) {
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
841 break;
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
842 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
843 insert_point--;
a61af66fc99e Initial load
duke
parents:
diff changeset
844 }
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 3842
diff changeset
845 uint orig_eidx = b->end_idx();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
846 maxlrg = split_DEF( n1, b, insert_point, maxlrg, Reachblock, debug_defs, splits, slidx);
a61af66fc99e Initial load
duke
parents:
diff changeset
847 // If it wasn't split bail
a61af66fc99e Initial load
duke
parents:
diff changeset
848 if (!maxlrg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
849 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
850 }
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 3842
diff changeset
851 // Spill of NULL check mem op goes into the following block.
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
852 if (b->end_idx() > orig_eidx) {
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 3842
diff changeset
853 insidx++;
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
854 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
855 }
a61af66fc99e Initial load
duke
parents:
diff changeset
856 // This is a new DEF, so update UP
a61af66fc99e Initial load
duke
parents:
diff changeset
857 UPblock[slidx] = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
858 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
859 // DEBUG
a61af66fc99e Initial load
duke
parents:
diff changeset
860 if( trace_spilling() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
861 tty->print("\nNew Split DOWN DEF of Spill Idx ");
a61af66fc99e Initial load
duke
parents:
diff changeset
862 tty->print("%d, UP %d:\n",slidx,false);
a61af66fc99e Initial load
duke
parents:
diff changeset
863 n1->dump();
a61af66fc99e Initial load
duke
parents:
diff changeset
864 }
a61af66fc99e Initial load
duke
parents:
diff changeset
865 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
866 }
a61af66fc99e Initial load
duke
parents:
diff changeset
867 } // end if LRG is UP
a61af66fc99e Initial load
duke
parents:
diff changeset
868 } // end for all spilling live ranges
12167
650868c062a9 8023691: Create interface for nodes in class Block
adlertz
parents: 12075
diff changeset
869 assert( b->get_node(insidx) == n, "got insidx set incorrectly" );
0
a61af66fc99e Initial load
duke
parents:
diff changeset
870 } // end if crossing HRP Boundry
a61af66fc99e Initial load
duke
parents:
diff changeset
871
a61af66fc99e Initial load
duke
parents:
diff changeset
872 // If the LRG index is oob, then this is a new spillcopy, skip it.
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
873 if (defidx >= _lrg_map.max_lrg_id()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
874 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
875 }
a61af66fc99e Initial load
duke
parents:
diff changeset
876 LRG &deflrg = lrgs(defidx);
a61af66fc99e Initial load
duke
parents:
diff changeset
877 uint copyidx = n->is_Copy();
a61af66fc99e Initial load
duke
parents:
diff changeset
878 // Remove coalesced copy from CFG
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
879 if (copyidx && defidx == _lrg_map.live_range_id(n->in(copyidx))) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
880 n->replace_by( n->in(copyidx) );
a61af66fc99e Initial load
duke
parents:
diff changeset
881 n->set_req( copyidx, NULL );
12167
650868c062a9 8023691: Create interface for nodes in class Block
adlertz
parents: 12075
diff changeset
882 b->remove_node(insidx--);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
883 b->_ihrp_index--; // Adjust the point where we go hi-pressure
a61af66fc99e Initial load
duke
parents:
diff changeset
884 b->_fhrp_index--;
a61af66fc99e Initial load
duke
parents:
diff changeset
885 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
886 }
a61af66fc99e Initial load
duke
parents:
diff changeset
887
a61af66fc99e Initial load
duke
parents:
diff changeset
888 #define DERIVED 0
a61af66fc99e Initial load
duke
parents:
diff changeset
889
a61af66fc99e Initial load
duke
parents:
diff changeset
890 // ********** Handle USES **********
a61af66fc99e Initial load
duke
parents:
diff changeset
891 bool nullcheck = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
892 // Implicit null checks never use the spilled value
a61af66fc99e Initial load
duke
parents:
diff changeset
893 if( n->is_MachNullCheck() )
a61af66fc99e Initial load
duke
parents:
diff changeset
894 nullcheck = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
895 if( !nullcheck ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
896 // Search all inputs for a Spill-USE
a61af66fc99e Initial load
duke
parents:
diff changeset
897 JVMState* jvms = n->jvms();
a61af66fc99e Initial load
duke
parents:
diff changeset
898 uint oopoff = jvms ? jvms->oopoff() : cnt;
a61af66fc99e Initial load
duke
parents:
diff changeset
899 uint old_last = cnt - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
900 for( inpidx = 1; inpidx < cnt; inpidx++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
901 // Derived/base pairs may be added to our inputs during this loop.
a61af66fc99e Initial load
duke
parents:
diff changeset
902 // If inpidx > old_last, then one of these new inputs is being
a61af66fc99e Initial load
duke
parents:
diff changeset
903 // handled. Skip the derived part of the pair, but process
a61af66fc99e Initial load
duke
parents:
diff changeset
904 // the base like any other input.
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
905 if (inpidx > old_last && ((inpidx - oopoff) & 1) == DERIVED) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
906 continue; // skip derived_debug added below
a61af66fc99e Initial load
duke
parents:
diff changeset
907 }
a61af66fc99e Initial load
duke
parents:
diff changeset
908 // Get lidx of input
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
909 uint useidx = _lrg_map.find_id(n->in(inpidx));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
910 // Not a brand-new split, and it is a spill use
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
911 if (useidx < _lrg_map.max_lrg_id() && lrgs(useidx).reg() >= LRG::SPILL_REG) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
912 // Check for valid reaching DEF
a61af66fc99e Initial load
duke
parents:
diff changeset
913 slidx = lrg2reach[useidx];
a61af66fc99e Initial load
duke
parents:
diff changeset
914 Node *def = Reachblock[slidx];
a61af66fc99e Initial load
duke
parents:
diff changeset
915 assert( def != NULL, "Using Undefined Value in Split()\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
916
a61af66fc99e Initial load
duke
parents:
diff changeset
917 // (+++) %%%% remove this in favor of pre-pass in matcher.cpp
a61af66fc99e Initial load
duke
parents:
diff changeset
918 // monitor references do not care where they live, so just hook
a61af66fc99e Initial load
duke
parents:
diff changeset
919 if ( jvms && jvms->is_monitor_use(inpidx) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
920 // The effect of this clone is to drop the node out of the block,
a61af66fc99e Initial load
duke
parents:
diff changeset
921 // so that the allocator does not see it anymore, and therefore
a61af66fc99e Initial load
duke
parents:
diff changeset
922 // does not attempt to assign it a register.
1693
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
923 def = clone_node(def, b, C);
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
924 if (def == NULL || C->check_node_count(NodeLimitFudgeFactor, out_of_nodes)) {
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
925 return 0;
6c9cc03d8726 6973329: C2 with Zero based COOP produces code with broken anti-dependency on x86
kvn
parents: 1552
diff changeset
926 }
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
927 _lrg_map.extend(def->_idx, 0);
12023
d1034bd8cefc 8022284: Hide internal data structure in PhaseCFG
adlertz
parents: 10395
diff changeset
928 _cfg.map_node_to_block(def, b);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
929 n->set_req(inpidx, def);
a61af66fc99e Initial load
duke
parents:
diff changeset
930 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
931 }
a61af66fc99e Initial load
duke
parents:
diff changeset
932
a61af66fc99e Initial load
duke
parents:
diff changeset
933 // Rematerializable? Then clone def at use site instead
a61af66fc99e Initial load
duke
parents:
diff changeset
934 // of store/load
a61af66fc99e Initial load
duke
parents:
diff changeset
935 if( def->rematerialize() ) {
12167
650868c062a9 8023691: Create interface for nodes in class Block
adlertz
parents: 12075
diff changeset
936 int old_size = b->number_of_nodes();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
937 def = split_Rematerialize( def, b, insidx, maxlrg, splits, slidx, lrg2reach, Reachblock, true );
a61af66fc99e Initial load
duke
parents:
diff changeset
938 if( !def ) return 0; // Bail out
12167
650868c062a9 8023691: Create interface for nodes in class Block
adlertz
parents: 12075
diff changeset
939 insidx += b->number_of_nodes()-old_size;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
940 }
a61af66fc99e Initial load
duke
parents:
diff changeset
941
a61af66fc99e Initial load
duke
parents:
diff changeset
942 MachNode *mach = n->is_Mach() ? n->as_Mach() : NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
943 // Base pointers and oopmap references do not care where they live.
a61af66fc99e Initial load
duke
parents:
diff changeset
944 if ((inpidx >= oopoff) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
945 (mach && mach->ideal_Opcode() == Op_AddP && inpidx == AddPNode::Base)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
946 if (def->rematerialize() && lrgs(useidx)._was_spilled2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
947 // This def has been rematerialized a couple of times without
a61af66fc99e Initial load
duke
parents:
diff changeset
948 // progress. It doesn't care if it lives UP or DOWN, so
a61af66fc99e Initial load
duke
parents:
diff changeset
949 // spill it down now.
a61af66fc99e Initial load
duke
parents:
diff changeset
950 maxlrg = split_USE(def,b,n,inpidx,maxlrg,false,false,splits,slidx);
a61af66fc99e Initial load
duke
parents:
diff changeset
951 // If it wasn't split bail
a61af66fc99e Initial load
duke
parents:
diff changeset
952 if (!maxlrg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
953 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
954 }
a61af66fc99e Initial load
duke
parents:
diff changeset
955 insidx++; // Reset iterator to skip USE side split
a61af66fc99e Initial load
duke
parents:
diff changeset
956 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
957 // Just hook the def edge
a61af66fc99e Initial load
duke
parents:
diff changeset
958 n->set_req(inpidx, def);
a61af66fc99e Initial load
duke
parents:
diff changeset
959 }
a61af66fc99e Initial load
duke
parents:
diff changeset
960
a61af66fc99e Initial load
duke
parents:
diff changeset
961 if (inpidx >= oopoff) {
a61af66fc99e Initial load
duke
parents:
diff changeset
962 // After oopoff, we have derived/base pairs. We must mention all
a61af66fc99e Initial load
duke
parents:
diff changeset
963 // derived pointers here as derived/base pairs for GC. If the
a61af66fc99e Initial load
duke
parents:
diff changeset
964 // derived value is spilling and we have a copy both in Reachblock
a61af66fc99e Initial load
duke
parents:
diff changeset
965 // (called here 'def') and debug_defs[slidx] we need to mention
a61af66fc99e Initial load
duke
parents:
diff changeset
966 // both in derived/base pairs or kill one.
a61af66fc99e Initial load
duke
parents:
diff changeset
967 Node *derived_debug = debug_defs[slidx];
a61af66fc99e Initial load
duke
parents:
diff changeset
968 if( ((inpidx - oopoff) & 1) == DERIVED && // derived vs base?
a61af66fc99e Initial load
duke
parents:
diff changeset
969 mach && mach->ideal_Opcode() != Op_Halt &&
a61af66fc99e Initial load
duke
parents:
diff changeset
970 derived_debug != NULL &&
a61af66fc99e Initial load
duke
parents:
diff changeset
971 derived_debug != def ) { // Actual 2nd value appears
a61af66fc99e Initial load
duke
parents:
diff changeset
972 // We have already set 'def' as a derived value.
a61af66fc99e Initial load
duke
parents:
diff changeset
973 // Also set debug_defs[slidx] as a derived value.
a61af66fc99e Initial load
duke
parents:
diff changeset
974 uint k;
a61af66fc99e Initial load
duke
parents:
diff changeset
975 for( k = oopoff; k < cnt; k += 2 )
a61af66fc99e Initial load
duke
parents:
diff changeset
976 if( n->in(k) == derived_debug )
a61af66fc99e Initial load
duke
parents:
diff changeset
977 break; // Found an instance of debug derived
a61af66fc99e Initial load
duke
parents:
diff changeset
978 if( k == cnt ) {// No instance of debug_defs[slidx]
a61af66fc99e Initial load
duke
parents:
diff changeset
979 // Add a derived/base pair to cover the debug info.
a61af66fc99e Initial load
duke
parents:
diff changeset
980 // We have to process the added base later since it is not
a61af66fc99e Initial load
duke
parents:
diff changeset
981 // handled yet at this point but skip derived part.
a61af66fc99e Initial load
duke
parents:
diff changeset
982 assert(((n->req() - oopoff) & 1) == DERIVED,
a61af66fc99e Initial load
duke
parents:
diff changeset
983 "must match skip condition above");
a61af66fc99e Initial load
duke
parents:
diff changeset
984 n->add_req( derived_debug ); // this will be skipped above
a61af66fc99e Initial load
duke
parents:
diff changeset
985 n->add_req( n->in(inpidx+1) ); // this will be processed
a61af66fc99e Initial load
duke
parents:
diff changeset
986 // Increment cnt to handle added input edges on
a61af66fc99e Initial load
duke
parents:
diff changeset
987 // subsequent iterations.
a61af66fc99e Initial load
duke
parents:
diff changeset
988 cnt += 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
989 }
a61af66fc99e Initial load
duke
parents:
diff changeset
990 }
a61af66fc99e Initial load
duke
parents:
diff changeset
991 }
a61af66fc99e Initial load
duke
parents:
diff changeset
992 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
993 }
a61af66fc99e Initial load
duke
parents:
diff changeset
994 // Special logic for DEBUG info
a61af66fc99e Initial load
duke
parents:
diff changeset
995 if( jvms && b->_freq > BLOCK_FREQUENCY(0.5) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
996 uint debug_start = jvms->debug_start();
a61af66fc99e Initial load
duke
parents:
diff changeset
997 // If this is debug info use & there is a reaching DOWN def
a61af66fc99e Initial load
duke
parents:
diff changeset
998 if ((debug_start <= inpidx) && (debug_defs[slidx] != NULL)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
999 assert(inpidx < oopoff, "handle only debug info here");
a61af66fc99e Initial load
duke
parents:
diff changeset
1000 // Just hook it in & move on
a61af66fc99e Initial load
duke
parents:
diff changeset
1001 n->set_req(inpidx, debug_defs[slidx]);
a61af66fc99e Initial load
duke
parents:
diff changeset
1002 // (Note that this can make two sides of a split live at the
a61af66fc99e Initial load
duke
parents:
diff changeset
1003 // same time: The debug def on stack, and another def in a
a61af66fc99e Initial load
duke
parents:
diff changeset
1004 // register. The GC needs to know about both of them, but any
a61af66fc99e Initial load
duke
parents:
diff changeset
1005 // derived pointers after oopoff will refer to only one of the
a61af66fc99e Initial load
duke
parents:
diff changeset
1006 // two defs and the GC would therefore miss the other. Thus
a61af66fc99e Initial load
duke
parents:
diff changeset
1007 // this hack is only allowed for debug info which is Java state
a61af66fc99e Initial load
duke
parents:
diff changeset
1008 // and therefore never a derived pointer.)
a61af66fc99e Initial load
duke
parents:
diff changeset
1009 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
1010 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1011 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1012 // Grab register mask info
a61af66fc99e Initial load
duke
parents:
diff changeset
1013 const RegMask &dmask = def->out_RegMask();
a61af66fc99e Initial load
duke
parents:
diff changeset
1014 const RegMask &umask = n->in_RegMask(inpidx);
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 3842
diff changeset
1015 bool is_vect = RegMask::is_vector(def->ideal_reg());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1016 assert(inpidx < oopoff, "cannot use-split oop map info");
a61af66fc99e Initial load
duke
parents:
diff changeset
1017
a61af66fc99e Initial load
duke
parents:
diff changeset
1018 bool dup = UPblock[slidx];
a61af66fc99e Initial load
duke
parents:
diff changeset
1019 bool uup = umask.is_UP();
a61af66fc99e Initial load
duke
parents:
diff changeset
1020
a61af66fc99e Initial load
duke
parents:
diff changeset
1021 // Need special logic to handle bound USES. Insert a split at this
a61af66fc99e Initial load
duke
parents:
diff changeset
1022 // bound use if we can't rematerialize the def, or if we need the
a61af66fc99e Initial load
duke
parents:
diff changeset
1023 // split to form a misaligned pair.
a61af66fc99e Initial load
duke
parents:
diff changeset
1024 if( !umask.is_AllStack() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1025 (int)umask.Size() <= lrgs(useidx).num_regs() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1026 (!def->rematerialize() ||
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 3842
diff changeset
1027 !is_vect && umask.is_misaligned_pair())) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1028 // These need a Split regardless of overlap or pressure
a61af66fc99e Initial load
duke
parents:
diff changeset
1029 // SPLIT - NO DEF - NO CISC SPILL
a61af66fc99e Initial load
duke
parents:
diff changeset
1030 maxlrg = split_USE(def,b,n,inpidx,maxlrg,dup,false, splits,slidx);
a61af66fc99e Initial load
duke
parents:
diff changeset
1031 // If it wasn't split bail
a61af66fc99e Initial load
duke
parents:
diff changeset
1032 if (!maxlrg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1033 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1034 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1035 insidx++; // Reset iterator to skip USE side split
a61af66fc99e Initial load
duke
parents:
diff changeset
1036 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
1037 }
1730
f55c4f82ab9d 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 1693
diff changeset
1038
3842
c7b60b601eb4 7069452: Cleanup NodeFlags
kvn
parents: 2016
diff changeset
1039 if (UseFPUForSpilling && n->is_MachCall() && !uup && !dup ) {
1730
f55c4f82ab9d 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 1693
diff changeset
1040 // The use at the call can force the def down so insert
f55c4f82ab9d 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 1693
diff changeset
1041 // a split before the use to allow the def more freedom.
f55c4f82ab9d 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 1693
diff changeset
1042 maxlrg = split_USE(def,b,n,inpidx,maxlrg,dup,false, splits,slidx);
f55c4f82ab9d 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 1693
diff changeset
1043 // If it wasn't split bail
f55c4f82ab9d 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 1693
diff changeset
1044 if (!maxlrg) {
f55c4f82ab9d 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 1693
diff changeset
1045 return 0;
f55c4f82ab9d 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 1693
diff changeset
1046 }
f55c4f82ab9d 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 1693
diff changeset
1047 insidx++; // Reset iterator to skip USE side split
f55c4f82ab9d 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 1693
diff changeset
1048 continue;
f55c4f82ab9d 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 1693
diff changeset
1049 }
f55c4f82ab9d 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 1693
diff changeset
1050
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1051 // Here is the logic chart which describes USE Splitting:
a61af66fc99e Initial load
duke
parents:
diff changeset
1052 // 0 = false or DOWN, 1 = true or UP
a61af66fc99e Initial load
duke
parents:
diff changeset
1053 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1054 // Overlap | DEF | USE | Action
a61af66fc99e Initial load
duke
parents:
diff changeset
1055 //-------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1056 // 0 | 0 | 0 | Copy - mem -> mem
a61af66fc99e Initial load
duke
parents:
diff changeset
1057 // 0 | 0 | 1 | Split-UP - Check HRP
a61af66fc99e Initial load
duke
parents:
diff changeset
1058 // 0 | 1 | 0 | Split-DOWN - Debug Info?
a61af66fc99e Initial load
duke
parents:
diff changeset
1059 // 0 | 1 | 1 | Copy - reg -> reg
a61af66fc99e Initial load
duke
parents:
diff changeset
1060 // 1 | 0 | 0 | Reset Input Edge (no Split)
a61af66fc99e Initial load
duke
parents:
diff changeset
1061 // 1 | 0 | 1 | Split-UP - Check HRP
a61af66fc99e Initial load
duke
parents:
diff changeset
1062 // 1 | 1 | 0 | Split-DOWN - Debug Info?
a61af66fc99e Initial load
duke
parents:
diff changeset
1063 // 1 | 1 | 1 | Reset Input Edge (no Split)
a61af66fc99e Initial load
duke
parents:
diff changeset
1064 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1065 // So, if (dup == uup), then overlap test determines action,
a61af66fc99e Initial load
duke
parents:
diff changeset
1066 // with true being no split, and false being copy. Else,
a61af66fc99e Initial load
duke
parents:
diff changeset
1067 // if DEF is DOWN, Split-UP, and check HRP to decide on
a61af66fc99e Initial load
duke
parents:
diff changeset
1068 // resetting DEF. Finally if DEF is UP, Split-DOWN, with
a61af66fc99e Initial load
duke
parents:
diff changeset
1069 // special handling for Debug Info.
a61af66fc99e Initial load
duke
parents:
diff changeset
1070 if( dup == uup ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1071 if( dmask.overlap(umask) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1072 // Both are either up or down, and there is overlap, No Split
a61af66fc99e Initial load
duke
parents:
diff changeset
1073 n->set_req(inpidx, def);
a61af66fc99e Initial load
duke
parents:
diff changeset
1074 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1075 else { // Both are either up or down, and there is no overlap
a61af66fc99e Initial load
duke
parents:
diff changeset
1076 if( dup ) { // If UP, reg->reg copy
a61af66fc99e Initial load
duke
parents:
diff changeset
1077 // COPY ACROSS HERE - NO DEF - NO CISC SPILL
a61af66fc99e Initial load
duke
parents:
diff changeset
1078 maxlrg = split_USE(def,b,n,inpidx,maxlrg,false,false, splits,slidx);
a61af66fc99e Initial load
duke
parents:
diff changeset
1079 // If it wasn't split bail
a61af66fc99e Initial load
duke
parents:
diff changeset
1080 if (!maxlrg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1081 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1082 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1083 insidx++; // Reset iterator to skip USE side split
a61af66fc99e Initial load
duke
parents:
diff changeset
1084 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1085 else { // DOWN, mem->mem copy
a61af66fc99e Initial load
duke
parents:
diff changeset
1086 // COPY UP & DOWN HERE - NO DEF - NO CISC SPILL
a61af66fc99e Initial load
duke
parents:
diff changeset
1087 // First Split-UP to move value into Register
a61af66fc99e Initial load
duke
parents:
diff changeset
1088 uint def_ideal = def->ideal_reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
1089 const RegMask* tmp_rm = Matcher::idealreg2regmask[def_ideal];
a61af66fc99e Initial load
duke
parents:
diff changeset
1090 Node *spill = new (C) MachSpillCopyNode(def, dmask, *tmp_rm);
a61af66fc99e Initial load
duke
parents:
diff changeset
1091 insert_proj( b, insidx, spill, maxlrg );
a61af66fc99e Initial load
duke
parents:
diff changeset
1092 // Then Split-DOWN as if previous Split was DEF
a61af66fc99e Initial load
duke
parents:
diff changeset
1093 maxlrg = split_USE(spill,b,n,inpidx,maxlrg,false,false, splits,slidx);
a61af66fc99e Initial load
duke
parents:
diff changeset
1094 // If it wasn't split bail
a61af66fc99e Initial load
duke
parents:
diff changeset
1095 if (!maxlrg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1096 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1097 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1098 insidx += 2; // Reset iterator to skip USE side splits
a61af66fc99e Initial load
duke
parents:
diff changeset
1099 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1100 } // End else no overlap
a61af66fc99e Initial load
duke
parents:
diff changeset
1101 } // End if dup == uup
a61af66fc99e Initial load
duke
parents:
diff changeset
1102 // dup != uup, so check dup for direction of Split
a61af66fc99e Initial load
duke
parents:
diff changeset
1103 else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1104 if( dup ) { // If UP, Split-DOWN and check Debug Info
a61af66fc99e Initial load
duke
parents:
diff changeset
1105 // If this node is already a SpillCopy, just patch the edge
a61af66fc99e Initial load
duke
parents:
diff changeset
1106 // except the case of spilling to stack.
a61af66fc99e Initial load
duke
parents:
diff changeset
1107 if( n->is_SpillCopy() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1108 RegMask tmp_rm(umask);
a61af66fc99e Initial load
duke
parents:
diff changeset
1109 tmp_rm.SUBTRACT(Matcher::STACK_ONLY_mask);
a61af66fc99e Initial load
duke
parents:
diff changeset
1110 if( dmask.overlap(tmp_rm) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1111 if( def != n->in(inpidx) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1112 n->set_req(inpidx, def);
a61af66fc99e Initial load
duke
parents:
diff changeset
1113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1114 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
1115 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1117 // COPY DOWN HERE - NO DEF - NO CISC SPILL
a61af66fc99e Initial load
duke
parents:
diff changeset
1118 maxlrg = split_USE(def,b,n,inpidx,maxlrg,false,false, splits,slidx);
a61af66fc99e Initial load
duke
parents:
diff changeset
1119 // If it wasn't split bail
a61af66fc99e Initial load
duke
parents:
diff changeset
1120 if (!maxlrg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1121 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1122 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1123 insidx++; // Reset iterator to skip USE side split
a61af66fc99e Initial load
duke
parents:
diff changeset
1124 // Check for debug-info split. Capture it for later
a61af66fc99e Initial load
duke
parents:
diff changeset
1125 // debug splits of the same value
a61af66fc99e Initial load
duke
parents:
diff changeset
1126 if (jvms && jvms->debug_start() <= inpidx && inpidx < oopoff)
a61af66fc99e Initial load
duke
parents:
diff changeset
1127 debug_defs[slidx] = n->in(inpidx);
a61af66fc99e Initial load
duke
parents:
diff changeset
1128
a61af66fc99e Initial load
duke
parents:
diff changeset
1129 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1130 else { // DOWN, Split-UP and check register pressure
a61af66fc99e Initial load
duke
parents:
diff changeset
1131 if( is_high_pressure( b, &lrgs(useidx), insidx ) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1132 // COPY UP HERE - NO DEF - CISC SPILL
a61af66fc99e Initial load
duke
parents:
diff changeset
1133 maxlrg = split_USE(def,b,n,inpidx,maxlrg,true,true, splits,slidx);
a61af66fc99e Initial load
duke
parents:
diff changeset
1134 // If it wasn't split bail
a61af66fc99e Initial load
duke
parents:
diff changeset
1135 if (!maxlrg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1136 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1138 insidx++; // Reset iterator to skip USE side split
a61af66fc99e Initial load
duke
parents:
diff changeset
1139 } else { // LRP
a61af66fc99e Initial load
duke
parents:
diff changeset
1140 // COPY UP HERE - WITH DEF - NO CISC SPILL
a61af66fc99e Initial load
duke
parents:
diff changeset
1141 maxlrg = split_USE(def,b,n,inpidx,maxlrg,true,false, splits,slidx);
a61af66fc99e Initial load
duke
parents:
diff changeset
1142 // If it wasn't split bail
a61af66fc99e Initial load
duke
parents:
diff changeset
1143 if (!maxlrg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1144 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1145 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1146 // Flag this lift-up in a low-pressure block as
a61af66fc99e Initial load
duke
parents:
diff changeset
1147 // already-spilled, so if it spills again it will
a61af66fc99e Initial load
duke
parents:
diff changeset
1148 // spill hard (instead of not spilling hard and
a61af66fc99e Initial load
duke
parents:
diff changeset
1149 // coalescing away).
a61af66fc99e Initial load
duke
parents:
diff changeset
1150 set_was_spilled(n->in(inpidx));
a61af66fc99e Initial load
duke
parents:
diff changeset
1151 // Since this is a new DEF, update Reachblock & UP
a61af66fc99e Initial load
duke
parents:
diff changeset
1152 Reachblock[slidx] = n->in(inpidx);
a61af66fc99e Initial load
duke
parents:
diff changeset
1153 UPblock[slidx] = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
1154 insidx++; // Reset iterator to skip USE side split
a61af66fc99e Initial load
duke
parents:
diff changeset
1155 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1156 } // End else DOWN
a61af66fc99e Initial load
duke
parents:
diff changeset
1157 } // End dup != uup
a61af66fc99e Initial load
duke
parents:
diff changeset
1158 } // End if Spill USE
a61af66fc99e Initial load
duke
parents:
diff changeset
1159 } // End For All Inputs
a61af66fc99e Initial load
duke
parents:
diff changeset
1160 } // End If not nullcheck
a61af66fc99e Initial load
duke
parents:
diff changeset
1161
a61af66fc99e Initial load
duke
parents:
diff changeset
1162 // ********** Handle DEFS **********
a61af66fc99e Initial load
duke
parents:
diff changeset
1163 // DEFS either Split DOWN in HRP regions or when the LRG is bound, or
a61af66fc99e Initial load
duke
parents:
diff changeset
1164 // just reset the Reaches info in LRP regions. DEFS must always update
a61af66fc99e Initial load
duke
parents:
diff changeset
1165 // UP info.
a61af66fc99e Initial load
duke
parents:
diff changeset
1166 if( deflrg.reg() >= LRG::SPILL_REG ) { // Spilled?
a61af66fc99e Initial load
duke
parents:
diff changeset
1167 uint slidx = lrg2reach[defidx];
a61af66fc99e Initial load
duke
parents:
diff changeset
1168 // Add to defs list for later assignment of new live range number
a61af66fc99e Initial load
duke
parents:
diff changeset
1169 defs->push(n);
a61af66fc99e Initial load
duke
parents:
diff changeset
1170 // Set a flag on the Node indicating it has already spilled.
a61af66fc99e Initial load
duke
parents:
diff changeset
1171 // Only do it for capacity spills not conflict spills.
a61af66fc99e Initial load
duke
parents:
diff changeset
1172 if( !deflrg._direct_conflict )
a61af66fc99e Initial load
duke
parents:
diff changeset
1173 set_was_spilled(n);
a61af66fc99e Initial load
duke
parents:
diff changeset
1174 assert(!n->is_Phi(),"Cannot insert Phi into DEFS list");
a61af66fc99e Initial load
duke
parents:
diff changeset
1175 // Grab UP info for DEF
a61af66fc99e Initial load
duke
parents:
diff changeset
1176 const RegMask &dmask = n->out_RegMask();
a61af66fc99e Initial load
duke
parents:
diff changeset
1177 bool defup = dmask.is_UP();
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 3842
diff changeset
1178 int ireg = n->ideal_reg();
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 3842
diff changeset
1179 bool is_vect = RegMask::is_vector(ireg);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1180 // Only split at Def if this is a HRP block or bound (and spilled once)
a61af66fc99e Initial load
duke
parents:
diff changeset
1181 if( !n->rematerialize() &&
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 3842
diff changeset
1182 (((dmask.is_bound(ireg) || !is_vect && dmask.is_misaligned_pair()) &&
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 3842
diff changeset
1183 (deflrg._direct_conflict || deflrg._must_spill)) ||
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1184 // Check for LRG being up in a register and we are inside a high
a61af66fc99e Initial load
duke
parents:
diff changeset
1185 // pressure area. Spill it down immediately.
a61af66fc99e Initial load
duke
parents:
diff changeset
1186 (defup && is_high_pressure(b,&deflrg,insidx))) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1187 assert( !n->rematerialize(), "" );
a61af66fc99e Initial load
duke
parents:
diff changeset
1188 assert( !n->is_SpillCopy(), "" );
a61af66fc99e Initial load
duke
parents:
diff changeset
1189 // Do a split at the def site.
a61af66fc99e Initial load
duke
parents:
diff changeset
1190 maxlrg = split_DEF( n, b, insidx, maxlrg, Reachblock, debug_defs, splits, slidx );
a61af66fc99e Initial load
duke
parents:
diff changeset
1191 // If it wasn't split bail
a61af66fc99e Initial load
duke
parents:
diff changeset
1192 if (!maxlrg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1193 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1194 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1195 // Split DEF's Down
a61af66fc99e Initial load
duke
parents:
diff changeset
1196 UPblock[slidx] = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1197 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
1198 // DEBUG
a61af66fc99e Initial load
duke
parents:
diff changeset
1199 if( trace_spilling() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1200 tty->print("\nNew Split DOWN DEF of Spill Idx ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1201 tty->print("%d, UP %d:\n",slidx,false);
a61af66fc99e Initial load
duke
parents:
diff changeset
1202 n->dump();
a61af66fc99e Initial load
duke
parents:
diff changeset
1203 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1204 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1205 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1206 else { // Neither bound nor HRP, must be LRP
a61af66fc99e Initial load
duke
parents:
diff changeset
1207 // otherwise, just record the def
a61af66fc99e Initial load
duke
parents:
diff changeset
1208 Reachblock[slidx] = n;
a61af66fc99e Initial load
duke
parents:
diff changeset
1209 // UP should come from the outRegmask() of the DEF
a61af66fc99e Initial load
duke
parents:
diff changeset
1210 UPblock[slidx] = defup;
a61af66fc99e Initial load
duke
parents:
diff changeset
1211 // Update debug list of reaching down definitions, kill if DEF is UP
a61af66fc99e Initial load
duke
parents:
diff changeset
1212 debug_defs[slidx] = defup ? NULL : n;
a61af66fc99e Initial load
duke
parents:
diff changeset
1213 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
1214 // DEBUG
a61af66fc99e Initial load
duke
parents:
diff changeset
1215 if( trace_spilling() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1216 tty->print("\nNew DEF of Spill Idx ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1217 tty->print("%d, UP %d:\n",slidx,defup);
a61af66fc99e Initial load
duke
parents:
diff changeset
1218 n->dump();
a61af66fc99e Initial load
duke
parents:
diff changeset
1219 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1220 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1221 } // End else LRP
a61af66fc99e Initial load
duke
parents:
diff changeset
1222 } // End if spill def
a61af66fc99e Initial load
duke
parents:
diff changeset
1223
a61af66fc99e Initial load
duke
parents:
diff changeset
1224 // ********** Split Left Over Mem-Mem Moves **********
a61af66fc99e Initial load
duke
parents:
diff changeset
1225 // Check for mem-mem copies and split them now. Do not do this
a61af66fc99e Initial load
duke
parents:
diff changeset
1226 // to copies about to be spilled; they will be Split shortly.
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1227 if (copyidx) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1228 Node *use = n->in(copyidx);
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1229 uint useidx = _lrg_map.find_id(use);
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1230 if (useidx < _lrg_map.max_lrg_id() && // This is not a new split
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1231 OptoReg::is_stack(deflrg.reg()) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1232 deflrg.reg() < LRG::SPILL_REG ) { // And DEF is from stack
a61af66fc99e Initial load
duke
parents:
diff changeset
1233 LRG &uselrg = lrgs(useidx);
a61af66fc99e Initial load
duke
parents:
diff changeset
1234 if( OptoReg::is_stack(uselrg.reg()) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1235 uselrg.reg() < LRG::SPILL_REG && // USE is from stack
a61af66fc99e Initial load
duke
parents:
diff changeset
1236 deflrg.reg() != uselrg.reg() ) { // Not trivially removed
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6632
diff changeset
1237 uint def_ideal_reg = n->bottom_type()->ideal_reg();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1238 const RegMask &def_rm = *Matcher::idealreg2regmask[def_ideal_reg];
a61af66fc99e Initial load
duke
parents:
diff changeset
1239 const RegMask &use_rm = n->in_RegMask(copyidx);
a61af66fc99e Initial load
duke
parents:
diff changeset
1240 if( def_rm.overlap(use_rm) && n->is_SpillCopy() ) { // Bug 4707800, 'n' may be a storeSSL
a61af66fc99e Initial load
duke
parents:
diff changeset
1241 if (C->check_node_count(NodeLimitFudgeFactor, out_of_nodes)) { // Check when generating nodes
a61af66fc99e Initial load
duke
parents:
diff changeset
1242 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1243 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1244 Node *spill = new (C) MachSpillCopyNode(use,use_rm,def_rm);
a61af66fc99e Initial load
duke
parents:
diff changeset
1245 n->set_req(copyidx,spill);
a61af66fc99e Initial load
duke
parents:
diff changeset
1246 n->as_MachSpillCopy()->set_in_RegMask(def_rm);
a61af66fc99e Initial load
duke
parents:
diff changeset
1247 // Put the spill just before the copy
a61af66fc99e Initial load
duke
parents:
diff changeset
1248 insert_proj( b, insidx++, spill, maxlrg++ );
a61af66fc99e Initial load
duke
parents:
diff changeset
1249 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1250 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1251 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1252 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1253 } // End For All Instructions in Block - Non-PHI Pass
a61af66fc99e Initial load
duke
parents:
diff changeset
1254
a61af66fc99e Initial load
duke
parents:
diff changeset
1255 // Check if each LRG is live out of this block so as not to propagate
a61af66fc99e Initial load
duke
parents:
diff changeset
1256 // beyond the last use of a LRG.
a61af66fc99e Initial load
duke
parents:
diff changeset
1257 for( slidx = 0; slidx < spill_cnt; slidx++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1258 uint defidx = lidxs.at(slidx);
a61af66fc99e Initial load
duke
parents:
diff changeset
1259 IndexSet *liveout = _live->live(b);
a61af66fc99e Initial load
duke
parents:
diff changeset
1260 if( !liveout->member(defidx) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1261 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
1262 // The index defidx is not live. Check the liveout array to ensure that
a61af66fc99e Initial load
duke
parents:
diff changeset
1263 // it contains no members which compress to defidx. Finding such an
a61af66fc99e Initial load
duke
parents:
diff changeset
1264 // instance may be a case to add liveout adjustment in compress_uf_map().
a61af66fc99e Initial load
duke
parents:
diff changeset
1265 // See 5063219.
a61af66fc99e Initial load
duke
parents:
diff changeset
1266 uint member;
a61af66fc99e Initial load
duke
parents:
diff changeset
1267 IndexSetIterator isi(liveout);
a61af66fc99e Initial load
duke
parents:
diff changeset
1268 while ((member = isi.next()) != 0) {
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1269 assert(defidx != _lrg_map.find_const(member), "Live out member has not been compressed");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1270 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1271 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1272 Reachblock[slidx] = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1273 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1274 assert(Reachblock[slidx] != NULL,"No reaching definition for liveout value");
a61af66fc99e Initial load
duke
parents:
diff changeset
1275 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1276 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1277 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
1278 if( trace_spilling() )
a61af66fc99e Initial load
duke
parents:
diff changeset
1279 b->dump();
a61af66fc99e Initial load
duke
parents:
diff changeset
1280 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1281 } // End For All Blocks
a61af66fc99e Initial load
duke
parents:
diff changeset
1282
a61af66fc99e Initial load
duke
parents:
diff changeset
1283 //----------PASS 2----------
a61af66fc99e Initial load
duke
parents:
diff changeset
1284 // Reset all DEF live range numbers here
a61af66fc99e Initial load
duke
parents:
diff changeset
1285 for( insidx = 0; insidx < defs->size(); insidx++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1286 // Grab the def
a61af66fc99e Initial load
duke
parents:
diff changeset
1287 n1 = defs->at(insidx);
a61af66fc99e Initial load
duke
parents:
diff changeset
1288 // Set new lidx for DEF
a61af66fc99e Initial load
duke
parents:
diff changeset
1289 new_lrg(n1, maxlrg++);
a61af66fc99e Initial load
duke
parents:
diff changeset
1290 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1291 //----------Phi Node Splitting----------
a61af66fc99e Initial load
duke
parents:
diff changeset
1292 // Clean up a phi here, and assign a new live range number
a61af66fc99e Initial load
duke
parents:
diff changeset
1293 // Cycle through this block's predecessors, collecting Reaches
a61af66fc99e Initial load
duke
parents:
diff changeset
1294 // info for each spilled LRG and update edges.
a61af66fc99e Initial load
duke
parents:
diff changeset
1295 // Walk the phis list to patch inputs, split phis, and name phis
2016
361783318e7e 7004940: CTW: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG
never
parents: 1972
diff changeset
1296 uint lrgs_before_phi_split = maxlrg;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1297 for( insidx = 0; insidx < phis->size(); insidx++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1298 Node *phi = phis->at(insidx);
a61af66fc99e Initial load
duke
parents:
diff changeset
1299 assert(phi->is_Phi(),"This list must only contain Phi Nodes");
12023
d1034bd8cefc 8022284: Hide internal data structure in PhaseCFG
adlertz
parents: 10395
diff changeset
1300 Block *b = _cfg.get_block_for_node(phi);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1301 // Grab the live range number
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1302 uint lidx = _lrg_map.find_id(phi);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1303 uint slidx = lrg2reach[lidx];
a61af66fc99e Initial load
duke
parents:
diff changeset
1304 // Update node to lidx map
a61af66fc99e Initial load
duke
parents:
diff changeset
1305 new_lrg(phi, maxlrg++);
a61af66fc99e Initial load
duke
parents:
diff changeset
1306 // Get PASS1's up/down decision for the block.
a61af66fc99e Initial load
duke
parents:
diff changeset
1307 int phi_up = !!UP_entry[slidx]->test(b->_pre_order);
a61af66fc99e Initial load
duke
parents:
diff changeset
1308
a61af66fc99e Initial load
duke
parents:
diff changeset
1309 // Force down if double-spilling live range
a61af66fc99e Initial load
duke
parents:
diff changeset
1310 if( lrgs(lidx)._was_spilled1 )
a61af66fc99e Initial load
duke
parents:
diff changeset
1311 phi_up = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
1312
a61af66fc99e Initial load
duke
parents:
diff changeset
1313 // When splitting a Phi we an split it normal or "inverted".
a61af66fc99e Initial load
duke
parents:
diff changeset
1314 // An inverted split makes the splits target the Phi's UP/DOWN
a61af66fc99e Initial load
duke
parents:
diff changeset
1315 // sense inverted; then the Phi is followed by a final def-side
a61af66fc99e Initial load
duke
parents:
diff changeset
1316 // split to invert back. It changes which blocks the spill code
a61af66fc99e Initial load
duke
parents:
diff changeset
1317 // goes in.
a61af66fc99e Initial load
duke
parents:
diff changeset
1318
a61af66fc99e Initial load
duke
parents:
diff changeset
1319 // Walk the predecessor blocks and assign the reaching def to the Phi.
a61af66fc99e Initial load
duke
parents:
diff changeset
1320 // Split Phi nodes by placing USE side splits wherever the reaching
a61af66fc99e Initial load
duke
parents:
diff changeset
1321 // DEF has the wrong UP/DOWN value.
a61af66fc99e Initial load
duke
parents:
diff changeset
1322 for( uint i = 1; i < b->num_preds(); i++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1323 // Get predecessor block pre-order number
12023
d1034bd8cefc 8022284: Hide internal data structure in PhaseCFG
adlertz
parents: 10395
diff changeset
1324 Block *pred = _cfg.get_block_for_node(b->pred(i));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1325 pidx = pred->_pre_order;
a61af66fc99e Initial load
duke
parents:
diff changeset
1326 // Grab reaching def
a61af66fc99e Initial load
duke
parents:
diff changeset
1327 Node *def = Reaches[pidx][slidx];
a61af66fc99e Initial load
duke
parents:
diff changeset
1328 assert( def, "must have reaching def" );
a61af66fc99e Initial load
duke
parents:
diff changeset
1329 // If input up/down sense and reg-pressure DISagree
10395
b274ac1dbe11 8005956: C2: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG defined in this block
adlertz
parents: 10111
diff changeset
1330 if (def->rematerialize() && contains_no_live_range_input(def)) {
2016
361783318e7e 7004940: CTW: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG
never
parents: 1972
diff changeset
1331 // Place the rematerialized node above any MSCs created during
361783318e7e 7004940: CTW: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG
never
parents: 1972
diff changeset
1332 // phi node splitting. end_idx points at the insertion point
361783318e7e 7004940: CTW: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG
never
parents: 1972
diff changeset
1333 // so look at the node before it.
361783318e7e 7004940: CTW: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG
never
parents: 1972
diff changeset
1334 int insert = pred->end_idx();
361783318e7e 7004940: CTW: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG
never
parents: 1972
diff changeset
1335 while (insert >= 1 &&
12167
650868c062a9 8023691: Create interface for nodes in class Block
adlertz
parents: 12075
diff changeset
1336 pred->get_node(insert - 1)->is_SpillCopy() &&
650868c062a9 8023691: Create interface for nodes in class Block
adlertz
parents: 12075
diff changeset
1337 _lrg_map.find(pred->get_node(insert - 1)) >= lrgs_before_phi_split) {
2016
361783318e7e 7004940: CTW: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG
never
parents: 1972
diff changeset
1338 insert--;
361783318e7e 7004940: CTW: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG
never
parents: 1972
diff changeset
1339 }
12872
98692a2d36d7 8013830: [parfait] Uninitialised pointer 'Reachblock' may be used as argument
adlertz
parents: 12167
diff changeset
1340 // since the def cannot contain any live range input, we can pass in NULL as Reachlock parameter
98692a2d36d7 8013830: [parfait] Uninitialised pointer 'Reachblock' may be used as argument
adlertz
parents: 12167
diff changeset
1341 def = split_Rematerialize(def, pred, insert, maxlrg, splits, slidx, lrg2reach, NULL, false);
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1342 if (!def) {
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1343 return 0; // Bail out
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1344 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1345 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1346 // Update the Phi's input edge array
a61af66fc99e Initial load
duke
parents:
diff changeset
1347 phi->set_req(i,def);
a61af66fc99e Initial load
duke
parents:
diff changeset
1348 // Grab the UP/DOWN sense for the input
a61af66fc99e Initial load
duke
parents:
diff changeset
1349 u1 = UP[pidx][slidx];
a61af66fc99e Initial load
duke
parents:
diff changeset
1350 if( u1 != (phi_up != 0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1351 maxlrg = split_USE(def, b, phi, i, maxlrg, !u1, false, splits,slidx);
a61af66fc99e Initial load
duke
parents:
diff changeset
1352 // If it wasn't split bail
a61af66fc99e Initial load
duke
parents:
diff changeset
1353 if (!maxlrg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1354 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1355 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1356 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1357 } // End for all inputs to the Phi
a61af66fc99e Initial load
duke
parents:
diff changeset
1358 } // End for all Phi Nodes
a61af66fc99e Initial load
duke
parents:
diff changeset
1359 // Update _maxlrg to save Union asserts
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1360 _lrg_map.set_max_lrg_id(maxlrg);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1361
a61af66fc99e Initial load
duke
parents:
diff changeset
1362
a61af66fc99e Initial load
duke
parents:
diff changeset
1363 //----------PASS 3----------
a61af66fc99e Initial load
duke
parents:
diff changeset
1364 // Pass over all Phi's to union the live ranges
a61af66fc99e Initial load
duke
parents:
diff changeset
1365 for( insidx = 0; insidx < phis->size(); insidx++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1366 Node *phi = phis->at(insidx);
a61af66fc99e Initial load
duke
parents:
diff changeset
1367 assert(phi->is_Phi(),"This list must only contain Phi Nodes");
a61af66fc99e Initial load
duke
parents:
diff changeset
1368 // Walk all inputs to Phi and Union input live range with Phi live range
a61af66fc99e Initial load
duke
parents:
diff changeset
1369 for( uint i = 1; i < phi->req(); i++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1370 // Grab the input node
a61af66fc99e Initial load
duke
parents:
diff changeset
1371 Node *n = phi->in(i);
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1372 assert(n, "node should exist");
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1373 uint lidx = _lrg_map.find(n);
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1374 uint pidx = _lrg_map.find(phi);
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1375 if (lidx < pidx) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1376 Union(n, phi);
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1377 }
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1378 else if(lidx > pidx) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1379 Union(phi, n);
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1380 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1381 } // End for all inputs to the Phi Node
a61af66fc99e Initial load
duke
parents:
diff changeset
1382 } // End for all Phi Nodes
a61af66fc99e Initial load
duke
parents:
diff changeset
1383 // Now union all two address instructions
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1384 for (insidx = 0; insidx < defs->size(); insidx++) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1385 // Grab the def
a61af66fc99e Initial load
duke
parents:
diff changeset
1386 n1 = defs->at(insidx);
a61af66fc99e Initial load
duke
parents:
diff changeset
1387 // Set new lidx for DEF & handle 2-addr instructions
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1388 if (n1->is_Mach() && ((twoidx = n1->as_Mach()->two_adr()) != 0)) {
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1389 assert(_lrg_map.find(n1->in(twoidx)) < maxlrg,"Assigning bad live range index");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1390 // Union the input and output live ranges
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1391 uint lr1 = _lrg_map.find(n1);
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1392 uint lr2 = _lrg_map.find(n1->in(twoidx));
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1393 if (lr1 < lr2) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1394 Union(n1, n1->in(twoidx));
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1395 }
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1396 else if (lr1 > lr2) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1397 Union(n1->in(twoidx), n1);
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1398 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1399 } // End if two address
a61af66fc99e Initial load
duke
parents:
diff changeset
1400 } // End for all defs
a61af66fc99e Initial load
duke
parents:
diff changeset
1401 // DEBUG
a61af66fc99e Initial load
duke
parents:
diff changeset
1402 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
1403 // Validate all live range index assignments
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
1404 for (bidx = 0; bidx < _cfg.number_of_blocks(); bidx++) {
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
1405 b = _cfg.get_block(bidx);
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1406 for (insidx = 0; insidx <= b->end_idx(); insidx++) {
12167
650868c062a9 8023691: Create interface for nodes in class Block
adlertz
parents: 12075
diff changeset
1407 Node *n = b->get_node(insidx);
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1408 uint defidx = _lrg_map.find(n);
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1409 assert(defidx < _lrg_map.max_lrg_id(), "Bad live range index in Split");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1410 assert(defidx < maxlrg,"Bad live range index in Split");
a61af66fc99e Initial load
duke
parents:
diff changeset
1411 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1412 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1413 // Issue a warning if splitting made no progress
a61af66fc99e Initial load
duke
parents:
diff changeset
1414 int noprogress = 0;
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1415 for (slidx = 0; slidx < spill_cnt; slidx++) {
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
1416 if (PrintOpto && WizardMode && splits.at(slidx) == 0) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1417 tty->print_cr("Failed to split live range %d", lidxs.at(slidx));
a61af66fc99e Initial load
duke
parents:
diff changeset
1418 //BREAKPOINT;
a61af66fc99e Initial load
duke
parents:
diff changeset
1419 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1420 else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1421 noprogress++;
a61af66fc99e Initial load
duke
parents:
diff changeset
1422 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1423 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1424 if(!noprogress) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1425 tty->print_cr("Failed to make progress in Split");
a61af66fc99e Initial load
duke
parents:
diff changeset
1426 //BREAKPOINT;
a61af66fc99e Initial load
duke
parents:
diff changeset
1427 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1428 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1429 // Return updated count of live ranges
a61af66fc99e Initial load
duke
parents:
diff changeset
1430 return maxlrg;
a61af66fc99e Initial load
duke
parents:
diff changeset
1431 }