annotate src/share/vm/opto/connode.cpp @ 36:f34d9da7acb2

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