Mercurial > hg > truffle
annotate src/share/vm/opto/connode.cpp @ 216:8d191a7697e2
6715633: when matching a memory node the adr_type should not change
Summary: verify the adr_type of a mach node was not changed
Reviewed-by: rasbold, never
author | kvn |
---|---|
date | Fri, 20 Jun 2008 11:10:05 -0700 |
parents | 7793bd37a336 |
children | 1e026f8da827 |
rev | line source |
---|---|
0 | 1 /* |
2 * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 // Optimization - Graph Style | |
26 | |
27 #include "incls/_precompiled.incl" | |
28 #include "incls/_connode.cpp.incl" | |
29 | |
30 //============================================================================= | |
31 //------------------------------hash------------------------------------------- | |
32 uint ConNode::hash() const { | |
33 return (uintptr_t)in(TypeFunc::Control) + _type->hash(); | |
34 } | |
35 | |
36 //------------------------------make------------------------------------------- | |
37 ConNode *ConNode::make( Compile* C, const Type *t ) { | |
38 switch( t->basic_type() ) { | |
39 case T_INT: return new (C, 1) ConINode( t->is_int() ); | |
40 case T_LONG: return new (C, 1) ConLNode( t->is_long() ); | |
41 case T_FLOAT: return new (C, 1) ConFNode( t->is_float_constant() ); | |
42 case T_DOUBLE: return new (C, 1) ConDNode( t->is_double_constant() ); | |
43 case T_VOID: return new (C, 1) ConNode ( Type::TOP ); | |
44 case T_OBJECT: return new (C, 1) ConPNode( t->is_oopptr() ); | |
164
c436414a719e
6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents:
163
diff
changeset
|
45 case T_ARRAY: return new (C, 1) ConPNode( t->is_aryptr() ); |
0 | 46 case T_ADDRESS: return new (C, 1) ConPNode( t->is_ptr() ); |
168
7793bd37a336
6705887: Compressed Oops: generate x64 addressing and implicit null checks with narrow oops
kvn
parents:
164
diff
changeset
|
47 case T_NARROWOOP: return new (C, 1) ConNNode( t->is_narrowoop() ); |
0 | 48 // Expected cases: TypePtr::NULL_PTR, any is_rawptr() |
49 // Also seen: AnyPtr(TopPTR *+top); from command line: | |
50 // r -XX:+PrintOpto -XX:CIStart=285 -XX:+CompileTheWorld -XX:CompileTheWorldStartAt=660 | |
51 // %%%% Stop using TypePtr::NULL_PTR to represent nulls: use either TypeRawPtr::NULL_PTR | |
52 // or else TypeOopPtr::NULL_PTR. Then set Type::_basic_type[AnyPtr] = T_ILLEGAL | |
53 } | |
54 ShouldNotReachHere(); | |
55 return NULL; | |
56 } | |
57 | |
58 //============================================================================= | |
59 /* | |
60 The major change is for CMoveP and StrComp. They have related but slightly | |
61 different problems. They both take in TWO oops which are both null-checked | |
62 independently before the using Node. After CCP removes the CastPP's they need | |
63 to pick up the guarding test edge - in this case TWO control edges. I tried | |
64 various solutions, all have problems: | |
65 | |
66 (1) Do nothing. This leads to a bug where we hoist a Load from a CMoveP or a | |
67 StrComp above a guarding null check. I've seen both cases in normal -Xcomp | |
68 testing. | |
69 | |
70 (2) Plug the control edge from 1 of the 2 oops in. Apparent problem here is | |
71 to figure out which test post-dominates. The real problem is that it doesn't | |
72 matter which one you pick. After you pick up, the dominating-test elider in | |
73 IGVN can remove the test and allow you to hoist up to the dominating test on | |
74 the choosen oop bypassing the test on the not-choosen oop. Seen in testing. | |
75 Oops. | |
76 | |
77 (3) Leave the CastPP's in. This makes the graph more accurate in some sense; | |
78 we get to keep around the knowledge that an oop is not-null after some test. | |
79 Alas, the CastPP's interfere with GVN (some values are the regular oop, some | |
80 are the CastPP of the oop, all merge at Phi's which cannot collapse, etc). | |
81 This cost us 10% on SpecJVM, even when I removed some of the more trivial | |
82 cases in the optimizer. Removing more useless Phi's started allowing Loads to | |
83 illegally float above null checks. I gave up on this approach. | |
84 | |
85 (4) Add BOTH control edges to both tests. Alas, too much code knows that | |
86 control edges are in slot-zero ONLY. Many quick asserts fail; no way to do | |
87 this one. Note that I really want to allow the CMoveP to float and add both | |
88 control edges to the dependent Load op - meaning I can select early but I | |
89 cannot Load until I pass both tests. | |
90 | |
91 (5) Do not hoist CMoveP and StrComp. To this end I added the v-call | |
92 depends_only_on_test(). No obvious performance loss on Spec, but we are | |
93 clearly conservative on CMoveP (also so on StrComp but that's unlikely to | |
94 matter ever). | |
95 | |
96 */ | |
97 | |
98 | |
99 //------------------------------Ideal------------------------------------------ | |
100 // Return a node which is more "ideal" than the current node. | |
101 // Move constants to the right. | |
102 Node *CMoveNode::Ideal(PhaseGVN *phase, bool can_reshape) { | |
103 if( in(0) && remove_dead_region(phase, can_reshape) ) return this; | |
104 assert( !phase->eqv(in(Condition), this) && | |
105 !phase->eqv(in(IfFalse), this) && | |
106 !phase->eqv(in(IfTrue), this), "dead loop in CMoveNode::Ideal" ); | |
107 if( phase->type(in(Condition)) == Type::TOP ) | |
108 return NULL; // return NULL when Condition is dead | |
109 | |
110 if( in(IfFalse)->is_Con() && !in(IfTrue)->is_Con() ) { | |
111 if( in(Condition)->is_Bool() ) { | |
112 BoolNode* b = in(Condition)->as_Bool(); | |
113 BoolNode* b2 = b->negate(phase); | |
114 return make( phase->C, in(Control), phase->transform(b2), in(IfTrue), in(IfFalse), _type ); | |
115 } | |
116 } | |
117 return NULL; | |
118 } | |
119 | |
120 //------------------------------is_cmove_id------------------------------------ | |
121 // Helper function to check for CMOVE identity. Shared with PhiNode::Identity | |
122 Node *CMoveNode::is_cmove_id( PhaseTransform *phase, Node *cmp, Node *t, Node *f, BoolNode *b ) { | |
123 // Check for Cmp'ing and CMove'ing same values | |
124 if( (phase->eqv(cmp->in(1),f) && | |
125 phase->eqv(cmp->in(2),t)) || | |
126 // Swapped Cmp is OK | |
127 (phase->eqv(cmp->in(2),f) && | |
128 phase->eqv(cmp->in(1),t)) ) { | |
129 // Check for "(t==f)?t:f;" and replace with "f" | |
130 if( b->_test._test == BoolTest::eq ) | |
131 return f; | |
132 // Allow the inverted case as well | |
133 // Check for "(t!=f)?t:f;" and replace with "t" | |
134 if( b->_test._test == BoolTest::ne ) | |
135 return t; | |
136 } | |
137 return NULL; | |
138 } | |
139 | |
140 //------------------------------Identity--------------------------------------- | |
141 // Conditional-move is an identity if both inputs are the same, or the test | |
142 // true or false. | |
143 Node *CMoveNode::Identity( PhaseTransform *phase ) { | |
144 if( phase->eqv(in(IfFalse),in(IfTrue)) ) // C-moving identical inputs? | |
145 return in(IfFalse); // Then it doesn't matter | |
146 if( phase->type(in(Condition)) == TypeInt::ZERO ) | |
147 return in(IfFalse); // Always pick left(false) input | |
148 if( phase->type(in(Condition)) == TypeInt::ONE ) | |
149 return in(IfTrue); // Always pick right(true) input | |
150 | |
151 // Check for CMove'ing a constant after comparing against the constant. | |
152 // Happens all the time now, since if we compare equality vs a constant in | |
153 // the parser, we "know" the variable is constant on one path and we force | |
154 // it. Thus code like "if( x==0 ) {/*EMPTY*/}" ends up inserting a | |
155 // conditional move: "x = (x==0)?0:x;". Yucko. This fix is slightly more | |
156 // general in that we don't need constants. | |
157 if( in(Condition)->is_Bool() ) { | |
158 BoolNode *b = in(Condition)->as_Bool(); | |
159 Node *cmp = b->in(1); | |
160 if( cmp->is_Cmp() ) { | |
161 Node *id = is_cmove_id( phase, cmp, in(IfTrue), in(IfFalse), b ); | |
162 if( id ) return id; | |
163 } | |
164 } | |
165 | |
166 return this; | |
167 } | |
168 | |
169 //------------------------------Value------------------------------------------ | |
170 // Result is the meet of inputs | |
171 const Type *CMoveNode::Value( PhaseTransform *phase ) const { | |
172 if( phase->type(in(Condition)) == Type::TOP ) | |
173 return Type::TOP; | |
174 return phase->type(in(IfFalse))->meet(phase->type(in(IfTrue))); | |
175 } | |
176 | |
177 //------------------------------make------------------------------------------- | |
178 // Make a correctly-flavored CMove. Since _type is directly determined | |
179 // from the inputs we do not need to specify it here. | |
180 CMoveNode *CMoveNode::make( Compile *C, Node *c, Node *bol, Node *left, Node *right, const Type *t ) { | |
181 switch( t->basic_type() ) { | |
182 case T_INT: return new (C, 4) CMoveINode( bol, left, right, t->is_int() ); | |
183 case T_FLOAT: return new (C, 4) CMoveFNode( bol, left, right, t ); | |
184 case T_DOUBLE: return new (C, 4) CMoveDNode( bol, left, right, t ); | |
185 case T_LONG: return new (C, 4) CMoveLNode( bol, left, right, t->is_long() ); | |
186 case T_OBJECT: return new (C, 4) CMovePNode( c, bol, left, right, t->is_oopptr() ); | |
187 case T_ADDRESS: return new (C, 4) CMovePNode( c, bol, left, right, t->is_ptr() ); | |
164
c436414a719e
6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents:
163
diff
changeset
|
188 case T_NARROWOOP: return new (C, 4) CMoveNNode( c, bol, left, right, t ); |
0 | 189 default: |
190 ShouldNotReachHere(); | |
191 return NULL; | |
192 } | |
193 } | |
194 | |
195 //============================================================================= | |
196 //------------------------------Ideal------------------------------------------ | |
197 // Return a node which is more "ideal" than the current node. | |
198 // Check for conversions to boolean | |
199 Node *CMoveINode::Ideal(PhaseGVN *phase, bool can_reshape) { | |
200 // Try generic ideal's first | |
201 Node *x = CMoveNode::Ideal(phase, can_reshape); | |
202 if( x ) return x; | |
203 | |
204 // If zero is on the left (false-case, no-move-case) it must mean another | |
205 // constant is on the right (otherwise the shared CMove::Ideal code would | |
206 // have moved the constant to the right). This situation is bad for Intel | |
207 // and a don't-care for Sparc. It's bad for Intel because the zero has to | |
208 // be manifested in a register with a XOR which kills flags, which are live | |
209 // on input to the CMoveI, leading to a situation which causes excessive | |
210 // spilling on Intel. For Sparc, if the zero in on the left the Sparc will | |
211 // zero a register via G0 and conditionally-move the other constant. If the | |
212 // zero is on the right, the Sparc will load the first constant with a | |
213 // 13-bit set-lo and conditionally move G0. See bug 4677505. | |
214 if( phase->type(in(IfFalse)) == TypeInt::ZERO && !(phase->type(in(IfTrue)) == TypeInt::ZERO) ) { | |
215 if( in(Condition)->is_Bool() ) { | |
216 BoolNode* b = in(Condition)->as_Bool(); | |
217 BoolNode* b2 = b->negate(phase); | |
218 return make( phase->C, in(Control), phase->transform(b2), in(IfTrue), in(IfFalse), _type ); | |
219 } | |
220 } | |
221 | |
222 // Now check for booleans | |
223 int flip = 0; | |
224 | |
225 // Check for picking from zero/one | |
226 if( phase->type(in(IfFalse)) == TypeInt::ZERO && phase->type(in(IfTrue)) == TypeInt::ONE ) { | |
227 flip = 1 - flip; | |
228 } else if( phase->type(in(IfFalse)) == TypeInt::ONE && phase->type(in(IfTrue)) == TypeInt::ZERO ) { | |
229 } else return NULL; | |
230 | |
231 // Check for eq/ne test | |
232 if( !in(1)->is_Bool() ) return NULL; | |
233 BoolNode *bol = in(1)->as_Bool(); | |
234 if( bol->_test._test == BoolTest::eq ) { | |
235 } else if( bol->_test._test == BoolTest::ne ) { | |
236 flip = 1-flip; | |
237 } else return NULL; | |
238 | |
239 // Check for vs 0 or 1 | |
240 if( !bol->in(1)->is_Cmp() ) return NULL; | |
241 const CmpNode *cmp = bol->in(1)->as_Cmp(); | |
242 if( phase->type(cmp->in(2)) == TypeInt::ZERO ) { | |
243 } else if( phase->type(cmp->in(2)) == TypeInt::ONE ) { | |
244 // Allow cmp-vs-1 if the other input is bounded by 0-1 | |
245 if( phase->type(cmp->in(1)) != TypeInt::BOOL ) | |
246 return NULL; | |
247 flip = 1 - flip; | |
248 } else return NULL; | |
249 | |
250 // Convert to a bool (flipped) | |
251 // Build int->bool conversion | |
252 #ifndef PRODUCT | |
253 if( PrintOpto ) tty->print_cr("CMOV to I2B"); | |
254 #endif | |
255 Node *n = new (phase->C, 2) Conv2BNode( cmp->in(1) ); | |
256 if( flip ) | |
257 n = new (phase->C, 3) XorINode( phase->transform(n), phase->intcon(1) ); | |
258 | |
259 return n; | |
260 } | |
261 | |
262 //============================================================================= | |
263 //------------------------------Ideal------------------------------------------ | |
264 // Return a node which is more "ideal" than the current node. | |
265 // Check for absolute value | |
266 Node *CMoveFNode::Ideal(PhaseGVN *phase, bool can_reshape) { | |
267 // Try generic ideal's first | |
268 Node *x = CMoveNode::Ideal(phase, can_reshape); | |
269 if( x ) return x; | |
270 | |
271 int cmp_zero_idx = 0; // Index of compare input where to look for zero | |
272 int phi_x_idx = 0; // Index of phi input where to find naked x | |
273 | |
274 // Find the Bool | |
275 if( !in(1)->is_Bool() ) return NULL; | |
276 BoolNode *bol = in(1)->as_Bool(); | |
277 // Check bool sense | |
278 switch( bol->_test._test ) { | |
279 case BoolTest::lt: cmp_zero_idx = 1; phi_x_idx = IfTrue; break; | |
280 case BoolTest::le: cmp_zero_idx = 2; phi_x_idx = IfFalse; break; | |
281 case BoolTest::gt: cmp_zero_idx = 2; phi_x_idx = IfTrue; break; | |
282 case BoolTest::ge: cmp_zero_idx = 1; phi_x_idx = IfFalse; break; | |
283 default: return NULL; break; | |
284 } | |
285 | |
286 // Find zero input of CmpF; the other input is being abs'd | |
287 Node *cmpf = bol->in(1); | |
288 if( cmpf->Opcode() != Op_CmpF ) return NULL; | |
289 Node *X = NULL; | |
290 bool flip = false; | |
291 if( phase->type(cmpf->in(cmp_zero_idx)) == TypeF::ZERO ) { | |
292 X = cmpf->in(3 - cmp_zero_idx); | |
293 } else if (phase->type(cmpf->in(3 - cmp_zero_idx)) == TypeF::ZERO) { | |
294 // The test is inverted, we should invert the result... | |
295 X = cmpf->in(cmp_zero_idx); | |
296 flip = true; | |
297 } else { | |
298 return NULL; | |
299 } | |
300 | |
301 // If X is found on the appropriate phi input, find the subtract on the other | |
302 if( X != in(phi_x_idx) ) return NULL; | |
303 int phi_sub_idx = phi_x_idx == IfTrue ? IfFalse : IfTrue; | |
304 Node *sub = in(phi_sub_idx); | |
305 | |
306 // Allow only SubF(0,X) and fail out for all others; NegF is not OK | |
307 if( sub->Opcode() != Op_SubF || | |
308 sub->in(2) != X || | |
309 phase->type(sub->in(1)) != TypeF::ZERO ) return NULL; | |
310 | |
311 Node *abs = new (phase->C, 2) AbsFNode( X ); | |
312 if( flip ) | |
313 abs = new (phase->C, 3) SubFNode(sub->in(1), phase->transform(abs)); | |
314 | |
315 return abs; | |
316 } | |
317 | |
318 //============================================================================= | |
319 //------------------------------Ideal------------------------------------------ | |
320 // Return a node which is more "ideal" than the current node. | |
321 // Check for absolute value | |
322 Node *CMoveDNode::Ideal(PhaseGVN *phase, bool can_reshape) { | |
323 // Try generic ideal's first | |
324 Node *x = CMoveNode::Ideal(phase, can_reshape); | |
325 if( x ) return x; | |
326 | |
327 int cmp_zero_idx = 0; // Index of compare input where to look for zero | |
328 int phi_x_idx = 0; // Index of phi input where to find naked x | |
329 | |
330 // Find the Bool | |
331 if( !in(1)->is_Bool() ) return NULL; | |
332 BoolNode *bol = in(1)->as_Bool(); | |
333 // Check bool sense | |
334 switch( bol->_test._test ) { | |
335 case BoolTest::lt: cmp_zero_idx = 1; phi_x_idx = IfTrue; break; | |
336 case BoolTest::le: cmp_zero_idx = 2; phi_x_idx = IfFalse; break; | |
337 case BoolTest::gt: cmp_zero_idx = 2; phi_x_idx = IfTrue; break; | |
338 case BoolTest::ge: cmp_zero_idx = 1; phi_x_idx = IfFalse; break; | |
339 default: return NULL; break; | |
340 } | |
341 | |
342 // Find zero input of CmpD; the other input is being abs'd | |
343 Node *cmpd = bol->in(1); | |
344 if( cmpd->Opcode() != Op_CmpD ) return NULL; | |
345 Node *X = NULL; | |
346 bool flip = false; | |
347 if( phase->type(cmpd->in(cmp_zero_idx)) == TypeD::ZERO ) { | |
348 X = cmpd->in(3 - cmp_zero_idx); | |
349 } else if (phase->type(cmpd->in(3 - cmp_zero_idx)) == TypeD::ZERO) { | |
350 // The test is inverted, we should invert the result... | |
351 X = cmpd->in(cmp_zero_idx); | |
352 flip = true; | |
353 } else { | |
354 return NULL; | |
355 } | |
356 | |
357 // If X is found on the appropriate phi input, find the subtract on the other | |
358 if( X != in(phi_x_idx) ) return NULL; | |
359 int phi_sub_idx = phi_x_idx == IfTrue ? IfFalse : IfTrue; | |
360 Node *sub = in(phi_sub_idx); | |
361 | |
362 // Allow only SubD(0,X) and fail out for all others; NegD is not OK | |
363 if( sub->Opcode() != Op_SubD || | |
364 sub->in(2) != X || | |
365 phase->type(sub->in(1)) != TypeD::ZERO ) return NULL; | |
366 | |
367 Node *abs = new (phase->C, 2) AbsDNode( X ); | |
368 if( flip ) | |
369 abs = new (phase->C, 3) SubDNode(sub->in(1), phase->transform(abs)); | |
370 | |
371 return abs; | |
372 } | |
373 | |
374 | |
375 //============================================================================= | |
376 // If input is already higher or equal to cast type, then this is an identity. | |
377 Node *ConstraintCastNode::Identity( PhaseTransform *phase ) { | |
378 return phase->type(in(1))->higher_equal(_type) ? in(1) : this; | |
379 } | |
380 | |
381 //------------------------------Value------------------------------------------ | |
382 // Take 'join' of input and cast-up type | |
383 const Type *ConstraintCastNode::Value( PhaseTransform *phase ) const { | |
384 if( in(0) && phase->type(in(0)) == Type::TOP ) return Type::TOP; | |
385 const Type* ft = phase->type(in(1))->filter(_type); | |
386 | |
387 #ifdef ASSERT | |
388 // Previous versions of this function had some special case logic, | |
389 // which is no longer necessary. Make sure of the required effects. | |
390 switch (Opcode()) { | |
391 case Op_CastII: | |
392 { | |
393 const Type* t1 = phase->type(in(1)); | |
394 if( t1 == Type::TOP ) assert(ft == Type::TOP, "special case #1"); | |
395 const Type* rt = t1->join(_type); | |
396 if (rt->empty()) assert(ft == Type::TOP, "special case #2"); | |
397 break; | |
398 } | |
399 case Op_CastPP: | |
400 if (phase->type(in(1)) == TypePtr::NULL_PTR && | |
401 _type->isa_ptr() && _type->is_ptr()->_ptr == TypePtr::NotNull) | |
402 assert(ft == Type::TOP, "special case #3"); | |
403 break; | |
404 } | |
405 #endif //ASSERT | |
406 | |
407 return ft; | |
408 } | |
409 | |
410 //------------------------------Ideal------------------------------------------ | |
411 // Return a node which is more "ideal" than the current node. Strip out | |
412 // control copies | |
413 Node *ConstraintCastNode::Ideal(PhaseGVN *phase, bool can_reshape){ | |
414 return (in(0) && remove_dead_region(phase, can_reshape)) ? this : NULL; | |
415 } | |
416 | |
417 //------------------------------Ideal_DU_postCCP------------------------------- | |
418 // Throw away cast after constant propagation | |
419 Node *ConstraintCastNode::Ideal_DU_postCCP( PhaseCCP *ccp ) { | |
420 const Type *t = ccp->type(in(1)); | |
421 ccp->hash_delete(this); | |
422 set_type(t); // Turn into ID function | |
423 ccp->hash_insert(this); | |
424 return this; | |
425 } | |
426 | |
427 | |
428 //============================================================================= | |
429 | |
430 //------------------------------Ideal_DU_postCCP------------------------------- | |
431 // If not converting int->oop, throw away cast after constant propagation | |
432 Node *CastPPNode::Ideal_DU_postCCP( PhaseCCP *ccp ) { | |
433 const Type *t = ccp->type(in(1)); | |
434 if (!t->isa_oop_ptr()) { | |
435 return NULL; // do not transform raw pointers | |
436 } | |
437 return ConstraintCastNode::Ideal_DU_postCCP(ccp); | |
438 } | |
439 | |
440 | |
441 | |
442 //============================================================================= | |
443 //------------------------------Identity--------------------------------------- | |
444 // If input is already higher or equal to cast type, then this is an identity. | |
445 Node *CheckCastPPNode::Identity( PhaseTransform *phase ) { | |
446 // Toned down to rescue meeting at a Phi 3 different oops all implementing | |
447 // the same interface. CompileTheWorld starting at 502, kd12rc1.zip. | |
448 return (phase->type(in(1)) == phase->type(this)) ? in(1) : this; | |
449 } | |
450 | |
451 // Determine whether "n" is a node which can cause an alias of one of its inputs. Node types | |
452 // which can create aliases are: CheckCastPP, Phi, and any store (if there is also a load from | |
453 // the location.) | |
454 // Note: this checks for aliases created in this compilation, not ones which may | |
455 // be potentially created at call sites. | |
456 static bool can_cause_alias(Node *n, PhaseTransform *phase) { | |
457 bool possible_alias = false; | |
458 | |
459 if (n->is_Store()) { | |
460 possible_alias = !n->as_Store()->value_never_loaded(phase); | |
461 } else { | |
462 int opc = n->Opcode(); | |
463 possible_alias = n->is_Phi() || | |
464 opc == Op_CheckCastPP || | |
465 opc == Op_StorePConditional || | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
466 opc == Op_CompareAndSwapP || |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
467 opc == Op_CompareAndSwapN; |
0 | 468 } |
469 return possible_alias; | |
470 } | |
471 | |
472 //------------------------------Value------------------------------------------ | |
473 // Take 'join' of input and cast-up type, unless working with an Interface | |
474 const Type *CheckCastPPNode::Value( PhaseTransform *phase ) const { | |
475 if( in(0) && phase->type(in(0)) == Type::TOP ) return Type::TOP; | |
476 | |
477 const Type *inn = phase->type(in(1)); | |
478 if( inn == Type::TOP ) return Type::TOP; // No information yet | |
479 | |
480 const TypePtr *in_type = inn->isa_ptr(); | |
481 const TypePtr *my_type = _type->isa_ptr(); | |
482 const Type *result = _type; | |
483 if( in_type != NULL && my_type != NULL ) { | |
484 TypePtr::PTR in_ptr = in_type->ptr(); | |
485 if( in_ptr == TypePtr::Null ) { | |
486 result = in_type; | |
487 } else if( in_ptr == TypePtr::Constant ) { | |
488 // Casting a constant oop to an interface? | |
489 // (i.e., a String to a Comparable?) | |
490 // Then return the interface. | |
491 const TypeOopPtr *jptr = my_type->isa_oopptr(); | |
492 assert( jptr, "" ); | |
493 result = (jptr->klass()->is_interface() || !in_type->higher_equal(_type)) | |
494 ? my_type->cast_to_ptr_type( TypePtr::NotNull ) | |
495 : in_type; | |
496 } else { | |
497 result = my_type->cast_to_ptr_type( my_type->join_ptr(in_ptr) ); | |
498 } | |
499 } | |
500 return result; | |
501 | |
502 // JOIN NOT DONE HERE BECAUSE OF INTERFACE ISSUES. | |
503 // FIX THIS (DO THE JOIN) WHEN UNION TYPES APPEAR! | |
504 | |
505 // | |
506 // Remove this code after overnight run indicates no performance | |
507 // loss from not performing JOIN at CheckCastPPNode | |
508 // | |
509 // const TypeInstPtr *in_oop = in->isa_instptr(); | |
510 // const TypeInstPtr *my_oop = _type->isa_instptr(); | |
511 // // If either input is an 'interface', return destination type | |
512 // assert (in_oop == NULL || in_oop->klass() != NULL, ""); | |
513 // assert (my_oop == NULL || my_oop->klass() != NULL, ""); | |
514 // if( (in_oop && in_oop->klass()->klass_part()->is_interface()) | |
515 // ||(my_oop && my_oop->klass()->klass_part()->is_interface()) ) { | |
516 // TypePtr::PTR in_ptr = in->isa_ptr() ? in->is_ptr()->_ptr : TypePtr::BotPTR; | |
517 // // Preserve cast away nullness for interfaces | |
518 // if( in_ptr == TypePtr::NotNull && my_oop && my_oop->_ptr == TypePtr::BotPTR ) { | |
519 // return my_oop->cast_to_ptr_type(TypePtr::NotNull); | |
520 // } | |
521 // return _type; | |
522 // } | |
523 // | |
524 // // Neither the input nor the destination type is an interface, | |
525 // | |
526 // // history: JOIN used to cause weird corner case bugs | |
527 // // return (in == TypeOopPtr::NULL_PTR) ? in : _type; | |
528 // // JOIN picks up NotNull in common instance-of/check-cast idioms, both oops. | |
529 // // JOIN does not preserve NotNull in other cases, e.g. RawPtr vs InstPtr | |
530 // const Type *join = in->join(_type); | |
531 // // Check if join preserved NotNull'ness for pointers | |
532 // if( join->isa_ptr() && _type->isa_ptr() ) { | |
533 // TypePtr::PTR join_ptr = join->is_ptr()->_ptr; | |
534 // TypePtr::PTR type_ptr = _type->is_ptr()->_ptr; | |
535 // // If there isn't any NotNull'ness to preserve | |
536 // // OR if join preserved NotNull'ness then return it | |
537 // if( type_ptr == TypePtr::BotPTR || type_ptr == TypePtr::Null || | |
538 // join_ptr == TypePtr::NotNull || join_ptr == TypePtr::Constant ) { | |
539 // return join; | |
540 // } | |
541 // // ELSE return same old type as before | |
542 // return _type; | |
543 // } | |
544 // // Not joining two pointers | |
545 // return join; | |
546 } | |
547 | |
548 //------------------------------Ideal------------------------------------------ | |
549 // Return a node which is more "ideal" than the current node. Strip out | |
550 // control copies | |
551 Node *CheckCastPPNode::Ideal(PhaseGVN *phase, bool can_reshape){ | |
552 return (in(0) && remove_dead_region(phase, can_reshape)) ? this : NULL; | |
553 } | |
554 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
555 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
556 Node* DecodeNNode::Identity(PhaseTransform* phase) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
557 const Type *t = phase->type( in(1) ); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
558 if( t == Type::TOP ) return in(1); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
559 |
168
7793bd37a336
6705887: Compressed Oops: generate x64 addressing and implicit null checks with narrow oops
kvn
parents:
164
diff
changeset
|
560 if (in(1)->is_EncodeP()) { |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
561 // (DecodeN (EncodeP p)) -> p |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
562 return in(1)->in(1); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
563 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
564 return this; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
565 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
566 |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
567 const Type *DecodeNNode::Value( PhaseTransform *phase ) const { |
216
8d191a7697e2
6715633: when matching a memory node the adr_type should not change
kvn
parents:
168
diff
changeset
|
568 const Type *t = phase->type( in(1) ); |
8d191a7697e2
6715633: when matching a memory node the adr_type should not change
kvn
parents:
168
diff
changeset
|
569 if (t == Type::TOP) return Type::TOP; |
8d191a7697e2
6715633: when matching a memory node the adr_type should not change
kvn
parents:
168
diff
changeset
|
570 if (t == TypeNarrowOop::NULL_PTR) return TypePtr::NULL_PTR; |
8d191a7697e2
6715633: when matching a memory node the adr_type should not change
kvn
parents:
168
diff
changeset
|
571 |
8d191a7697e2
6715633: when matching a memory node the adr_type should not change
kvn
parents:
168
diff
changeset
|
572 assert(t->isa_narrowoop(), "only narrowoop here"); |
8d191a7697e2
6715633: when matching a memory node the adr_type should not change
kvn
parents:
168
diff
changeset
|
573 return t->is_narrowoop()->make_oopptr(); |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
574 } |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
575 |
164
c436414a719e
6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents:
163
diff
changeset
|
576 Node* DecodeNNode::decode(PhaseTransform* phase, Node* value) { |
168
7793bd37a336
6705887: Compressed Oops: generate x64 addressing and implicit null checks with narrow oops
kvn
parents:
164
diff
changeset
|
577 if (value->is_EncodeP()) { |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
578 // (DecodeN (EncodeP p)) -> p |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
579 return value->in(1); |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
580 } |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
581 const Type* newtype = value->bottom_type(); |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
582 if (newtype == TypeNarrowOop::NULL_PTR) { |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
583 return phase->transform(new (phase->C, 1) ConPNode(TypePtr::NULL_PTR)); |
163 | 584 } else if (newtype->isa_narrowoop()) { |
585 return phase->transform(new (phase->C, 2) DecodeNNode(value, newtype->is_narrowoop()->make_oopptr())); | |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
586 } else { |
163 | 587 ShouldNotReachHere(); |
588 return NULL; // to make C++ compiler happy. | |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
589 } |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
590 } |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
591 |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
592 Node* EncodePNode::Identity(PhaseTransform* phase) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
593 const Type *t = phase->type( in(1) ); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
594 if( t == Type::TOP ) return in(1); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
595 |
168
7793bd37a336
6705887: Compressed Oops: generate x64 addressing and implicit null checks with narrow oops
kvn
parents:
164
diff
changeset
|
596 if (in(1)->is_DecodeN()) { |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
597 // (EncodeP (DecodeN p)) -> p |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
598 return in(1)->in(1); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
599 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
600 return this; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
601 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
602 |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
603 const Type *EncodePNode::Value( PhaseTransform *phase ) const { |
216
8d191a7697e2
6715633: when matching a memory node the adr_type should not change
kvn
parents:
168
diff
changeset
|
604 const Type *t = phase->type( in(1) ); |
8d191a7697e2
6715633: when matching a memory node the adr_type should not change
kvn
parents:
168
diff
changeset
|
605 if (t == Type::TOP) return Type::TOP; |
8d191a7697e2
6715633: when matching a memory node the adr_type should not change
kvn
parents:
168
diff
changeset
|
606 if (t == TypePtr::NULL_PTR) return TypeNarrowOop::NULL_PTR; |
8d191a7697e2
6715633: when matching a memory node the adr_type should not change
kvn
parents:
168
diff
changeset
|
607 |
8d191a7697e2
6715633: when matching a memory node the adr_type should not change
kvn
parents:
168
diff
changeset
|
608 assert(t->isa_oopptr(), "only oopptr here"); |
8d191a7697e2
6715633: when matching a memory node the adr_type should not change
kvn
parents:
168
diff
changeset
|
609 return t->is_oopptr()->make_narrowoop(); |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
610 } |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
611 |
164
c436414a719e
6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents:
163
diff
changeset
|
612 Node* EncodePNode::encode(PhaseTransform* phase, Node* value) { |
168
7793bd37a336
6705887: Compressed Oops: generate x64 addressing and implicit null checks with narrow oops
kvn
parents:
164
diff
changeset
|
613 if (value->is_DecodeN()) { |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
614 // (EncodeP (DecodeN p)) -> p |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
615 return value->in(1); |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
616 } |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
617 const Type* newtype = value->bottom_type(); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
618 if (newtype == TypePtr::NULL_PTR) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
619 return phase->transform(new (phase->C, 1) ConNNode(TypeNarrowOop::NULL_PTR)); |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
620 } else if (newtype->isa_oopptr()) { |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
621 return phase->transform(new (phase->C, 2) EncodePNode(value, newtype->is_oopptr()->make_narrowoop())); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
622 } else { |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
623 ShouldNotReachHere(); |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
624 return NULL; // to make C++ compiler happy. |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
625 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
626 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
627 |
163 | 628 Node *EncodePNode::Ideal_DU_postCCP( PhaseCCP *ccp ) { |
629 return MemNode::Ideal_common_DU_postCCP(ccp, this, in(1)); | |
630 } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
36
diff
changeset
|
631 |
0 | 632 //============================================================================= |
633 //------------------------------Identity--------------------------------------- | |
634 Node *Conv2BNode::Identity( PhaseTransform *phase ) { | |
635 const Type *t = phase->type( in(1) ); | |
636 if( t == Type::TOP ) return in(1); | |
637 if( t == TypeInt::ZERO ) return in(1); | |
638 if( t == TypeInt::ONE ) return in(1); | |
639 if( t == TypeInt::BOOL ) return in(1); | |
640 return this; | |
641 } | |
642 | |
643 //------------------------------Value------------------------------------------ | |
644 const Type *Conv2BNode::Value( PhaseTransform *phase ) const { | |
645 const Type *t = phase->type( in(1) ); | |
646 if( t == Type::TOP ) return Type::TOP; | |
647 if( t == TypeInt::ZERO ) return TypeInt::ZERO; | |
648 if( t == TypePtr::NULL_PTR ) return TypeInt::ZERO; | |
649 const TypePtr *tp = t->isa_ptr(); | |
650 if( tp != NULL ) { | |
651 if( tp->ptr() == TypePtr::AnyNull ) return Type::TOP; | |
652 if( tp->ptr() == TypePtr::Constant) return TypeInt::ONE; | |
653 if (tp->ptr() == TypePtr::NotNull) return TypeInt::ONE; | |
654 return TypeInt::BOOL; | |
655 } | |
656 if (t->base() != Type::Int) return TypeInt::BOOL; | |
657 const TypeInt *ti = t->is_int(); | |
658 if( ti->_hi < 0 || ti->_lo > 0 ) return TypeInt::ONE; | |
659 return TypeInt::BOOL; | |
660 } | |
661 | |
662 | |
663 // The conversions operations are all Alpha sorted. Please keep it that way! | |
664 //============================================================================= | |
665 //------------------------------Value------------------------------------------ | |
666 const Type *ConvD2FNode::Value( PhaseTransform *phase ) const { | |
667 const Type *t = phase->type( in(1) ); | |
668 if( t == Type::TOP ) return Type::TOP; | |
669 if( t == Type::DOUBLE ) return Type::FLOAT; | |
670 const TypeD *td = t->is_double_constant(); | |
671 return TypeF::make( (float)td->getd() ); | |
672 } | |
673 | |
674 //------------------------------Identity--------------------------------------- | |
675 // Float's can be converted to doubles with no loss of bits. Hence | |
676 // converting a float to a double and back to a float is a NOP. | |
677 Node *ConvD2FNode::Identity(PhaseTransform *phase) { | |
678 return (in(1)->Opcode() == Op_ConvF2D) ? in(1)->in(1) : this; | |
679 } | |
680 | |
681 //============================================================================= | |
682 //------------------------------Value------------------------------------------ | |
683 const Type *ConvD2INode::Value( PhaseTransform *phase ) const { | |
684 const Type *t = phase->type( in(1) ); | |
685 if( t == Type::TOP ) return Type::TOP; | |
686 if( t == Type::DOUBLE ) return TypeInt::INT; | |
687 const TypeD *td = t->is_double_constant(); | |
688 return TypeInt::make( SharedRuntime::d2i( td->getd() ) ); | |
689 } | |
690 | |
691 //------------------------------Ideal------------------------------------------ | |
692 // If converting to an int type, skip any rounding nodes | |
693 Node *ConvD2INode::Ideal(PhaseGVN *phase, bool can_reshape) { | |
694 if( in(1)->Opcode() == Op_RoundDouble ) | |
695 set_req(1,in(1)->in(1)); | |
696 return NULL; | |
697 } | |
698 | |
699 //------------------------------Identity--------------------------------------- | |
700 // Int's can be converted to doubles with no loss of bits. Hence | |
701 // converting an integer to a double and back to an integer is a NOP. | |
702 Node *ConvD2INode::Identity(PhaseTransform *phase) { | |
703 return (in(1)->Opcode() == Op_ConvI2D) ? in(1)->in(1) : this; | |
704 } | |
705 | |
706 //============================================================================= | |
707 //------------------------------Value------------------------------------------ | |
708 const Type *ConvD2LNode::Value( PhaseTransform *phase ) const { | |
709 const Type *t = phase->type( in(1) ); | |
710 if( t == Type::TOP ) return Type::TOP; | |
711 if( t == Type::DOUBLE ) return TypeLong::LONG; | |
712 const TypeD *td = t->is_double_constant(); | |
713 return TypeLong::make( SharedRuntime::d2l( td->getd() ) ); | |
714 } | |
715 | |
716 //------------------------------Identity--------------------------------------- | |
717 Node *ConvD2LNode::Identity(PhaseTransform *phase) { | |
718 // Remove ConvD2L->ConvL2D->ConvD2L sequences. | |
719 if( in(1) ->Opcode() == Op_ConvL2D && | |
720 in(1)->in(1)->Opcode() == Op_ConvD2L ) | |
721 return in(1)->in(1); | |
722 return this; | |
723 } | |
724 | |
725 //------------------------------Ideal------------------------------------------ | |
726 // If converting to an int type, skip any rounding nodes | |
727 Node *ConvD2LNode::Ideal(PhaseGVN *phase, bool can_reshape) { | |
728 if( in(1)->Opcode() == Op_RoundDouble ) | |
729 set_req(1,in(1)->in(1)); | |
730 return NULL; | |
731 } | |
732 | |
733 //============================================================================= | |
734 //------------------------------Value------------------------------------------ | |
735 const Type *ConvF2DNode::Value( PhaseTransform *phase ) const { | |
736 const Type *t = phase->type( in(1) ); | |
737 if( t == Type::TOP ) return Type::TOP; | |
738 if( t == Type::FLOAT ) return Type::DOUBLE; | |
739 const TypeF *tf = t->is_float_constant(); | |
740 #ifndef IA64 | |
741 return TypeD::make( (double)tf->getf() ); | |
742 #else | |
743 float x = tf->getf(); | |
744 return TypeD::make( (x == 0.0f) ? (double)x : (double)x + ia64_double_zero ); | |
745 #endif | |
746 } | |
747 | |
748 //============================================================================= | |
749 //------------------------------Value------------------------------------------ | |
750 const Type *ConvF2INode::Value( PhaseTransform *phase ) const { | |
751 const Type *t = phase->type( in(1) ); | |
752 if( t == Type::TOP ) return Type::TOP; | |
753 if( t == Type::FLOAT ) return TypeInt::INT; | |
754 const TypeF *tf = t->is_float_constant(); | |
755 return TypeInt::make( SharedRuntime::f2i( tf->getf() ) ); | |
756 } | |
757 | |
758 //------------------------------Identity--------------------------------------- | |
759 Node *ConvF2INode::Identity(PhaseTransform *phase) { | |
760 // Remove ConvF2I->ConvI2F->ConvF2I sequences. | |
761 if( in(1) ->Opcode() == Op_ConvI2F && | |
762 in(1)->in(1)->Opcode() == Op_ConvF2I ) | |
763 return in(1)->in(1); | |
764 return this; | |
765 } | |
766 | |
767 //------------------------------Ideal------------------------------------------ | |
768 // If converting to an int type, skip any rounding nodes | |
769 Node *ConvF2INode::Ideal(PhaseGVN *phase, bool can_reshape) { | |
770 if( in(1)->Opcode() == Op_RoundFloat ) | |
771 set_req(1,in(1)->in(1)); | |
772 return NULL; | |
773 } | |
774 | |
775 //============================================================================= | |
776 //------------------------------Value------------------------------------------ | |
777 const Type *ConvF2LNode::Value( PhaseTransform *phase ) const { | |
778 const Type *t = phase->type( in(1) ); | |
779 if( t == Type::TOP ) return Type::TOP; | |
780 if( t == Type::FLOAT ) return TypeLong::LONG; | |
781 const TypeF *tf = t->is_float_constant(); | |
782 return TypeLong::make( SharedRuntime::f2l( tf->getf() ) ); | |
783 } | |
784 | |
785 //------------------------------Identity--------------------------------------- | |
786 Node *ConvF2LNode::Identity(PhaseTransform *phase) { | |
787 // Remove ConvF2L->ConvL2F->ConvF2L sequences. | |
788 if( in(1) ->Opcode() == Op_ConvL2F && | |
789 in(1)->in(1)->Opcode() == Op_ConvF2L ) | |
790 return in(1)->in(1); | |
791 return this; | |
792 } | |
793 | |
794 //------------------------------Ideal------------------------------------------ | |
795 // If converting to an int type, skip any rounding nodes | |
796 Node *ConvF2LNode::Ideal(PhaseGVN *phase, bool can_reshape) { | |
797 if( in(1)->Opcode() == Op_RoundFloat ) | |
798 set_req(1,in(1)->in(1)); | |
799 return NULL; | |
800 } | |
801 | |
802 //============================================================================= | |
803 //------------------------------Value------------------------------------------ | |
804 const Type *ConvI2DNode::Value( PhaseTransform *phase ) const { | |
805 const Type *t = phase->type( in(1) ); | |
806 if( t == Type::TOP ) return Type::TOP; | |
807 const TypeInt *ti = t->is_int(); | |
808 if( ti->is_con() ) return TypeD::make( (double)ti->get_con() ); | |
809 return bottom_type(); | |
810 } | |
811 | |
812 //============================================================================= | |
813 //------------------------------Value------------------------------------------ | |
814 const Type *ConvI2FNode::Value( PhaseTransform *phase ) const { | |
815 const Type *t = phase->type( in(1) ); | |
816 if( t == Type::TOP ) return Type::TOP; | |
817 const TypeInt *ti = t->is_int(); | |
818 if( ti->is_con() ) return TypeF::make( (float)ti->get_con() ); | |
819 return bottom_type(); | |
820 } | |
821 | |
822 //------------------------------Identity--------------------------------------- | |
823 Node *ConvI2FNode::Identity(PhaseTransform *phase) { | |
824 // Remove ConvI2F->ConvF2I->ConvI2F sequences. | |
825 if( in(1) ->Opcode() == Op_ConvF2I && | |
826 in(1)->in(1)->Opcode() == Op_ConvI2F ) | |
827 return in(1)->in(1); | |
828 return this; | |
829 } | |
830 | |
831 //============================================================================= | |
832 //------------------------------Value------------------------------------------ | |
833 const Type *ConvI2LNode::Value( PhaseTransform *phase ) const { | |
834 const Type *t = phase->type( in(1) ); | |
835 if( t == Type::TOP ) return Type::TOP; | |
836 const TypeInt *ti = t->is_int(); | |
837 const Type* tl = TypeLong::make(ti->_lo, ti->_hi, ti->_widen); | |
838 // Join my declared type against my incoming type. | |
839 tl = tl->filter(_type); | |
840 return tl; | |
841 } | |
842 | |
843 #ifdef _LP64 | |
844 static inline bool long_ranges_overlap(jlong lo1, jlong hi1, | |
845 jlong lo2, jlong hi2) { | |
846 // Two ranges overlap iff one range's low point falls in the other range. | |
847 return (lo2 <= lo1 && lo1 <= hi2) || (lo1 <= lo2 && lo2 <= hi1); | |
848 } | |
849 #endif | |
850 | |
851 //------------------------------Ideal------------------------------------------ | |
852 Node *ConvI2LNode::Ideal(PhaseGVN *phase, bool can_reshape) { | |
853 const TypeLong* this_type = this->type()->is_long(); | |
854 Node* this_changed = NULL; | |
855 | |
856 // If _major_progress, then more loop optimizations follow. Do NOT | |
857 // remove this node's type assertion until no more loop ops can happen. | |
858 // The progress bit is set in the major loop optimizations THEN comes the | |
859 // call to IterGVN and any chance of hitting this code. Cf. Opaque1Node. | |
860 if (can_reshape && !phase->C->major_progress()) { | |
861 const TypeInt* in_type = phase->type(in(1))->isa_int(); | |
862 if (in_type != NULL && this_type != NULL && | |
863 (in_type->_lo != this_type->_lo || | |
864 in_type->_hi != this_type->_hi)) { | |
865 // Although this WORSENS the type, it increases GVN opportunities, | |
866 // because I2L nodes with the same input will common up, regardless | |
867 // of slightly differing type assertions. Such slight differences | |
868 // arise routinely as a result of loop unrolling, so this is a | |
869 // post-unrolling graph cleanup. Choose a type which depends only | |
870 // on my input. (Exception: Keep a range assertion of >=0 or <0.) | |
871 jlong lo1 = this_type->_lo; | |
872 jlong hi1 = this_type->_hi; | |
873 int w1 = this_type->_widen; | |
874 if (lo1 != (jint)lo1 || | |
875 hi1 != (jint)hi1 || | |
876 lo1 > hi1) { | |
877 // Overflow leads to wraparound, wraparound leads to range saturation. | |
878 lo1 = min_jint; hi1 = max_jint; | |
879 } else if (lo1 >= 0) { | |
880 // Keep a range assertion of >=0. | |
881 lo1 = 0; hi1 = max_jint; | |
882 } else if (hi1 < 0) { | |
883 // Keep a range assertion of <0. | |
884 lo1 = min_jint; hi1 = -1; | |
885 } else { | |
886 lo1 = min_jint; hi1 = max_jint; | |
887 } | |
888 const TypeLong* wtype = TypeLong::make(MAX2((jlong)in_type->_lo, lo1), | |
889 MIN2((jlong)in_type->_hi, hi1), | |
890 MAX2((int)in_type->_widen, w1)); | |
891 if (wtype != type()) { | |
892 set_type(wtype); | |
893 // Note: this_type still has old type value, for the logic below. | |
894 this_changed = this; | |
895 } | |
896 } | |
897 } | |
898 | |
899 #ifdef _LP64 | |
900 // Convert ConvI2L(AddI(x, y)) to AddL(ConvI2L(x), ConvI2L(y)) , | |
901 // but only if x and y have subranges that cannot cause 32-bit overflow, | |
902 // under the assumption that x+y is in my own subrange this->type(). | |
903 | |
904 // This assumption is based on a constraint (i.e., type assertion) | |
905 // established in Parse::array_addressing or perhaps elsewhere. | |
906 // This constraint has been adjoined to the "natural" type of | |
907 // the incoming argument in(0). We know (because of runtime | |
908 // checks) - that the result value I2L(x+y) is in the joined range. | |
909 // Hence we can restrict the incoming terms (x, y) to values such | |
910 // that their sum also lands in that range. | |
911 | |
912 // This optimization is useful only on 64-bit systems, where we hope | |
913 // the addition will end up subsumed in an addressing mode. | |
914 // It is necessary to do this when optimizing an unrolled array | |
915 // copy loop such as x[i++] = y[i++]. | |
916 | |
917 // On 32-bit systems, it's better to perform as much 32-bit math as | |
918 // possible before the I2L conversion, because 32-bit math is cheaper. | |
919 // There's no common reason to "leak" a constant offset through the I2L. | |
920 // Addressing arithmetic will not absorb it as part of a 64-bit AddL. | |
921 | |
922 Node* z = in(1); | |
923 int op = z->Opcode(); | |
924 if (op == Op_AddI || op == Op_SubI) { | |
925 Node* x = z->in(1); | |
926 Node* y = z->in(2); | |
927 assert (x != z && y != z, "dead loop in ConvI2LNode::Ideal"); | |
928 if (phase->type(x) == Type::TOP) return this_changed; | |
929 if (phase->type(y) == Type::TOP) return this_changed; | |
930 const TypeInt* tx = phase->type(x)->is_int(); | |
931 const TypeInt* ty = phase->type(y)->is_int(); | |
932 const TypeLong* tz = this_type; | |
933 jlong xlo = tx->_lo; | |
934 jlong xhi = tx->_hi; | |
935 jlong ylo = ty->_lo; | |
936 jlong yhi = ty->_hi; | |
937 jlong zlo = tz->_lo; | |
938 jlong zhi = tz->_hi; | |
939 jlong vbit = CONST64(1) << BitsPerInt; | |
940 int widen = MAX2(tx->_widen, ty->_widen); | |
941 if (op == Op_SubI) { | |
942 jlong ylo0 = ylo; | |
943 ylo = -yhi; | |
944 yhi = -ylo0; | |
945 } | |
946 // See if x+y can cause positive overflow into z+2**32 | |
947 if (long_ranges_overlap(xlo+ylo, xhi+yhi, zlo+vbit, zhi+vbit)) { | |
948 return this_changed; | |
949 } | |
950 // See if x+y can cause negative overflow into z-2**32 | |
951 if (long_ranges_overlap(xlo+ylo, xhi+yhi, zlo-vbit, zhi-vbit)) { | |
952 return this_changed; | |
953 } | |
954 // Now it's always safe to assume x+y does not overflow. | |
955 // This is true even if some pairs x,y might cause overflow, as long | |
956 // as that overflow value cannot fall into [zlo,zhi]. | |
957 | |
958 // Confident that the arithmetic is "as if infinite precision", | |
959 // we can now use z's range to put constraints on those of x and y. | |
960 // The "natural" range of x [xlo,xhi] can perhaps be narrowed to a | |
961 // more "restricted" range by intersecting [xlo,xhi] with the | |
962 // range obtained by subtracting y's range from the asserted range | |
963 // of the I2L conversion. Here's the interval arithmetic algebra: | |
964 // x == z-y == [zlo,zhi]-[ylo,yhi] == [zlo,zhi]+[-yhi,-ylo] | |
965 // => x in [zlo-yhi, zhi-ylo] | |
966 // => x in [zlo-yhi, zhi-ylo] INTERSECT [xlo,xhi] | |
967 // => x in [xlo MAX zlo-yhi, xhi MIN zhi-ylo] | |
968 jlong rxlo = MAX2(xlo, zlo - yhi); | |
969 jlong rxhi = MIN2(xhi, zhi - ylo); | |
970 // And similarly, x changing place with y: | |
971 jlong rylo = MAX2(ylo, zlo - xhi); | |
972 jlong ryhi = MIN2(yhi, zhi - xlo); | |
973 if (rxlo > rxhi || rylo > ryhi) { | |
974 return this_changed; // x or y is dying; don't mess w/ it | |
975 } | |
976 if (op == Op_SubI) { | |
977 jlong rylo0 = rylo; | |
978 rylo = -ryhi; | |
979 ryhi = -rylo0; | |
980 } | |
981 | |
982 Node* cx = phase->transform( new (phase->C, 2) ConvI2LNode(x, TypeLong::make(rxlo, rxhi, widen)) ); | |
983 Node* cy = phase->transform( new (phase->C, 2) ConvI2LNode(y, TypeLong::make(rylo, ryhi, widen)) ); | |
984 switch (op) { | |
985 case Op_AddI: return new (phase->C, 3) AddLNode(cx, cy); | |
986 case Op_SubI: return new (phase->C, 3) SubLNode(cx, cy); | |
987 default: ShouldNotReachHere(); | |
988 } | |
989 } | |
990 #endif //_LP64 | |
991 | |
992 return this_changed; | |
993 } | |
994 | |
995 //============================================================================= | |
996 //------------------------------Value------------------------------------------ | |
997 const Type *ConvL2DNode::Value( PhaseTransform *phase ) const { | |
998 const Type *t = phase->type( in(1) ); | |
999 if( t == Type::TOP ) return Type::TOP; | |
1000 const TypeLong *tl = t->is_long(); | |
1001 if( tl->is_con() ) return TypeD::make( (double)tl->get_con() ); | |
1002 return bottom_type(); | |
1003 } | |
1004 | |
1005 //============================================================================= | |
1006 //------------------------------Value------------------------------------------ | |
1007 const Type *ConvL2FNode::Value( PhaseTransform *phase ) const { | |
1008 const Type *t = phase->type( in(1) ); | |
1009 if( t == Type::TOP ) return Type::TOP; | |
1010 const TypeLong *tl = t->is_long(); | |
1011 if( tl->is_con() ) return TypeF::make( (float)tl->get_con() ); | |
1012 return bottom_type(); | |
1013 } | |
1014 | |
1015 //============================================================================= | |
1016 //----------------------------Identity----------------------------------------- | |
1017 Node *ConvL2INode::Identity( PhaseTransform *phase ) { | |
1018 // Convert L2I(I2L(x)) => x | |
1019 if (in(1)->Opcode() == Op_ConvI2L) return in(1)->in(1); | |
1020 return this; | |
1021 } | |
1022 | |
1023 //------------------------------Value------------------------------------------ | |
1024 const Type *ConvL2INode::Value( PhaseTransform *phase ) const { | |
1025 const Type *t = phase->type( in(1) ); | |
1026 if( t == Type::TOP ) return Type::TOP; | |
1027 const TypeLong *tl = t->is_long(); | |
1028 if (tl->is_con()) | |
1029 // Easy case. | |
1030 return TypeInt::make((jint)tl->get_con()); | |
1031 return bottom_type(); | |
1032 } | |
1033 | |
1034 //------------------------------Ideal------------------------------------------ | |
1035 // Return a node which is more "ideal" than the current node. | |
1036 // Blow off prior masking to int | |
1037 Node *ConvL2INode::Ideal(PhaseGVN *phase, bool can_reshape) { | |
1038 Node *andl = in(1); | |
1039 uint andl_op = andl->Opcode(); | |
1040 if( andl_op == Op_AndL ) { | |
1041 // Blow off prior masking to int | |
1042 if( phase->type(andl->in(2)) == TypeLong::make( 0xFFFFFFFF ) ) { | |
1043 set_req(1,andl->in(1)); | |
1044 return this; | |
1045 } | |
1046 } | |
1047 | |
1048 // Swap with a prior add: convL2I(addL(x,y)) ==> addI(convL2I(x),convL2I(y)) | |
1049 // This replaces an 'AddL' with an 'AddI'. | |
1050 if( andl_op == Op_AddL ) { | |
1051 // Don't do this for nodes which have more than one user since | |
1052 // we'll end up computing the long add anyway. | |
1053 if (andl->outcnt() > 1) return NULL; | |
1054 | |
1055 Node* x = andl->in(1); | |
1056 Node* y = andl->in(2); | |
1057 assert( x != andl && y != andl, "dead loop in ConvL2INode::Ideal" ); | |
1058 if (phase->type(x) == Type::TOP) return NULL; | |
1059 if (phase->type(y) == Type::TOP) return NULL; | |
1060 Node *add1 = phase->transform(new (phase->C, 2) ConvL2INode(x)); | |
1061 Node *add2 = phase->transform(new (phase->C, 2) ConvL2INode(y)); | |
1062 return new (phase->C, 3) AddINode(add1,add2); | |
1063 } | |
1064 | |
36 | 1065 // Disable optimization: LoadL->ConvL2I ==> LoadI. |
1066 // It causes problems (sizes of Load and Store nodes do not match) | |
1067 // in objects initialization code and Escape Analysis. | |
0 | 1068 return NULL; |
1069 } | |
1070 | |
1071 //============================================================================= | |
1072 //------------------------------Value------------------------------------------ | |
1073 const Type *CastX2PNode::Value( PhaseTransform *phase ) const { | |
1074 const Type* t = phase->type(in(1)); | |
1075 if (t->base() == Type_X && t->singleton()) { | |
1076 uintptr_t bits = (uintptr_t) t->is_intptr_t()->get_con(); | |
1077 if (bits == 0) return TypePtr::NULL_PTR; | |
1078 return TypeRawPtr::make((address) bits); | |
1079 } | |
1080 return CastX2PNode::bottom_type(); | |
1081 } | |
1082 | |
1083 //------------------------------Idealize--------------------------------------- | |
1084 static inline bool fits_in_int(const Type* t, bool but_not_min_int = false) { | |
1085 if (t == Type::TOP) return false; | |
1086 const TypeX* tl = t->is_intptr_t(); | |
1087 jint lo = min_jint; | |
1088 jint hi = max_jint; | |
1089 if (but_not_min_int) ++lo; // caller wants to negate the value w/o overflow | |
1090 return (tl->_lo >= lo) && (tl->_hi <= hi); | |
1091 } | |
1092 | |
1093 static inline Node* addP_of_X2P(PhaseGVN *phase, | |
1094 Node* base, | |
1095 Node* dispX, | |
1096 bool negate = false) { | |
1097 if (negate) { | |
1098 dispX = new (phase->C, 3) SubXNode(phase->MakeConX(0), phase->transform(dispX)); | |
1099 } | |
1100 return new (phase->C, 4) AddPNode(phase->C->top(), | |
1101 phase->transform(new (phase->C, 2) CastX2PNode(base)), | |
1102 phase->transform(dispX)); | |
1103 } | |
1104 | |
1105 Node *CastX2PNode::Ideal(PhaseGVN *phase, bool can_reshape) { | |
1106 // convert CastX2P(AddX(x, y)) to AddP(CastX2P(x), y) if y fits in an int | |
1107 int op = in(1)->Opcode(); | |
1108 Node* x; | |
1109 Node* y; | |
1110 switch (op) { | |
1111 case Op_SubX: | |
1112 x = in(1)->in(1); | |
1113 y = in(1)->in(2); | |
1114 if (fits_in_int(phase->type(y), true)) { | |
1115 return addP_of_X2P(phase, x, y, true); | |
1116 } | |
1117 break; | |
1118 case Op_AddX: | |
1119 x = in(1)->in(1); | |
1120 y = in(1)->in(2); | |
1121 if (fits_in_int(phase->type(y))) { | |
1122 return addP_of_X2P(phase, x, y); | |
1123 } | |
1124 if (fits_in_int(phase->type(x))) { | |
1125 return addP_of_X2P(phase, y, x); | |
1126 } | |
1127 break; | |
1128 } | |
1129 return NULL; | |
1130 } | |
1131 | |
1132 //------------------------------Identity--------------------------------------- | |
1133 Node *CastX2PNode::Identity( PhaseTransform *phase ) { | |
1134 if (in(1)->Opcode() == Op_CastP2X) return in(1)->in(1); | |
1135 return this; | |
1136 } | |
1137 | |
1138 //============================================================================= | |
1139 //------------------------------Value------------------------------------------ | |
1140 const Type *CastP2XNode::Value( PhaseTransform *phase ) const { | |
1141 const Type* t = phase->type(in(1)); | |
1142 if (t->base() == Type::RawPtr && t->singleton()) { | |
1143 uintptr_t bits = (uintptr_t) t->is_rawptr()->get_con(); | |
1144 return TypeX::make(bits); | |
1145 } | |
1146 return CastP2XNode::bottom_type(); | |
1147 } | |
1148 | |
1149 Node *CastP2XNode::Ideal(PhaseGVN *phase, bool can_reshape) { | |
1150 return (in(0) && remove_dead_region(phase, can_reshape)) ? this : NULL; | |
1151 } | |
1152 | |
1153 //------------------------------Identity--------------------------------------- | |
1154 Node *CastP2XNode::Identity( PhaseTransform *phase ) { | |
1155 if (in(1)->Opcode() == Op_CastX2P) return in(1)->in(1); | |
1156 return this; | |
1157 } | |
1158 | |
1159 | |
1160 //============================================================================= | |
1161 //------------------------------Identity--------------------------------------- | |
1162 // Remove redundant roundings | |
1163 Node *RoundFloatNode::Identity( PhaseTransform *phase ) { | |
1164 assert(Matcher::strict_fp_requires_explicit_rounding, "should only generate for Intel"); | |
1165 // Do not round constants | |
1166 if (phase->type(in(1))->base() == Type::FloatCon) return in(1); | |
1167 int op = in(1)->Opcode(); | |
1168 // Redundant rounding | |
1169 if( op == Op_RoundFloat ) return in(1); | |
1170 // Already rounded | |
1171 if( op == Op_Parm ) return in(1); | |
1172 if( op == Op_LoadF ) return in(1); | |
1173 return this; | |
1174 } | |
1175 | |
1176 //------------------------------Value------------------------------------------ | |
1177 const Type *RoundFloatNode::Value( PhaseTransform *phase ) const { | |
1178 return phase->type( in(1) ); | |
1179 } | |
1180 | |
1181 //============================================================================= | |
1182 //------------------------------Identity--------------------------------------- | |
1183 // Remove redundant roundings. Incoming arguments are already rounded. | |
1184 Node *RoundDoubleNode::Identity( PhaseTransform *phase ) { | |
1185 assert(Matcher::strict_fp_requires_explicit_rounding, "should only generate for Intel"); | |
1186 // Do not round constants | |
1187 if (phase->type(in(1))->base() == Type::DoubleCon) return in(1); | |
1188 int op = in(1)->Opcode(); | |
1189 // Redundant rounding | |
1190 if( op == Op_RoundDouble ) return in(1); | |
1191 // Already rounded | |
1192 if( op == Op_Parm ) return in(1); | |
1193 if( op == Op_LoadD ) return in(1); | |
1194 if( op == Op_ConvF2D ) return in(1); | |
1195 if( op == Op_ConvI2D ) return in(1); | |
1196 return this; | |
1197 } | |
1198 | |
1199 //------------------------------Value------------------------------------------ | |
1200 const Type *RoundDoubleNode::Value( PhaseTransform *phase ) const { | |
1201 return phase->type( in(1) ); | |
1202 } | |
1203 | |
1204 | |
1205 //============================================================================= | |
1206 // Do not allow value-numbering | |
1207 uint Opaque1Node::hash() const { return NO_HASH; } | |
1208 uint Opaque1Node::cmp( const Node &n ) const { | |
1209 return (&n == this); // Always fail except on self | |
1210 } | |
1211 | |
1212 //------------------------------Identity--------------------------------------- | |
1213 // If _major_progress, then more loop optimizations follow. Do NOT remove | |
1214 // the opaque Node until no more loop ops can happen. Note the timing of | |
1215 // _major_progress; it's set in the major loop optimizations THEN comes the | |
1216 // call to IterGVN and any chance of hitting this code. Hence there's no | |
1217 // phase-ordering problem with stripping Opaque1 in IGVN followed by some | |
1218 // more loop optimizations that require it. | |
1219 Node *Opaque1Node::Identity( PhaseTransform *phase ) { | |
1220 return phase->C->major_progress() ? this : in(1); | |
1221 } | |
1222 | |
1223 //============================================================================= | |
1224 // A node to prevent unwanted optimizations. Allows constant folding. Stops | |
1225 // value-numbering, most Ideal calls or Identity functions. This Node is | |
1226 // specifically designed to prevent the pre-increment value of a loop trip | |
1227 // counter from being live out of the bottom of the loop (hence causing the | |
1228 // pre- and post-increment values both being live and thus requiring an extra | |
1229 // temp register and an extra move). If we "accidentally" optimize through | |
1230 // this kind of a Node, we'll get slightly pessimal, but correct, code. Thus | |
1231 // it's OK to be slightly sloppy on optimizations here. | |
1232 | |
1233 // Do not allow value-numbering | |
1234 uint Opaque2Node::hash() const { return NO_HASH; } | |
1235 uint Opaque2Node::cmp( const Node &n ) const { | |
1236 return (&n == this); // Always fail except on self | |
1237 } | |
1238 | |
1239 | |
1240 //------------------------------Value------------------------------------------ | |
1241 const Type *MoveL2DNode::Value( PhaseTransform *phase ) const { | |
1242 const Type *t = phase->type( in(1) ); | |
1243 if( t == Type::TOP ) return Type::TOP; | |
1244 const TypeLong *tl = t->is_long(); | |
1245 if( !tl->is_con() ) return bottom_type(); | |
1246 JavaValue v; | |
1247 v.set_jlong(tl->get_con()); | |
1248 return TypeD::make( v.get_jdouble() ); | |
1249 } | |
1250 | |
1251 //------------------------------Value------------------------------------------ | |
1252 const Type *MoveI2FNode::Value( PhaseTransform *phase ) const { | |
1253 const Type *t = phase->type( in(1) ); | |
1254 if( t == Type::TOP ) return Type::TOP; | |
1255 const TypeInt *ti = t->is_int(); | |
1256 if( !ti->is_con() ) return bottom_type(); | |
1257 JavaValue v; | |
1258 v.set_jint(ti->get_con()); | |
1259 return TypeF::make( v.get_jfloat() ); | |
1260 } | |
1261 | |
1262 //------------------------------Value------------------------------------------ | |
1263 const Type *MoveF2INode::Value( PhaseTransform *phase ) const { | |
1264 const Type *t = phase->type( in(1) ); | |
1265 if( t == Type::TOP ) return Type::TOP; | |
1266 if( t == Type::FLOAT ) return TypeInt::INT; | |
1267 const TypeF *tf = t->is_float_constant(); | |
1268 JavaValue v; | |
1269 v.set_jfloat(tf->getf()); | |
1270 return TypeInt::make( v.get_jint() ); | |
1271 } | |
1272 | |
1273 //------------------------------Value------------------------------------------ | |
1274 const Type *MoveD2LNode::Value( PhaseTransform *phase ) const { | |
1275 const Type *t = phase->type( in(1) ); | |
1276 if( t == Type::TOP ) return Type::TOP; | |
1277 if( t == Type::DOUBLE ) return TypeLong::LONG; | |
1278 const TypeD *td = t->is_double_constant(); | |
1279 JavaValue v; | |
1280 v.set_jdouble(td->getd()); | |
1281 return TypeLong::make( v.get_jlong() ); | |
1282 } |