annotate src/share/vm/opto/connode.cpp @ 24164:f98ea2d742a2

fixed missing exception propagation (JDK-8185790)
author Doug Simon <doug.simon@oracle.com>
date Tue, 08 Aug 2017 10:06:50 +0200
parents 9b69cec6d01b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
14223
de6a9e811145 8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents: 12226
diff changeset
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 995
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 995
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 995
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
26 #include "memory/allocation.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
27 #include "opto/addnode.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
28 #include "opto/compile.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
29 #include "opto/connode.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
30 #include "opto/machnode.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
31 #include "opto/matcher.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
32 #include "opto/memnode.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
33 #include "opto/phaseX.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
34 #include "opto/subnode.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
35 #include "runtime/sharedRuntime.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
36
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
37 // Optimization - Graph Style
0
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
40 //------------------------------hash-------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
41 uint ConNode::hash() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
42 return (uintptr_t)in(TypeFunc::Control) + _type->hash();
a61af66fc99e Initial load
duke
parents:
diff changeset
43 }
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 //------------------------------make-------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
46 ConNode *ConNode::make( Compile* C, const Type *t ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 switch( t->basic_type() ) {
6848
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
48 case T_INT: return new (C) ConINode( t->is_int() );
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
49 case T_LONG: return new (C) ConLNode( t->is_long() );
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
50 case T_FLOAT: return new (C) ConFNode( t->is_float_constant() );
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
51 case T_DOUBLE: return new (C) ConDNode( t->is_double_constant() );
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
52 case T_VOID: return new (C) ConNode ( Type::TOP );
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
53 case T_OBJECT: return new (C) ConPNode( t->is_ptr() );
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
54 case T_ARRAY: return new (C) ConPNode( t->is_aryptr() );
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
55 case T_ADDRESS: return new (C) ConPNode( t->is_ptr() );
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
56 case T_NARROWOOP: return new (C) ConNNode( t->is_narrowoop() );
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
57 case T_NARROWKLASS: return new (C) ConNKlassNode( t->is_narrowklass() );
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
58 case T_METADATA: return new (C) ConPNode( t->is_ptr() );
0
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // Expected cases: TypePtr::NULL_PTR, any is_rawptr()
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // Also seen: AnyPtr(TopPTR *+top); from command line:
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // r -XX:+PrintOpto -XX:CIStart=285 -XX:+CompileTheWorld -XX:CompileTheWorldStartAt=660
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // %%%% Stop using TypePtr::NULL_PTR to represent nulls: use either TypeRawPtr::NULL_PTR
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // or else TypeOopPtr::NULL_PTR. Then set Type::_basic_type[AnyPtr] = T_ILLEGAL
a61af66fc99e Initial load
duke
parents:
diff changeset
64 }
a61af66fc99e Initial load
duke
parents:
diff changeset
65 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
66 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 }
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
70 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
71 The major change is for CMoveP and StrComp. They have related but slightly
a61af66fc99e Initial load
duke
parents:
diff changeset
72 different problems. They both take in TWO oops which are both null-checked
a61af66fc99e Initial load
duke
parents:
diff changeset
73 independently before the using Node. After CCP removes the CastPP's they need
a61af66fc99e Initial load
duke
parents:
diff changeset
74 to pick up the guarding test edge - in this case TWO control edges. I tried
a61af66fc99e Initial load
duke
parents:
diff changeset
75 various solutions, all have problems:
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 (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
78 StrComp above a guarding null check. I've seen both cases in normal -Xcomp
a61af66fc99e Initial load
duke
parents:
diff changeset
79 testing.
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 (2) Plug the control edge from 1 of the 2 oops in. Apparent problem here is
a61af66fc99e Initial load
duke
parents:
diff changeset
82 to figure out which test post-dominates. The real problem is that it doesn't
a61af66fc99e Initial load
duke
parents:
diff changeset
83 matter which one you pick. After you pick up, the dominating-test elider in
a61af66fc99e Initial load
duke
parents:
diff changeset
84 IGVN can remove the test and allow you to hoist up to the dominating test on
605
98cb887364d3 6810672: Comment typos
twisti
parents: 368
diff changeset
85 the chosen oop bypassing the test on the not-chosen oop. Seen in testing.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
86 Oops.
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 (3) Leave the CastPP's in. This makes the graph more accurate in some sense;
a61af66fc99e Initial load
duke
parents:
diff changeset
89 we get to keep around the knowledge that an oop is not-null after some test.
a61af66fc99e Initial load
duke
parents:
diff changeset
90 Alas, the CastPP's interfere with GVN (some values are the regular oop, some
a61af66fc99e Initial load
duke
parents:
diff changeset
91 are the CastPP of the oop, all merge at Phi's which cannot collapse, etc).
a61af66fc99e Initial load
duke
parents:
diff changeset
92 This cost us 10% on SpecJVM, even when I removed some of the more trivial
a61af66fc99e Initial load
duke
parents:
diff changeset
93 cases in the optimizer. Removing more useless Phi's started allowing Loads to
a61af66fc99e Initial load
duke
parents:
diff changeset
94 illegally float above null checks. I gave up on this approach.
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 (4) Add BOTH control edges to both tests. Alas, too much code knows that
a61af66fc99e Initial load
duke
parents:
diff changeset
97 control edges are in slot-zero ONLY. Many quick asserts fail; no way to do
a61af66fc99e Initial load
duke
parents:
diff changeset
98 this one. Note that I really want to allow the CMoveP to float and add both
a61af66fc99e Initial load
duke
parents:
diff changeset
99 control edges to the dependent Load op - meaning I can select early but I
a61af66fc99e Initial load
duke
parents:
diff changeset
100 cannot Load until I pass both tests.
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 (5) Do not hoist CMoveP and StrComp. To this end I added the v-call
a61af66fc99e Initial load
duke
parents:
diff changeset
103 depends_only_on_test(). No obvious performance loss on Spec, but we are
a61af66fc99e Initial load
duke
parents:
diff changeset
104 clearly conservative on CMoveP (also so on StrComp but that's unlikely to
a61af66fc99e Initial load
duke
parents:
diff changeset
105 matter ever).
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107 */
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 //------------------------------Ideal------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // Return a node which is more "ideal" than the current node.
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // Move constants to the right.
a61af66fc99e Initial load
duke
parents:
diff changeset
113 Node *CMoveNode::Ideal(PhaseGVN *phase, bool can_reshape) {
a61af66fc99e Initial load
duke
parents:
diff changeset
114 if( in(0) && remove_dead_region(phase, can_reshape) ) return this;
305
ab075d07f1ba 6736417: Fastdebug C2 crashes in StoreBNode::Ideal
kvn
parents: 235
diff changeset
115 // Don't bother trying to transform a dead node
ab075d07f1ba 6736417: Fastdebug C2 crashes in StoreBNode::Ideal
kvn
parents: 235
diff changeset
116 if( in(0) && in(0)->is_top() ) return NULL;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
117 assert( !phase->eqv(in(Condition), this) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
118 !phase->eqv(in(IfFalse), this) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
119 !phase->eqv(in(IfTrue), this), "dead loop in CMoveNode::Ideal" );
a61af66fc99e Initial load
duke
parents:
diff changeset
120 if( phase->type(in(Condition)) == Type::TOP )
a61af66fc99e Initial load
duke
parents:
diff changeset
121 return NULL; // return NULL when Condition is dead
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 if( in(IfFalse)->is_Con() && !in(IfTrue)->is_Con() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
124 if( in(Condition)->is_Bool() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
125 BoolNode* b = in(Condition)->as_Bool();
a61af66fc99e Initial load
duke
parents:
diff changeset
126 BoolNode* b2 = b->negate(phase);
a61af66fc99e Initial load
duke
parents:
diff changeset
127 return make( phase->C, in(Control), phase->transform(b2), in(IfTrue), in(IfFalse), _type );
a61af66fc99e Initial load
duke
parents:
diff changeset
128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
129 }
a61af66fc99e Initial load
duke
parents:
diff changeset
130 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
131 }
a61af66fc99e Initial load
duke
parents:
diff changeset
132
a61af66fc99e Initial load
duke
parents:
diff changeset
133 //------------------------------is_cmove_id------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // Helper function to check for CMOVE identity. Shared with PhiNode::Identity
a61af66fc99e Initial load
duke
parents:
diff changeset
135 Node *CMoveNode::is_cmove_id( PhaseTransform *phase, Node *cmp, Node *t, Node *f, BoolNode *b ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 // Check for Cmp'ing and CMove'ing same values
a61af66fc99e Initial load
duke
parents:
diff changeset
137 if( (phase->eqv(cmp->in(1),f) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
138 phase->eqv(cmp->in(2),t)) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
139 // Swapped Cmp is OK
a61af66fc99e Initial load
duke
parents:
diff changeset
140 (phase->eqv(cmp->in(2),f) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
141 phase->eqv(cmp->in(1),t)) ) {
755
36ee9b69616e 6833879: Assigning positive zero is ignored when old value is negative zero
cfang
parents: 642
diff changeset
142 // Give up this identity check for floating points because it may choose incorrect
36ee9b69616e 6833879: Assigning positive zero is ignored when old value is negative zero
cfang
parents: 642
diff changeset
143 // value around 0.0 and -0.0
36ee9b69616e 6833879: Assigning positive zero is ignored when old value is negative zero
cfang
parents: 642
diff changeset
144 if ( cmp->Opcode()==Op_CmpF || cmp->Opcode()==Op_CmpD )
36ee9b69616e 6833879: Assigning positive zero is ignored when old value is negative zero
cfang
parents: 642
diff changeset
145 return NULL;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
146 // Check for "(t==f)?t:f;" and replace with "f"
a61af66fc99e Initial load
duke
parents:
diff changeset
147 if( b->_test._test == BoolTest::eq )
a61af66fc99e Initial load
duke
parents:
diff changeset
148 return f;
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // Allow the inverted case as well
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // Check for "(t!=f)?t:f;" and replace with "t"
a61af66fc99e Initial load
duke
parents:
diff changeset
151 if( b->_test._test == BoolTest::ne )
a61af66fc99e Initial load
duke
parents:
diff changeset
152 return t;
a61af66fc99e Initial load
duke
parents:
diff changeset
153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
154 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
155 }
a61af66fc99e Initial load
duke
parents:
diff changeset
156
a61af66fc99e Initial load
duke
parents:
diff changeset
157 //------------------------------Identity---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
158 // Conditional-move is an identity if both inputs are the same, or the test
a61af66fc99e Initial load
duke
parents:
diff changeset
159 // true or false.
a61af66fc99e Initial load
duke
parents:
diff changeset
160 Node *CMoveNode::Identity( PhaseTransform *phase ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
161 if( phase->eqv(in(IfFalse),in(IfTrue)) ) // C-moving identical inputs?
a61af66fc99e Initial load
duke
parents:
diff changeset
162 return in(IfFalse); // Then it doesn't matter
a61af66fc99e Initial load
duke
parents:
diff changeset
163 if( phase->type(in(Condition)) == TypeInt::ZERO )
a61af66fc99e Initial load
duke
parents:
diff changeset
164 return in(IfFalse); // Always pick left(false) input
a61af66fc99e Initial load
duke
parents:
diff changeset
165 if( phase->type(in(Condition)) == TypeInt::ONE )
a61af66fc99e Initial load
duke
parents:
diff changeset
166 return in(IfTrue); // Always pick right(true) input
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168 // Check for CMove'ing a constant after comparing against the constant.
a61af66fc99e Initial load
duke
parents:
diff changeset
169 // Happens all the time now, since if we compare equality vs a constant in
a61af66fc99e Initial load
duke
parents:
diff changeset
170 // the parser, we "know" the variable is constant on one path and we force
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // it. Thus code like "if( x==0 ) {/*EMPTY*/}" ends up inserting a
a61af66fc99e Initial load
duke
parents:
diff changeset
172 // conditional move: "x = (x==0)?0:x;". Yucko. This fix is slightly more
a61af66fc99e Initial load
duke
parents:
diff changeset
173 // general in that we don't need constants.
a61af66fc99e Initial load
duke
parents:
diff changeset
174 if( in(Condition)->is_Bool() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
175 BoolNode *b = in(Condition)->as_Bool();
a61af66fc99e Initial load
duke
parents:
diff changeset
176 Node *cmp = b->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
177 if( cmp->is_Cmp() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
178 Node *id = is_cmove_id( phase, cmp, in(IfTrue), in(IfFalse), b );
a61af66fc99e Initial load
duke
parents:
diff changeset
179 if( id ) return id;
a61af66fc99e Initial load
duke
parents:
diff changeset
180 }
a61af66fc99e Initial load
duke
parents:
diff changeset
181 }
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 return this;
a61af66fc99e Initial load
duke
parents:
diff changeset
184 }
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
187 // Result is the meet of inputs
a61af66fc99e Initial load
duke
parents:
diff changeset
188 const Type *CMoveNode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
189 if( phase->type(in(Condition)) == Type::TOP )
a61af66fc99e Initial load
duke
parents:
diff changeset
190 return Type::TOP;
14383
5ec7dace41a6 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents: 14223
diff changeset
191 return phase->type(in(IfFalse))->meet_speculative(phase->type(in(IfTrue)));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
192 }
a61af66fc99e Initial load
duke
parents:
diff changeset
193
a61af66fc99e Initial load
duke
parents:
diff changeset
194 //------------------------------make-------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
195 // Make a correctly-flavored CMove. Since _type is directly determined
a61af66fc99e Initial load
duke
parents:
diff changeset
196 // from the inputs we do not need to specify it here.
a61af66fc99e Initial load
duke
parents:
diff changeset
197 CMoveNode *CMoveNode::make( Compile *C, Node *c, Node *bol, Node *left, Node *right, const Type *t ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
198 switch( t->basic_type() ) {
6804
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6795
diff changeset
199 case T_INT: return new (C) CMoveINode( bol, left, right, t->is_int() );
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6795
diff changeset
200 case T_FLOAT: return new (C) CMoveFNode( bol, left, right, t );
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6795
diff changeset
201 case T_DOUBLE: return new (C) CMoveDNode( bol, left, right, t );
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6795
diff changeset
202 case T_LONG: return new (C) CMoveLNode( bol, left, right, t->is_long() );
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6795
diff changeset
203 case T_OBJECT: return new (C) CMovePNode( c, bol, left, right, t->is_oopptr() );
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6795
diff changeset
204 case T_ADDRESS: return new (C) CMovePNode( c, bol, left, right, t->is_ptr() );
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6795
diff changeset
205 case T_NARROWOOP: return new (C) CMoveNNode( c, bol, left, right, t );
0
a61af66fc99e Initial load
duke
parents:
diff changeset
206 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
207 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
208 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
209 }
a61af66fc99e Initial load
duke
parents:
diff changeset
210 }
a61af66fc99e Initial load
duke
parents:
diff changeset
211
a61af66fc99e Initial load
duke
parents:
diff changeset
212 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
213 //------------------------------Ideal------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // Return a node which is more "ideal" than the current node.
a61af66fc99e Initial load
duke
parents:
diff changeset
215 // Check for conversions to boolean
a61af66fc99e Initial load
duke
parents:
diff changeset
216 Node *CMoveINode::Ideal(PhaseGVN *phase, bool can_reshape) {
a61af66fc99e Initial load
duke
parents:
diff changeset
217 // Try generic ideal's first
a61af66fc99e Initial load
duke
parents:
diff changeset
218 Node *x = CMoveNode::Ideal(phase, can_reshape);
a61af66fc99e Initial load
duke
parents:
diff changeset
219 if( x ) return x;
a61af66fc99e Initial load
duke
parents:
diff changeset
220
a61af66fc99e Initial load
duke
parents:
diff changeset
221 // If zero is on the left (false-case, no-move-case) it must mean another
a61af66fc99e Initial load
duke
parents:
diff changeset
222 // constant is on the right (otherwise the shared CMove::Ideal code would
a61af66fc99e Initial load
duke
parents:
diff changeset
223 // have moved the constant to the right). This situation is bad for Intel
a61af66fc99e Initial load
duke
parents:
diff changeset
224 // and a don't-care for Sparc. It's bad for Intel because the zero has to
a61af66fc99e Initial load
duke
parents:
diff changeset
225 // be manifested in a register with a XOR which kills flags, which are live
a61af66fc99e Initial load
duke
parents:
diff changeset
226 // on input to the CMoveI, leading to a situation which causes excessive
a61af66fc99e Initial load
duke
parents:
diff changeset
227 // spilling on Intel. For Sparc, if the zero in on the left the Sparc will
a61af66fc99e Initial load
duke
parents:
diff changeset
228 // zero a register via G0 and conditionally-move the other constant. If the
a61af66fc99e Initial load
duke
parents:
diff changeset
229 // zero is on the right, the Sparc will load the first constant with a
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // 13-bit set-lo and conditionally move G0. See bug 4677505.
a61af66fc99e Initial load
duke
parents:
diff changeset
231 if( phase->type(in(IfFalse)) == TypeInt::ZERO && !(phase->type(in(IfTrue)) == TypeInt::ZERO) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
232 if( in(Condition)->is_Bool() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
233 BoolNode* b = in(Condition)->as_Bool();
a61af66fc99e Initial load
duke
parents:
diff changeset
234 BoolNode* b2 = b->negate(phase);
a61af66fc99e Initial load
duke
parents:
diff changeset
235 return make( phase->C, in(Control), phase->transform(b2), in(IfTrue), in(IfFalse), _type );
a61af66fc99e Initial load
duke
parents:
diff changeset
236 }
a61af66fc99e Initial load
duke
parents:
diff changeset
237 }
a61af66fc99e Initial load
duke
parents:
diff changeset
238
a61af66fc99e Initial load
duke
parents:
diff changeset
239 // Now check for booleans
a61af66fc99e Initial load
duke
parents:
diff changeset
240 int flip = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
241
a61af66fc99e Initial load
duke
parents:
diff changeset
242 // Check for picking from zero/one
a61af66fc99e Initial load
duke
parents:
diff changeset
243 if( phase->type(in(IfFalse)) == TypeInt::ZERO && phase->type(in(IfTrue)) == TypeInt::ONE ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
244 flip = 1 - flip;
a61af66fc99e Initial load
duke
parents:
diff changeset
245 } else if( phase->type(in(IfFalse)) == TypeInt::ONE && phase->type(in(IfTrue)) == TypeInt::ZERO ) {
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 // Check for eq/ne test
a61af66fc99e Initial load
duke
parents:
diff changeset
249 if( !in(1)->is_Bool() ) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
250 BoolNode *bol = in(1)->as_Bool();
a61af66fc99e Initial load
duke
parents:
diff changeset
251 if( bol->_test._test == BoolTest::eq ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
252 } else if( bol->_test._test == BoolTest::ne ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
253 flip = 1-flip;
a61af66fc99e Initial load
duke
parents:
diff changeset
254 } else return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
255
a61af66fc99e Initial load
duke
parents:
diff changeset
256 // Check for vs 0 or 1
a61af66fc99e Initial load
duke
parents:
diff changeset
257 if( !bol->in(1)->is_Cmp() ) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
258 const CmpNode *cmp = bol->in(1)->as_Cmp();
a61af66fc99e Initial load
duke
parents:
diff changeset
259 if( phase->type(cmp->in(2)) == TypeInt::ZERO ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
260 } else if( phase->type(cmp->in(2)) == TypeInt::ONE ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
261 // Allow cmp-vs-1 if the other input is bounded by 0-1
a61af66fc99e Initial load
duke
parents:
diff changeset
262 if( phase->type(cmp->in(1)) != TypeInt::BOOL )
a61af66fc99e Initial load
duke
parents:
diff changeset
263 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
264 flip = 1 - flip;
a61af66fc99e Initial load
duke
parents:
diff changeset
265 } else return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
266
a61af66fc99e Initial load
duke
parents:
diff changeset
267 // Convert to a bool (flipped)
a61af66fc99e Initial load
duke
parents:
diff changeset
268 // Build int->bool conversion
a61af66fc99e Initial load
duke
parents:
diff changeset
269 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
270 if( PrintOpto ) tty->print_cr("CMOV to I2B");
a61af66fc99e Initial load
duke
parents:
diff changeset
271 #endif
6804
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6795
diff changeset
272 Node *n = new (phase->C) Conv2BNode( cmp->in(1) );
0
a61af66fc99e Initial load
duke
parents:
diff changeset
273 if( flip )
6804
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6795
diff changeset
274 n = new (phase->C) XorINode( phase->transform(n), phase->intcon(1) );
0
a61af66fc99e Initial load
duke
parents:
diff changeset
275
a61af66fc99e Initial load
duke
parents:
diff changeset
276 return n;
a61af66fc99e Initial load
duke
parents:
diff changeset
277 }
a61af66fc99e Initial load
duke
parents:
diff changeset
278
a61af66fc99e Initial load
duke
parents:
diff changeset
279 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
280 //------------------------------Ideal------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
281 // Return a node which is more "ideal" than the current node.
a61af66fc99e Initial load
duke
parents:
diff changeset
282 // Check for absolute value
a61af66fc99e Initial load
duke
parents:
diff changeset
283 Node *CMoveFNode::Ideal(PhaseGVN *phase, bool can_reshape) {
a61af66fc99e Initial load
duke
parents:
diff changeset
284 // Try generic ideal's first
a61af66fc99e Initial load
duke
parents:
diff changeset
285 Node *x = CMoveNode::Ideal(phase, can_reshape);
a61af66fc99e Initial load
duke
parents:
diff changeset
286 if( x ) return x;
a61af66fc99e Initial load
duke
parents:
diff changeset
287
a61af66fc99e Initial load
duke
parents:
diff changeset
288 int cmp_zero_idx = 0; // Index of compare input where to look for zero
a61af66fc99e Initial load
duke
parents:
diff changeset
289 int phi_x_idx = 0; // Index of phi input where to find naked x
a61af66fc99e Initial load
duke
parents:
diff changeset
290
a61af66fc99e Initial load
duke
parents:
diff changeset
291 // Find the Bool
a61af66fc99e Initial load
duke
parents:
diff changeset
292 if( !in(1)->is_Bool() ) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
293 BoolNode *bol = in(1)->as_Bool();
a61af66fc99e Initial load
duke
parents:
diff changeset
294 // Check bool sense
a61af66fc99e Initial load
duke
parents:
diff changeset
295 switch( bol->_test._test ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
296 case BoolTest::lt: cmp_zero_idx = 1; phi_x_idx = IfTrue; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
297 case BoolTest::le: cmp_zero_idx = 2; phi_x_idx = IfFalse; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
298 case BoolTest::gt: cmp_zero_idx = 2; phi_x_idx = IfTrue; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
299 case BoolTest::ge: cmp_zero_idx = 1; phi_x_idx = IfFalse; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
300 default: return NULL; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
301 }
a61af66fc99e Initial load
duke
parents:
diff changeset
302
a61af66fc99e Initial load
duke
parents:
diff changeset
303 // Find zero input of CmpF; the other input is being abs'd
a61af66fc99e Initial load
duke
parents:
diff changeset
304 Node *cmpf = bol->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
305 if( cmpf->Opcode() != Op_CmpF ) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
306 Node *X = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
307 bool flip = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
308 if( phase->type(cmpf->in(cmp_zero_idx)) == TypeF::ZERO ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
309 X = cmpf->in(3 - cmp_zero_idx);
a61af66fc99e Initial load
duke
parents:
diff changeset
310 } else if (phase->type(cmpf->in(3 - cmp_zero_idx)) == TypeF::ZERO) {
a61af66fc99e Initial load
duke
parents:
diff changeset
311 // The test is inverted, we should invert the result...
a61af66fc99e Initial load
duke
parents:
diff changeset
312 X = cmpf->in(cmp_zero_idx);
a61af66fc99e Initial load
duke
parents:
diff changeset
313 flip = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
314 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
315 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
316 }
a61af66fc99e Initial load
duke
parents:
diff changeset
317
a61af66fc99e Initial load
duke
parents:
diff changeset
318 // If X is found on the appropriate phi input, find the subtract on the other
a61af66fc99e Initial load
duke
parents:
diff changeset
319 if( X != in(phi_x_idx) ) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
320 int phi_sub_idx = phi_x_idx == IfTrue ? IfFalse : IfTrue;
a61af66fc99e Initial load
duke
parents:
diff changeset
321 Node *sub = in(phi_sub_idx);
a61af66fc99e Initial load
duke
parents:
diff changeset
322
a61af66fc99e Initial load
duke
parents:
diff changeset
323 // Allow only SubF(0,X) and fail out for all others; NegF is not OK
a61af66fc99e Initial load
duke
parents:
diff changeset
324 if( sub->Opcode() != Op_SubF ||
a61af66fc99e Initial load
duke
parents:
diff changeset
325 sub->in(2) != X ||
a61af66fc99e Initial load
duke
parents:
diff changeset
326 phase->type(sub->in(1)) != TypeF::ZERO ) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
327
6804
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6795
diff changeset
328 Node *abs = new (phase->C) AbsFNode( X );
0
a61af66fc99e Initial load
duke
parents:
diff changeset
329 if( flip )
6804
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6795
diff changeset
330 abs = new (phase->C) SubFNode(sub->in(1), phase->transform(abs));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
331
a61af66fc99e Initial load
duke
parents:
diff changeset
332 return abs;
a61af66fc99e Initial load
duke
parents:
diff changeset
333 }
a61af66fc99e Initial load
duke
parents:
diff changeset
334
a61af66fc99e Initial load
duke
parents:
diff changeset
335 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
336 //------------------------------Ideal------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
337 // Return a node which is more "ideal" than the current node.
a61af66fc99e Initial load
duke
parents:
diff changeset
338 // Check for absolute value
a61af66fc99e Initial load
duke
parents:
diff changeset
339 Node *CMoveDNode::Ideal(PhaseGVN *phase, bool can_reshape) {
a61af66fc99e Initial load
duke
parents:
diff changeset
340 // Try generic ideal's first
a61af66fc99e Initial load
duke
parents:
diff changeset
341 Node *x = CMoveNode::Ideal(phase, can_reshape);
a61af66fc99e Initial load
duke
parents:
diff changeset
342 if( x ) return x;
a61af66fc99e Initial load
duke
parents:
diff changeset
343
a61af66fc99e Initial load
duke
parents:
diff changeset
344 int cmp_zero_idx = 0; // Index of compare input where to look for zero
a61af66fc99e Initial load
duke
parents:
diff changeset
345 int phi_x_idx = 0; // Index of phi input where to find naked x
a61af66fc99e Initial load
duke
parents:
diff changeset
346
a61af66fc99e Initial load
duke
parents:
diff changeset
347 // Find the Bool
a61af66fc99e Initial load
duke
parents:
diff changeset
348 if( !in(1)->is_Bool() ) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
349 BoolNode *bol = in(1)->as_Bool();
a61af66fc99e Initial load
duke
parents:
diff changeset
350 // Check bool sense
a61af66fc99e Initial load
duke
parents:
diff changeset
351 switch( bol->_test._test ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
352 case BoolTest::lt: cmp_zero_idx = 1; phi_x_idx = IfTrue; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
353 case BoolTest::le: cmp_zero_idx = 2; phi_x_idx = IfFalse; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
354 case BoolTest::gt: cmp_zero_idx = 2; phi_x_idx = IfTrue; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
355 case BoolTest::ge: cmp_zero_idx = 1; phi_x_idx = IfFalse; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
356 default: return NULL; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
357 }
a61af66fc99e Initial load
duke
parents:
diff changeset
358
a61af66fc99e Initial load
duke
parents:
diff changeset
359 // Find zero input of CmpD; the other input is being abs'd
a61af66fc99e Initial load
duke
parents:
diff changeset
360 Node *cmpd = bol->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
361 if( cmpd->Opcode() != Op_CmpD ) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
362 Node *X = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
363 bool flip = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
364 if( phase->type(cmpd->in(cmp_zero_idx)) == TypeD::ZERO ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
365 X = cmpd->in(3 - cmp_zero_idx);
a61af66fc99e Initial load
duke
parents:
diff changeset
366 } else if (phase->type(cmpd->in(3 - cmp_zero_idx)) == TypeD::ZERO) {
a61af66fc99e Initial load
duke
parents:
diff changeset
367 // The test is inverted, we should invert the result...
a61af66fc99e Initial load
duke
parents:
diff changeset
368 X = cmpd->in(cmp_zero_idx);
a61af66fc99e Initial load
duke
parents:
diff changeset
369 flip = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
370 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
371 return NULL;
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 X is found on the appropriate phi input, find the subtract on the other
a61af66fc99e Initial load
duke
parents:
diff changeset
375 if( X != in(phi_x_idx) ) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
376 int phi_sub_idx = phi_x_idx == IfTrue ? IfFalse : IfTrue;
a61af66fc99e Initial load
duke
parents:
diff changeset
377 Node *sub = in(phi_sub_idx);
a61af66fc99e Initial load
duke
parents:
diff changeset
378
a61af66fc99e Initial load
duke
parents:
diff changeset
379 // Allow only SubD(0,X) and fail out for all others; NegD is not OK
a61af66fc99e Initial load
duke
parents:
diff changeset
380 if( sub->Opcode() != Op_SubD ||
a61af66fc99e Initial load
duke
parents:
diff changeset
381 sub->in(2) != X ||
a61af66fc99e Initial load
duke
parents:
diff changeset
382 phase->type(sub->in(1)) != TypeD::ZERO ) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
383
6804
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6795
diff changeset
384 Node *abs = new (phase->C) AbsDNode( X );
0
a61af66fc99e Initial load
duke
parents:
diff changeset
385 if( flip )
6804
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6795
diff changeset
386 abs = new (phase->C) SubDNode(sub->in(1), phase->transform(abs));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
387
a61af66fc99e Initial load
duke
parents:
diff changeset
388 return abs;
a61af66fc99e Initial load
duke
parents:
diff changeset
389 }
a61af66fc99e Initial load
duke
parents:
diff changeset
390
a61af66fc99e Initial load
duke
parents:
diff changeset
391
a61af66fc99e Initial load
duke
parents:
diff changeset
392 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
393 // If input is already higher or equal to cast type, then this is an identity.
a61af66fc99e Initial load
duke
parents:
diff changeset
394 Node *ConstraintCastNode::Identity( PhaseTransform *phase ) {
14383
5ec7dace41a6 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents: 14223
diff changeset
395 return phase->type(in(1))->higher_equal_speculative(_type) ? in(1) : this;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
396 }
a61af66fc99e Initial load
duke
parents:
diff changeset
397
a61af66fc99e Initial load
duke
parents:
diff changeset
398 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
399 // Take 'join' of input and cast-up type
a61af66fc99e Initial load
duke
parents:
diff changeset
400 const Type *ConstraintCastNode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
401 if( in(0) && phase->type(in(0)) == Type::TOP ) return Type::TOP;
14383
5ec7dace41a6 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents: 14223
diff changeset
402 const Type* ft = phase->type(in(1))->filter_speculative(_type);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
403
a61af66fc99e Initial load
duke
parents:
diff changeset
404 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
405 // Previous versions of this function had some special case logic,
a61af66fc99e Initial load
duke
parents:
diff changeset
406 // which is no longer necessary. Make sure of the required effects.
a61af66fc99e Initial load
duke
parents:
diff changeset
407 switch (Opcode()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
408 case Op_CastII:
a61af66fc99e Initial load
duke
parents:
diff changeset
409 {
a61af66fc99e Initial load
duke
parents:
diff changeset
410 const Type* t1 = phase->type(in(1));
a61af66fc99e Initial load
duke
parents:
diff changeset
411 if( t1 == Type::TOP ) assert(ft == Type::TOP, "special case #1");
14383
5ec7dace41a6 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents: 14223
diff changeset
412 const Type* rt = t1->join_speculative(_type);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
413 if (rt->empty()) assert(ft == Type::TOP, "special case #2");
a61af66fc99e Initial load
duke
parents:
diff changeset
414 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
415 }
a61af66fc99e Initial load
duke
parents:
diff changeset
416 case Op_CastPP:
a61af66fc99e Initial load
duke
parents:
diff changeset
417 if (phase->type(in(1)) == TypePtr::NULL_PTR &&
a61af66fc99e Initial load
duke
parents:
diff changeset
418 _type->isa_ptr() && _type->is_ptr()->_ptr == TypePtr::NotNull)
a61af66fc99e Initial load
duke
parents:
diff changeset
419 assert(ft == Type::TOP, "special case #3");
a61af66fc99e Initial load
duke
parents:
diff changeset
420 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
421 }
a61af66fc99e Initial load
duke
parents:
diff changeset
422 #endif //ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
423
a61af66fc99e Initial load
duke
parents:
diff changeset
424 return ft;
a61af66fc99e Initial load
duke
parents:
diff changeset
425 }
a61af66fc99e Initial load
duke
parents:
diff changeset
426
a61af66fc99e Initial load
duke
parents:
diff changeset
427 //------------------------------Ideal------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
428 // Return a node which is more "ideal" than the current node. Strip out
a61af66fc99e Initial load
duke
parents:
diff changeset
429 // control copies
a61af66fc99e Initial load
duke
parents:
diff changeset
430 Node *ConstraintCastNode::Ideal(PhaseGVN *phase, bool can_reshape){
a61af66fc99e Initial load
duke
parents:
diff changeset
431 return (in(0) && remove_dead_region(phase, can_reshape)) ? this : NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
432 }
a61af66fc99e Initial load
duke
parents:
diff changeset
433
a61af66fc99e Initial load
duke
parents:
diff changeset
434 //------------------------------Ideal_DU_postCCP-------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
435 // Throw away cast after constant propagation
a61af66fc99e Initial load
duke
parents:
diff changeset
436 Node *ConstraintCastNode::Ideal_DU_postCCP( PhaseCCP *ccp ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
437 const Type *t = ccp->type(in(1));
a61af66fc99e Initial load
duke
parents:
diff changeset
438 ccp->hash_delete(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
439 set_type(t); // Turn into ID function
a61af66fc99e Initial load
duke
parents:
diff changeset
440 ccp->hash_insert(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
441 return this;
a61af66fc99e Initial load
duke
parents:
diff changeset
442 }
a61af66fc99e Initial load
duke
parents:
diff changeset
443
20680
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
444 uint CastIINode::size_of() const {
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
445 return sizeof(*this);
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
446 }
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
447
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
448 uint CastIINode::cmp(const Node &n) const {
24008
64bd5b63923c 8154831: CastII/ConvI2L for a range check is prematurely eliminated
vlivanov
parents: 23799
diff changeset
449 return TypeNode::cmp(n) &&
64bd5b63923c 8154831: CastII/ConvI2L for a range check is prematurely eliminated
vlivanov
parents: 23799
diff changeset
450 ((CastIINode&)n)._carry_dependency == _carry_dependency &&
64bd5b63923c 8154831: CastII/ConvI2L for a range check is prematurely eliminated
vlivanov
parents: 23799
diff changeset
451 ((CastIINode&)n)._range_check_dependency == _range_check_dependency;
20680
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
452 }
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
453
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
454 Node *CastIINode::Identity(PhaseTransform *phase) {
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
455 if (_carry_dependency) {
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
456 return this;
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
457 }
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
458 return ConstraintCastNode::Identity(phase);
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
459 }
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
460
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
461 const Type *CastIINode::Value(PhaseTransform *phase) const {
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
462 const Type *res = ConstraintCastNode::Value(phase);
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
463
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
464 // Try to improve the type of the CastII if we recognize a CmpI/If
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
465 // pattern.
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
466 if (_carry_dependency) {
20708
d9e22e15d3f6 8066775: opto/node.hpp:355, assert(i < _max) failed: oob: i=1, _max=1
roland
parents: 20680
diff changeset
467 if (in(0) != NULL && in(0)->in(0) != NULL && in(0)->in(0)->is_If()) {
d9e22e15d3f6 8066775: opto/node.hpp:355, assert(i < _max) failed: oob: i=1, _max=1
roland
parents: 20680
diff changeset
468 assert(in(0)->is_IfFalse() || in(0)->is_IfTrue(), "should be If proj");
20680
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
469 Node* proj = in(0);
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
470 if (proj->in(0)->in(1)->is_Bool()) {
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
471 Node* b = proj->in(0)->in(1);
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
472 if (b->in(1)->Opcode() == Op_CmpI) {
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
473 Node* cmp = b->in(1);
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
474 if (cmp->in(1) == in(1) && phase->type(cmp->in(2))->isa_int()) {
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
475 const TypeInt* in2_t = phase->type(cmp->in(2))->is_int();
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
476 const Type* t = TypeInt::INT;
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
477 BoolTest test = b->as_Bool()->_test;
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
478 if (proj->is_IfFalse()) {
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
479 test = test.negate();
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
480 }
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
481 BoolTest::mask m = test._test;
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
482 jlong lo_long = min_jint;
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
483 jlong hi_long = max_jint;
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
484 if (m == BoolTest::le || m == BoolTest::lt) {
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
485 hi_long = in2_t->_hi;
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
486 if (m == BoolTest::lt) {
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
487 hi_long -= 1;
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
488 }
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
489 } else if (m == BoolTest::ge || m == BoolTest::gt) {
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
490 lo_long = in2_t->_lo;
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
491 if (m == BoolTest::gt) {
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
492 lo_long += 1;
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
493 }
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
494 } else if (m == BoolTest::eq) {
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
495 lo_long = in2_t->_lo;
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
496 hi_long = in2_t->_hi;
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
497 } else if (m == BoolTest::ne) {
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
498 // can't do any better
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
499 } else {
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
500 stringStream ss;
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
501 test.dump_on(&ss);
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
502 fatal(err_msg_res("unexpected comparison %s", ss.as_string()));
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
503 }
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
504 int lo_int = (int)lo_long;
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
505 int hi_int = (int)hi_long;
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
506
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
507 if (lo_long != (jlong)lo_int) {
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
508 lo_int = min_jint;
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
509 }
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
510 if (hi_long != (jlong)hi_int) {
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
511 hi_int = max_jint;
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
512 }
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
513
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
514 t = TypeInt::make(lo_int, hi_int, Type::WidenMax);
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
515
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
516 res = res->filter_speculative(t);
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
517
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
518 return res;
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
519 }
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
520 }
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
521 }
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
522 }
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
523 }
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
524 return res;
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
525 }
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
526
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
527 Node *CastIINode::Ideal_DU_postCCP(PhaseCCP *ccp) {
24008
64bd5b63923c 8154831: CastII/ConvI2L for a range check is prematurely eliminated
vlivanov
parents: 23799
diff changeset
528 if (_carry_dependency || _range_check_dependency) {
20680
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
529 return NULL;
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
530 }
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
531 return ConstraintCastNode::Ideal_DU_postCCP(ccp);
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
532 }
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
533
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
534 #ifndef PRODUCT
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
535 void CastIINode::dump_spec(outputStream *st) const {
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
536 TypeNode::dump_spec(st);
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
537 if (_carry_dependency) {
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
538 st->print(" carry dependency");
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
539 }
23799
535618ab1c04 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 22985
diff changeset
540 if (_range_check_dependency) {
535618ab1c04 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 22985
diff changeset
541 st->print(" range check dependency");
535618ab1c04 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 22985
diff changeset
542 }
20680
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
543 }
5b8e0f84f00f 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 14383
diff changeset
544 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
545
a61af66fc99e Initial load
duke
parents:
diff changeset
546 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
547
a61af66fc99e Initial load
duke
parents:
diff changeset
548 //------------------------------Ideal_DU_postCCP-------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
549 // If not converting int->oop, throw away cast after constant propagation
a61af66fc99e Initial load
duke
parents:
diff changeset
550 Node *CastPPNode::Ideal_DU_postCCP( PhaseCCP *ccp ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
551 const Type *t = ccp->type(in(1));
6848
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
552 if (!t->isa_oop_ptr() || ((in(1)->is_DecodeN()) && Matcher::gen_narrow_oop_implicit_null_checks())) {
368
36ccc817fca4 6747051: Improve code and implicit null check generation for compressed oops
kvn
parents: 305
diff changeset
553 return NULL; // do not transform raw pointers or narrow oops
0
a61af66fc99e Initial load
duke
parents:
diff changeset
554 }
a61af66fc99e Initial load
duke
parents:
diff changeset
555 return ConstraintCastNode::Ideal_DU_postCCP(ccp);
a61af66fc99e Initial load
duke
parents:
diff changeset
556 }
a61af66fc99e Initial load
duke
parents:
diff changeset
557
a61af66fc99e Initial load
duke
parents:
diff changeset
558
a61af66fc99e Initial load
duke
parents:
diff changeset
559
a61af66fc99e Initial load
duke
parents:
diff changeset
560 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
561 //------------------------------Identity---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
562 // If input is already higher or equal to cast type, then this is an identity.
a61af66fc99e Initial load
duke
parents:
diff changeset
563 Node *CheckCastPPNode::Identity( PhaseTransform *phase ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
564 // Toned down to rescue meeting at a Phi 3 different oops all implementing
a61af66fc99e Initial load
duke
parents:
diff changeset
565 // the same interface. CompileTheWorld starting at 502, kd12rc1.zip.
a61af66fc99e Initial load
duke
parents:
diff changeset
566 return (phase->type(in(1)) == phase->type(this)) ? in(1) : this;
a61af66fc99e Initial load
duke
parents:
diff changeset
567 }
a61af66fc99e Initial load
duke
parents:
diff changeset
568
a61af66fc99e Initial load
duke
parents:
diff changeset
569 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
570 // Take 'join' of input and cast-up type, unless working with an Interface
a61af66fc99e Initial load
duke
parents:
diff changeset
571 const Type *CheckCastPPNode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
572 if( in(0) && phase->type(in(0)) == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
573
a61af66fc99e Initial load
duke
parents:
diff changeset
574 const Type *inn = phase->type(in(1));
a61af66fc99e Initial load
duke
parents:
diff changeset
575 if( inn == Type::TOP ) return Type::TOP; // No information yet
a61af66fc99e Initial load
duke
parents:
diff changeset
576
a61af66fc99e Initial load
duke
parents:
diff changeset
577 const TypePtr *in_type = inn->isa_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
578 const TypePtr *my_type = _type->isa_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
579 const Type *result = _type;
a61af66fc99e Initial load
duke
parents:
diff changeset
580 if( in_type != NULL && my_type != NULL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
581 TypePtr::PTR in_ptr = in_type->ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
582 if( in_ptr == TypePtr::Null ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
583 result = in_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
584 } else if( in_ptr == TypePtr::Constant ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
585 // Casting a constant oop to an interface?
a61af66fc99e Initial load
duke
parents:
diff changeset
586 // (i.e., a String to a Comparable?)
a61af66fc99e Initial load
duke
parents:
diff changeset
587 // Then return the interface.
a61af66fc99e Initial load
duke
parents:
diff changeset
588 const TypeOopPtr *jptr = my_type->isa_oopptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
589 assert( jptr, "" );
a61af66fc99e Initial load
duke
parents:
diff changeset
590 result = (jptr->klass()->is_interface() || !in_type->higher_equal(_type))
a61af66fc99e Initial load
duke
parents:
diff changeset
591 ? my_type->cast_to_ptr_type( TypePtr::NotNull )
a61af66fc99e Initial load
duke
parents:
diff changeset
592 : in_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
593 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
594 result = my_type->cast_to_ptr_type( my_type->join_ptr(in_ptr) );
a61af66fc99e Initial load
duke
parents:
diff changeset
595 }
a61af66fc99e Initial load
duke
parents:
diff changeset
596 }
a61af66fc99e Initial load
duke
parents:
diff changeset
597 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
598
a61af66fc99e Initial load
duke
parents:
diff changeset
599 // JOIN NOT DONE HERE BECAUSE OF INTERFACE ISSUES.
a61af66fc99e Initial load
duke
parents:
diff changeset
600 // FIX THIS (DO THE JOIN) WHEN UNION TYPES APPEAR!
a61af66fc99e Initial load
duke
parents:
diff changeset
601
a61af66fc99e Initial load
duke
parents:
diff changeset
602 //
a61af66fc99e Initial load
duke
parents:
diff changeset
603 // Remove this code after overnight run indicates no performance
a61af66fc99e Initial load
duke
parents:
diff changeset
604 // loss from not performing JOIN at CheckCastPPNode
a61af66fc99e Initial load
duke
parents:
diff changeset
605 //
a61af66fc99e Initial load
duke
parents:
diff changeset
606 // const TypeInstPtr *in_oop = in->isa_instptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
607 // const TypeInstPtr *my_oop = _type->isa_instptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
608 // // If either input is an 'interface', return destination type
a61af66fc99e Initial load
duke
parents:
diff changeset
609 // assert (in_oop == NULL || in_oop->klass() != NULL, "");
a61af66fc99e Initial load
duke
parents:
diff changeset
610 // assert (my_oop == NULL || my_oop->klass() != NULL, "");
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5901
diff changeset
611 // if( (in_oop && in_oop->klass()->is_interface())
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5901
diff changeset
612 // ||(my_oop && my_oop->klass()->is_interface()) ) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
613 // TypePtr::PTR in_ptr = in->isa_ptr() ? in->is_ptr()->_ptr : TypePtr::BotPTR;
a61af66fc99e Initial load
duke
parents:
diff changeset
614 // // Preserve cast away nullness for interfaces
a61af66fc99e Initial load
duke
parents:
diff changeset
615 // if( in_ptr == TypePtr::NotNull && my_oop && my_oop->_ptr == TypePtr::BotPTR ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
616 // return my_oop->cast_to_ptr_type(TypePtr::NotNull);
a61af66fc99e Initial load
duke
parents:
diff changeset
617 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
618 // return _type;
a61af66fc99e Initial load
duke
parents:
diff changeset
619 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
620 //
a61af66fc99e Initial load
duke
parents:
diff changeset
621 // // Neither the input nor the destination type is an interface,
a61af66fc99e Initial load
duke
parents:
diff changeset
622 //
a61af66fc99e Initial load
duke
parents:
diff changeset
623 // // history: JOIN used to cause weird corner case bugs
a61af66fc99e Initial load
duke
parents:
diff changeset
624 // // return (in == TypeOopPtr::NULL_PTR) ? in : _type;
a61af66fc99e Initial load
duke
parents:
diff changeset
625 // // JOIN picks up NotNull in common instance-of/check-cast idioms, both oops.
a61af66fc99e Initial load
duke
parents:
diff changeset
626 // // JOIN does not preserve NotNull in other cases, e.g. RawPtr vs InstPtr
a61af66fc99e Initial load
duke
parents:
diff changeset
627 // const Type *join = in->join(_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
628 // // Check if join preserved NotNull'ness for pointers
a61af66fc99e Initial load
duke
parents:
diff changeset
629 // if( join->isa_ptr() && _type->isa_ptr() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
630 // TypePtr::PTR join_ptr = join->is_ptr()->_ptr;
a61af66fc99e Initial load
duke
parents:
diff changeset
631 // TypePtr::PTR type_ptr = _type->is_ptr()->_ptr;
a61af66fc99e Initial load
duke
parents:
diff changeset
632 // // If there isn't any NotNull'ness to preserve
a61af66fc99e Initial load
duke
parents:
diff changeset
633 // // OR if join preserved NotNull'ness then return it
a61af66fc99e Initial load
duke
parents:
diff changeset
634 // if( type_ptr == TypePtr::BotPTR || type_ptr == TypePtr::Null ||
a61af66fc99e Initial load
duke
parents:
diff changeset
635 // join_ptr == TypePtr::NotNull || join_ptr == TypePtr::Constant ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
636 // return join;
a61af66fc99e Initial load
duke
parents:
diff changeset
637 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
638 // // ELSE return same old type as before
a61af66fc99e Initial load
duke
parents:
diff changeset
639 // return _type;
a61af66fc99e Initial load
duke
parents:
diff changeset
640 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
641 // // Not joining two pointers
a61af66fc99e Initial load
duke
parents:
diff changeset
642 // return join;
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 // Return a node which is more "ideal" than the current node. Strip out
a61af66fc99e Initial load
duke
parents:
diff changeset
647 // control copies
a61af66fc99e Initial load
duke
parents:
diff changeset
648 Node *CheckCastPPNode::Ideal(PhaseGVN *phase, bool can_reshape){
a61af66fc99e Initial load
duke
parents:
diff changeset
649 return (in(0) && remove_dead_region(phase, can_reshape)) ? this : NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
650 }
a61af66fc99e Initial load
duke
parents:
diff changeset
651
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 36
diff changeset
652
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 36
diff changeset
653 Node* DecodeNNode::Identity(PhaseTransform* phase) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 36
diff changeset
654 const Type *t = phase->type( in(1) );
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 36
diff changeset
655 if( t == Type::TOP ) return in(1);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 36
diff changeset
656
168
7793bd37a336 6705887: Compressed Oops: generate x64 addressing and implicit null checks with narrow oops
kvn
parents: 164
diff changeset
657 if (in(1)->is_EncodeP()) {
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 36
diff changeset
658 // (DecodeN (EncodeP p)) -> p
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 36
diff changeset
659 return in(1)->in(1);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 36
diff changeset
660 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 36
diff changeset
661 return this;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 36
diff changeset
662 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 36
diff changeset
663
124
b130b98db9cf 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 113
diff changeset
664 const Type *DecodeNNode::Value( PhaseTransform *phase ) const {
216
8d191a7697e2 6715633: when matching a memory node the adr_type should not change
kvn
parents: 168
diff changeset
665 const Type *t = phase->type( in(1) );
8d191a7697e2 6715633: when matching a memory node the adr_type should not change
kvn
parents: 168
diff changeset
666 if (t == Type::TOP) return Type::TOP;
8d191a7697e2 6715633: when matching a memory node the adr_type should not change
kvn
parents: 168
diff changeset
667 if (t == TypeNarrowOop::NULL_PTR) return TypePtr::NULL_PTR;
8d191a7697e2 6715633: when matching a memory node the adr_type should not change
kvn
parents: 168
diff changeset
668
8d191a7697e2 6715633: when matching a memory node the adr_type should not change
kvn
parents: 168
diff changeset
669 assert(t->isa_narrowoop(), "only narrowoop here");
221
1e026f8da827 6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents: 216
diff changeset
670 return t->make_ptr();
124
b130b98db9cf 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 113
diff changeset
671 }
b130b98db9cf 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 113
diff changeset
672
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 36
diff changeset
673 Node* EncodePNode::Identity(PhaseTransform* phase) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 36
diff changeset
674 const Type *t = phase->type( in(1) );
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 36
diff changeset
675 if( t == Type::TOP ) return in(1);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 36
diff changeset
676
168
7793bd37a336 6705887: Compressed Oops: generate x64 addressing and implicit null checks with narrow oops
kvn
parents: 164
diff changeset
677 if (in(1)->is_DecodeN()) {
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 36
diff changeset
678 // (EncodeP (DecodeN p)) -> p
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 36
diff changeset
679 return in(1)->in(1);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 36
diff changeset
680 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 36
diff changeset
681 return this;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 36
diff changeset
682 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 36
diff changeset
683
124
b130b98db9cf 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 113
diff changeset
684 const Type *EncodePNode::Value( PhaseTransform *phase ) const {
216
8d191a7697e2 6715633: when matching a memory node the adr_type should not change
kvn
parents: 168
diff changeset
685 const Type *t = phase->type( in(1) );
8d191a7697e2 6715633: when matching a memory node the adr_type should not change
kvn
parents: 168
diff changeset
686 if (t == Type::TOP) return Type::TOP;
8d191a7697e2 6715633: when matching a memory node the adr_type should not change
kvn
parents: 168
diff changeset
687 if (t == TypePtr::NULL_PTR) return TypeNarrowOop::NULL_PTR;
8d191a7697e2 6715633: when matching a memory node the adr_type should not change
kvn
parents: 168
diff changeset
688
6848
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
689 assert(t->isa_oop_ptr(), "only oopptr here");
221
1e026f8da827 6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents: 216
diff changeset
690 return t->make_narrowoop();
124
b130b98db9cf 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 113
diff changeset
691 }
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 36
diff changeset
692
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 36
diff changeset
693
6848
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
694 Node *EncodeNarrowPtrNode::Ideal_DU_postCCP( PhaseCCP *ccp ) {
163
885ed790ecf0 6695810: null oop passed to encode_heap_oop_not_null
kvn
parents: 124
diff changeset
695 return MemNode::Ideal_common_DU_postCCP(ccp, this, in(1));
885ed790ecf0 6695810: null oop passed to encode_heap_oop_not_null
kvn
parents: 124
diff changeset
696 }
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 36
diff changeset
697
6848
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
698 Node* DecodeNKlassNode::Identity(PhaseTransform* phase) {
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
699 const Type *t = phase->type( in(1) );
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
700 if( t == Type::TOP ) return in(1);
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
701
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
702 if (in(1)->is_EncodePKlass()) {
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
703 // (DecodeNKlass (EncodePKlass p)) -> p
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
704 return in(1)->in(1);
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
705 }
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
706 return this;
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
707 }
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
708
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
709 const Type *DecodeNKlassNode::Value( PhaseTransform *phase ) const {
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
710 const Type *t = phase->type( in(1) );
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
711 if (t == Type::TOP) return Type::TOP;
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
712 assert(t != TypeNarrowKlass::NULL_PTR, "null klass?");
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
713
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
714 assert(t->isa_narrowklass(), "only narrow klass ptr here");
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
715 return t->make_ptr();
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
716 }
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
717
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
718 Node* EncodePKlassNode::Identity(PhaseTransform* phase) {
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
719 const Type *t = phase->type( in(1) );
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
720 if( t == Type::TOP ) return in(1);
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
721
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
722 if (in(1)->is_DecodeNKlass()) {
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
723 // (EncodePKlass (DecodeNKlass p)) -> p
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
724 return in(1)->in(1);
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
725 }
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
726 return this;
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
727 }
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
728
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
729 const Type *EncodePKlassNode::Value( PhaseTransform *phase ) const {
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
730 const Type *t = phase->type( in(1) );
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
731 if (t == Type::TOP) return Type::TOP;
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
732 assert (t != TypePtr::NULL_PTR, "null klass?");
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
733
12226
7944aba7ba41 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 9060
diff changeset
734 assert(UseCompressedClassPointers && t->isa_klassptr(), "only klass ptr here");
6848
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
735 return t->make_narrowklass();
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
736 }
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
737
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6804
diff changeset
738
0
a61af66fc99e Initial load
duke
parents:
diff changeset
739 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
740 //------------------------------Identity---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
741 Node *Conv2BNode::Identity( PhaseTransform *phase ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
742 const Type *t = phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
743 if( t == Type::TOP ) return in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
744 if( t == TypeInt::ZERO ) return in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
745 if( t == TypeInt::ONE ) return in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
746 if( t == TypeInt::BOOL ) return in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
747 return this;
a61af66fc99e Initial load
duke
parents:
diff changeset
748 }
a61af66fc99e Initial load
duke
parents:
diff changeset
749
a61af66fc99e Initial load
duke
parents:
diff changeset
750 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
751 const Type *Conv2BNode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
752 const Type *t = phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
753 if( t == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
754 if( t == TypeInt::ZERO ) return TypeInt::ZERO;
a61af66fc99e Initial load
duke
parents:
diff changeset
755 if( t == TypePtr::NULL_PTR ) return TypeInt::ZERO;
a61af66fc99e Initial load
duke
parents:
diff changeset
756 const TypePtr *tp = t->isa_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
757 if( tp != NULL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
758 if( tp->ptr() == TypePtr::AnyNull ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
759 if( tp->ptr() == TypePtr::Constant) return TypeInt::ONE;
a61af66fc99e Initial load
duke
parents:
diff changeset
760 if (tp->ptr() == TypePtr::NotNull) return TypeInt::ONE;
a61af66fc99e Initial load
duke
parents:
diff changeset
761 return TypeInt::BOOL;
a61af66fc99e Initial load
duke
parents:
diff changeset
762 }
a61af66fc99e Initial load
duke
parents:
diff changeset
763 if (t->base() != Type::Int) return TypeInt::BOOL;
a61af66fc99e Initial load
duke
parents:
diff changeset
764 const TypeInt *ti = t->is_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
765 if( ti->_hi < 0 || ti->_lo > 0 ) return TypeInt::ONE;
a61af66fc99e Initial load
duke
parents:
diff changeset
766 return TypeInt::BOOL;
a61af66fc99e Initial load
duke
parents:
diff changeset
767 }
a61af66fc99e Initial load
duke
parents:
diff changeset
768
a61af66fc99e Initial load
duke
parents:
diff changeset
769
a61af66fc99e Initial load
duke
parents:
diff changeset
770 // The conversions operations are all Alpha sorted. Please keep it that way!
a61af66fc99e Initial load
duke
parents:
diff changeset
771 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
772 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
773 const Type *ConvD2FNode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
774 const Type *t = phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
775 if( t == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
776 if( t == Type::DOUBLE ) return Type::FLOAT;
a61af66fc99e Initial load
duke
parents:
diff changeset
777 const TypeD *td = t->is_double_constant();
a61af66fc99e Initial load
duke
parents:
diff changeset
778 return TypeF::make( (float)td->getd() );
a61af66fc99e Initial load
duke
parents:
diff changeset
779 }
a61af66fc99e Initial load
duke
parents:
diff changeset
780
a61af66fc99e Initial load
duke
parents:
diff changeset
781 //------------------------------Identity---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
782 // Float's can be converted to doubles with no loss of bits. Hence
a61af66fc99e Initial load
duke
parents:
diff changeset
783 // converting a float to a double and back to a float is a NOP.
a61af66fc99e Initial load
duke
parents:
diff changeset
784 Node *ConvD2FNode::Identity(PhaseTransform *phase) {
a61af66fc99e Initial load
duke
parents:
diff changeset
785 return (in(1)->Opcode() == Op_ConvF2D) ? in(1)->in(1) : this;
a61af66fc99e Initial load
duke
parents:
diff changeset
786 }
a61af66fc99e Initial load
duke
parents:
diff changeset
787
a61af66fc99e Initial load
duke
parents:
diff changeset
788 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
789 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
790 const Type *ConvD2INode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
791 const Type *t = phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
792 if( t == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
793 if( t == Type::DOUBLE ) return TypeInt::INT;
a61af66fc99e Initial load
duke
parents:
diff changeset
794 const TypeD *td = t->is_double_constant();
a61af66fc99e Initial load
duke
parents:
diff changeset
795 return TypeInt::make( SharedRuntime::d2i( td->getd() ) );
a61af66fc99e Initial load
duke
parents:
diff changeset
796 }
a61af66fc99e Initial load
duke
parents:
diff changeset
797
a61af66fc99e Initial load
duke
parents:
diff changeset
798 //------------------------------Ideal------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
799 // If converting to an int type, skip any rounding nodes
a61af66fc99e Initial load
duke
parents:
diff changeset
800 Node *ConvD2INode::Ideal(PhaseGVN *phase, bool can_reshape) {
a61af66fc99e Initial load
duke
parents:
diff changeset
801 if( in(1)->Opcode() == Op_RoundDouble )
a61af66fc99e Initial load
duke
parents:
diff changeset
802 set_req(1,in(1)->in(1));
a61af66fc99e Initial load
duke
parents:
diff changeset
803 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
804 }
a61af66fc99e Initial load
duke
parents:
diff changeset
805
a61af66fc99e Initial load
duke
parents:
diff changeset
806 //------------------------------Identity---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
807 // Int's can be converted to doubles with no loss of bits. Hence
a61af66fc99e Initial load
duke
parents:
diff changeset
808 // converting an integer to a double and back to an integer is a NOP.
a61af66fc99e Initial load
duke
parents:
diff changeset
809 Node *ConvD2INode::Identity(PhaseTransform *phase) {
a61af66fc99e Initial load
duke
parents:
diff changeset
810 return (in(1)->Opcode() == Op_ConvI2D) ? in(1)->in(1) : this;
a61af66fc99e Initial load
duke
parents:
diff changeset
811 }
a61af66fc99e Initial load
duke
parents:
diff changeset
812
a61af66fc99e Initial load
duke
parents:
diff changeset
813 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
814 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
815 const Type *ConvD2LNode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
816 const Type *t = phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
817 if( t == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
818 if( t == Type::DOUBLE ) return TypeLong::LONG;
a61af66fc99e Initial load
duke
parents:
diff changeset
819 const TypeD *td = t->is_double_constant();
a61af66fc99e Initial load
duke
parents:
diff changeset
820 return TypeLong::make( SharedRuntime::d2l( td->getd() ) );
a61af66fc99e Initial load
duke
parents:
diff changeset
821 }
a61af66fc99e Initial load
duke
parents:
diff changeset
822
a61af66fc99e Initial load
duke
parents:
diff changeset
823 //------------------------------Identity---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
824 Node *ConvD2LNode::Identity(PhaseTransform *phase) {
a61af66fc99e Initial load
duke
parents:
diff changeset
825 // Remove ConvD2L->ConvL2D->ConvD2L sequences.
a61af66fc99e Initial load
duke
parents:
diff changeset
826 if( in(1) ->Opcode() == Op_ConvL2D &&
a61af66fc99e Initial load
duke
parents:
diff changeset
827 in(1)->in(1)->Opcode() == Op_ConvD2L )
a61af66fc99e Initial load
duke
parents:
diff changeset
828 return in(1)->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
829 return this;
a61af66fc99e Initial load
duke
parents:
diff changeset
830 }
a61af66fc99e Initial load
duke
parents:
diff changeset
831
a61af66fc99e Initial load
duke
parents:
diff changeset
832 //------------------------------Ideal------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
833 // If converting to an int type, skip any rounding nodes
a61af66fc99e Initial load
duke
parents:
diff changeset
834 Node *ConvD2LNode::Ideal(PhaseGVN *phase, bool can_reshape) {
a61af66fc99e Initial load
duke
parents:
diff changeset
835 if( in(1)->Opcode() == Op_RoundDouble )
a61af66fc99e Initial load
duke
parents:
diff changeset
836 set_req(1,in(1)->in(1));
a61af66fc99e Initial load
duke
parents:
diff changeset
837 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
838 }
a61af66fc99e Initial load
duke
parents:
diff changeset
839
a61af66fc99e Initial load
duke
parents:
diff changeset
840 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
841 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
842 const Type *ConvF2DNode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
843 const Type *t = phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
844 if( t == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
845 if( t == Type::FLOAT ) return Type::DOUBLE;
a61af66fc99e Initial load
duke
parents:
diff changeset
846 const TypeF *tf = t->is_float_constant();
a61af66fc99e Initial load
duke
parents:
diff changeset
847 return TypeD::make( (double)tf->getf() );
a61af66fc99e Initial load
duke
parents:
diff changeset
848 }
a61af66fc99e Initial load
duke
parents:
diff changeset
849
a61af66fc99e Initial load
duke
parents:
diff changeset
850 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
851 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
852 const Type *ConvF2INode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
853 const Type *t = phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
854 if( t == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
855 if( t == Type::FLOAT ) return TypeInt::INT;
a61af66fc99e Initial load
duke
parents:
diff changeset
856 const TypeF *tf = t->is_float_constant();
a61af66fc99e Initial load
duke
parents:
diff changeset
857 return TypeInt::make( SharedRuntime::f2i( tf->getf() ) );
a61af66fc99e Initial load
duke
parents:
diff changeset
858 }
a61af66fc99e Initial load
duke
parents:
diff changeset
859
a61af66fc99e Initial load
duke
parents:
diff changeset
860 //------------------------------Identity---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
861 Node *ConvF2INode::Identity(PhaseTransform *phase) {
a61af66fc99e Initial load
duke
parents:
diff changeset
862 // Remove ConvF2I->ConvI2F->ConvF2I sequences.
a61af66fc99e Initial load
duke
parents:
diff changeset
863 if( in(1) ->Opcode() == Op_ConvI2F &&
a61af66fc99e Initial load
duke
parents:
diff changeset
864 in(1)->in(1)->Opcode() == Op_ConvF2I )
a61af66fc99e Initial load
duke
parents:
diff changeset
865 return in(1)->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
866 return this;
a61af66fc99e Initial load
duke
parents:
diff changeset
867 }
a61af66fc99e Initial load
duke
parents:
diff changeset
868
a61af66fc99e Initial load
duke
parents:
diff changeset
869 //------------------------------Ideal------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
870 // If converting to an int type, skip any rounding nodes
a61af66fc99e Initial load
duke
parents:
diff changeset
871 Node *ConvF2INode::Ideal(PhaseGVN *phase, bool can_reshape) {
a61af66fc99e Initial load
duke
parents:
diff changeset
872 if( in(1)->Opcode() == Op_RoundFloat )
a61af66fc99e Initial load
duke
parents:
diff changeset
873 set_req(1,in(1)->in(1));
a61af66fc99e Initial load
duke
parents:
diff changeset
874 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
875 }
a61af66fc99e Initial load
duke
parents:
diff changeset
876
a61af66fc99e Initial load
duke
parents:
diff changeset
877 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
878 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
879 const Type *ConvF2LNode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
880 const Type *t = phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
881 if( t == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
882 if( t == Type::FLOAT ) return TypeLong::LONG;
a61af66fc99e Initial load
duke
parents:
diff changeset
883 const TypeF *tf = t->is_float_constant();
a61af66fc99e Initial load
duke
parents:
diff changeset
884 return TypeLong::make( SharedRuntime::f2l( tf->getf() ) );
a61af66fc99e Initial load
duke
parents:
diff changeset
885 }
a61af66fc99e Initial load
duke
parents:
diff changeset
886
a61af66fc99e Initial load
duke
parents:
diff changeset
887 //------------------------------Identity---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
888 Node *ConvF2LNode::Identity(PhaseTransform *phase) {
a61af66fc99e Initial load
duke
parents:
diff changeset
889 // Remove ConvF2L->ConvL2F->ConvF2L sequences.
a61af66fc99e Initial load
duke
parents:
diff changeset
890 if( in(1) ->Opcode() == Op_ConvL2F &&
a61af66fc99e Initial load
duke
parents:
diff changeset
891 in(1)->in(1)->Opcode() == Op_ConvF2L )
a61af66fc99e Initial load
duke
parents:
diff changeset
892 return in(1)->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
893 return this;
a61af66fc99e Initial load
duke
parents:
diff changeset
894 }
a61af66fc99e Initial load
duke
parents:
diff changeset
895
a61af66fc99e Initial load
duke
parents:
diff changeset
896 //------------------------------Ideal------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
897 // If converting to an int type, skip any rounding nodes
a61af66fc99e Initial load
duke
parents:
diff changeset
898 Node *ConvF2LNode::Ideal(PhaseGVN *phase, bool can_reshape) {
a61af66fc99e Initial load
duke
parents:
diff changeset
899 if( in(1)->Opcode() == Op_RoundFloat )
a61af66fc99e Initial load
duke
parents:
diff changeset
900 set_req(1,in(1)->in(1));
a61af66fc99e Initial load
duke
parents:
diff changeset
901 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
902 }
a61af66fc99e Initial load
duke
parents:
diff changeset
903
a61af66fc99e Initial load
duke
parents:
diff changeset
904 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
905 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
906 const Type *ConvI2DNode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
907 const Type *t = phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
908 if( t == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
909 const TypeInt *ti = t->is_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
910 if( ti->is_con() ) return TypeD::make( (double)ti->get_con() );
a61af66fc99e Initial load
duke
parents:
diff changeset
911 return bottom_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
912 }
a61af66fc99e Initial load
duke
parents:
diff changeset
913
a61af66fc99e Initial load
duke
parents:
diff changeset
914 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
915 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
916 const Type *ConvI2FNode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
917 const Type *t = phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
918 if( t == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
919 const TypeInt *ti = t->is_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
920 if( ti->is_con() ) return TypeF::make( (float)ti->get_con() );
a61af66fc99e Initial load
duke
parents:
diff changeset
921 return bottom_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
922 }
a61af66fc99e Initial load
duke
parents:
diff changeset
923
a61af66fc99e Initial load
duke
parents:
diff changeset
924 //------------------------------Identity---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
925 Node *ConvI2FNode::Identity(PhaseTransform *phase) {
a61af66fc99e Initial load
duke
parents:
diff changeset
926 // Remove ConvI2F->ConvF2I->ConvI2F sequences.
a61af66fc99e Initial load
duke
parents:
diff changeset
927 if( in(1) ->Opcode() == Op_ConvF2I &&
a61af66fc99e Initial load
duke
parents:
diff changeset
928 in(1)->in(1)->Opcode() == Op_ConvI2F )
a61af66fc99e Initial load
duke
parents:
diff changeset
929 return in(1)->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
930 return this;
a61af66fc99e Initial load
duke
parents:
diff changeset
931 }
a61af66fc99e Initial load
duke
parents:
diff changeset
932
a61af66fc99e Initial load
duke
parents:
diff changeset
933 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
934 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
935 const Type *ConvI2LNode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
936 const Type *t = phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
937 if( t == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
938 const TypeInt *ti = t->is_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
939 const Type* tl = TypeLong::make(ti->_lo, ti->_hi, ti->_widen);
a61af66fc99e Initial load
duke
parents:
diff changeset
940 // Join my declared type against my incoming type.
a61af66fc99e Initial load
duke
parents:
diff changeset
941 tl = tl->filter(_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
942 return tl;
a61af66fc99e Initial load
duke
parents:
diff changeset
943 }
a61af66fc99e Initial load
duke
parents:
diff changeset
944
a61af66fc99e Initial load
duke
parents:
diff changeset
945 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
946 static inline bool long_ranges_overlap(jlong lo1, jlong hi1,
a61af66fc99e Initial load
duke
parents:
diff changeset
947 jlong lo2, jlong hi2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
948 // Two ranges overlap iff one range's low point falls in the other range.
a61af66fc99e Initial load
duke
parents:
diff changeset
949 return (lo2 <= lo1 && lo1 <= hi2) || (lo1 <= lo2 && lo2 <= hi1);
a61af66fc99e Initial load
duke
parents:
diff changeset
950 }
a61af66fc99e Initial load
duke
parents:
diff changeset
951 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
952
a61af66fc99e Initial load
duke
parents:
diff changeset
953 //------------------------------Ideal------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
954 Node *ConvI2LNode::Ideal(PhaseGVN *phase, bool can_reshape) {
a61af66fc99e Initial load
duke
parents:
diff changeset
955 const TypeLong* this_type = this->type()->is_long();
a61af66fc99e Initial load
duke
parents:
diff changeset
956 Node* this_changed = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
957
a61af66fc99e Initial load
duke
parents:
diff changeset
958 // If _major_progress, then more loop optimizations follow. Do NOT
a61af66fc99e Initial load
duke
parents:
diff changeset
959 // remove this node's type assertion until no more loop ops can happen.
a61af66fc99e Initial load
duke
parents:
diff changeset
960 // The progress bit is set in the major loop optimizations THEN comes the
a61af66fc99e Initial load
duke
parents:
diff changeset
961 // call to IterGVN and any chance of hitting this code. Cf. Opaque1Node.
a61af66fc99e Initial load
duke
parents:
diff changeset
962 if (can_reshape && !phase->C->major_progress()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
963 const TypeInt* in_type = phase->type(in(1))->isa_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
964 if (in_type != NULL && this_type != NULL &&
a61af66fc99e Initial load
duke
parents:
diff changeset
965 (in_type->_lo != this_type->_lo ||
a61af66fc99e Initial load
duke
parents:
diff changeset
966 in_type->_hi != this_type->_hi)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
967 // Although this WORSENS the type, it increases GVN opportunities,
a61af66fc99e Initial load
duke
parents:
diff changeset
968 // because I2L nodes with the same input will common up, regardless
a61af66fc99e Initial load
duke
parents:
diff changeset
969 // of slightly differing type assertions. Such slight differences
a61af66fc99e Initial load
duke
parents:
diff changeset
970 // arise routinely as a result of loop unrolling, so this is a
a61af66fc99e Initial load
duke
parents:
diff changeset
971 // post-unrolling graph cleanup. Choose a type which depends only
a61af66fc99e Initial load
duke
parents:
diff changeset
972 // on my input. (Exception: Keep a range assertion of >=0 or <0.)
a61af66fc99e Initial load
duke
parents:
diff changeset
973 jlong lo1 = this_type->_lo;
a61af66fc99e Initial load
duke
parents:
diff changeset
974 jlong hi1 = this_type->_hi;
a61af66fc99e Initial load
duke
parents:
diff changeset
975 int w1 = this_type->_widen;
a61af66fc99e Initial load
duke
parents:
diff changeset
976 if (lo1 != (jint)lo1 ||
a61af66fc99e Initial load
duke
parents:
diff changeset
977 hi1 != (jint)hi1 ||
a61af66fc99e Initial load
duke
parents:
diff changeset
978 lo1 > hi1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
979 // Overflow leads to wraparound, wraparound leads to range saturation.
a61af66fc99e Initial load
duke
parents:
diff changeset
980 lo1 = min_jint; hi1 = max_jint;
a61af66fc99e Initial load
duke
parents:
diff changeset
981 } else if (lo1 >= 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
982 // Keep a range assertion of >=0.
a61af66fc99e Initial load
duke
parents:
diff changeset
983 lo1 = 0; hi1 = max_jint;
a61af66fc99e Initial load
duke
parents:
diff changeset
984 } else if (hi1 < 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
985 // Keep a range assertion of <0.
a61af66fc99e Initial load
duke
parents:
diff changeset
986 lo1 = min_jint; hi1 = -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
987 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
988 lo1 = min_jint; hi1 = max_jint;
a61af66fc99e Initial load
duke
parents:
diff changeset
989 }
a61af66fc99e Initial load
duke
parents:
diff changeset
990 const TypeLong* wtype = TypeLong::make(MAX2((jlong)in_type->_lo, lo1),
a61af66fc99e Initial load
duke
parents:
diff changeset
991 MIN2((jlong)in_type->_hi, hi1),
a61af66fc99e Initial load
duke
parents:
diff changeset
992 MAX2((int)in_type->_widen, w1));
a61af66fc99e Initial load
duke
parents:
diff changeset
993 if (wtype != type()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
994 set_type(wtype);
a61af66fc99e Initial load
duke
parents:
diff changeset
995 // Note: this_type still has old type value, for the logic below.
a61af66fc99e Initial load
duke
parents:
diff changeset
996 this_changed = this;
a61af66fc99e Initial load
duke
parents:
diff changeset
997 }
a61af66fc99e Initial load
duke
parents:
diff changeset
998 }
a61af66fc99e Initial load
duke
parents:
diff changeset
999 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1000
a61af66fc99e Initial load
duke
parents:
diff changeset
1001 #ifdef _LP64
23799
535618ab1c04 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 22985
diff changeset
1002 // Convert ConvI2L(AddI(x, y)) to AddL(ConvI2L(x), ConvI2L(y)) or
535618ab1c04 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 22985
diff changeset
1003 // ConvI2L(CastII(AddI(x, y))) to AddL(ConvI2L(CastII(x)), ConvI2L(CastII(y))),
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1004 // but only if x and y have subranges that cannot cause 32-bit overflow,
a61af66fc99e Initial load
duke
parents:
diff changeset
1005 // under the assumption that x+y is in my own subrange this->type().
a61af66fc99e Initial load
duke
parents:
diff changeset
1006
a61af66fc99e Initial load
duke
parents:
diff changeset
1007 // This assumption is based on a constraint (i.e., type assertion)
a61af66fc99e Initial load
duke
parents:
diff changeset
1008 // established in Parse::array_addressing or perhaps elsewhere.
a61af66fc99e Initial load
duke
parents:
diff changeset
1009 // This constraint has been adjoined to the "natural" type of
a61af66fc99e Initial load
duke
parents:
diff changeset
1010 // the incoming argument in(0). We know (because of runtime
a61af66fc99e Initial load
duke
parents:
diff changeset
1011 // checks) - that the result value I2L(x+y) is in the joined range.
a61af66fc99e Initial load
duke
parents:
diff changeset
1012 // Hence we can restrict the incoming terms (x, y) to values such
a61af66fc99e Initial load
duke
parents:
diff changeset
1013 // that their sum also lands in that range.
a61af66fc99e Initial load
duke
parents:
diff changeset
1014
a61af66fc99e Initial load
duke
parents:
diff changeset
1015 // This optimization is useful only on 64-bit systems, where we hope
a61af66fc99e Initial load
duke
parents:
diff changeset
1016 // the addition will end up subsumed in an addressing mode.
a61af66fc99e Initial load
duke
parents:
diff changeset
1017 // It is necessary to do this when optimizing an unrolled array
a61af66fc99e Initial load
duke
parents:
diff changeset
1018 // copy loop such as x[i++] = y[i++].
a61af66fc99e Initial load
duke
parents:
diff changeset
1019
a61af66fc99e Initial load
duke
parents:
diff changeset
1020 // On 32-bit systems, it's better to perform as much 32-bit math as
a61af66fc99e Initial load
duke
parents:
diff changeset
1021 // possible before the I2L conversion, because 32-bit math is cheaper.
a61af66fc99e Initial load
duke
parents:
diff changeset
1022 // There's no common reason to "leak" a constant offset through the I2L.
a61af66fc99e Initial load
duke
parents:
diff changeset
1023 // Addressing arithmetic will not absorb it as part of a 64-bit AddL.
a61af66fc99e Initial load
duke
parents:
diff changeset
1024
a61af66fc99e Initial load
duke
parents:
diff changeset
1025 Node* z = in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1026 int op = z->Opcode();
23799
535618ab1c04 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 22985
diff changeset
1027 Node* ctrl = NULL;
535618ab1c04 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 22985
diff changeset
1028 if (op == Op_CastII && z->as_CastII()->has_range_check()) {
535618ab1c04 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 22985
diff changeset
1029 // Skip CastII node but save control dependency
535618ab1c04 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 22985
diff changeset
1030 ctrl = z->in(0);
535618ab1c04 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 22985
diff changeset
1031 z = z->in(1);
535618ab1c04 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 22985
diff changeset
1032 op = z->Opcode();
535618ab1c04 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 22985
diff changeset
1033 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1034 if (op == Op_AddI || op == Op_SubI) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1035 Node* x = z->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1036 Node* y = z->in(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1037 assert (x != z && y != z, "dead loop in ConvI2LNode::Ideal");
a61af66fc99e Initial load
duke
parents:
diff changeset
1038 if (phase->type(x) == Type::TOP) return this_changed;
a61af66fc99e Initial load
duke
parents:
diff changeset
1039 if (phase->type(y) == Type::TOP) return this_changed;
a61af66fc99e Initial load
duke
parents:
diff changeset
1040 const TypeInt* tx = phase->type(x)->is_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
1041 const TypeInt* ty = phase->type(y)->is_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
1042 const TypeLong* tz = this_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
1043 jlong xlo = tx->_lo;
a61af66fc99e Initial load
duke
parents:
diff changeset
1044 jlong xhi = tx->_hi;
a61af66fc99e Initial load
duke
parents:
diff changeset
1045 jlong ylo = ty->_lo;
a61af66fc99e Initial load
duke
parents:
diff changeset
1046 jlong yhi = ty->_hi;
a61af66fc99e Initial load
duke
parents:
diff changeset
1047 jlong zlo = tz->_lo;
a61af66fc99e Initial load
duke
parents:
diff changeset
1048 jlong zhi = tz->_hi;
a61af66fc99e Initial load
duke
parents:
diff changeset
1049 jlong vbit = CONST64(1) << BitsPerInt;
a61af66fc99e Initial load
duke
parents:
diff changeset
1050 int widen = MAX2(tx->_widen, ty->_widen);
a61af66fc99e Initial load
duke
parents:
diff changeset
1051 if (op == Op_SubI) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1052 jlong ylo0 = ylo;
a61af66fc99e Initial load
duke
parents:
diff changeset
1053 ylo = -yhi;
a61af66fc99e Initial load
duke
parents:
diff changeset
1054 yhi = -ylo0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1055 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1056 // See if x+y can cause positive overflow into z+2**32
a61af66fc99e Initial load
duke
parents:
diff changeset
1057 if (long_ranges_overlap(xlo+ylo, xhi+yhi, zlo+vbit, zhi+vbit)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1058 return this_changed;
a61af66fc99e Initial load
duke
parents:
diff changeset
1059 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1060 // See if x+y can cause negative overflow into z-2**32
a61af66fc99e Initial load
duke
parents:
diff changeset
1061 if (long_ranges_overlap(xlo+ylo, xhi+yhi, zlo-vbit, zhi-vbit)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1062 return this_changed;
a61af66fc99e Initial load
duke
parents:
diff changeset
1063 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1064 // Now it's always safe to assume x+y does not overflow.
a61af66fc99e Initial load
duke
parents:
diff changeset
1065 // This is true even if some pairs x,y might cause overflow, as long
a61af66fc99e Initial load
duke
parents:
diff changeset
1066 // as that overflow value cannot fall into [zlo,zhi].
a61af66fc99e Initial load
duke
parents:
diff changeset
1067
a61af66fc99e Initial load
duke
parents:
diff changeset
1068 // Confident that the arithmetic is "as if infinite precision",
a61af66fc99e Initial load
duke
parents:
diff changeset
1069 // we can now use z's range to put constraints on those of x and y.
a61af66fc99e Initial load
duke
parents:
diff changeset
1070 // The "natural" range of x [xlo,xhi] can perhaps be narrowed to a
a61af66fc99e Initial load
duke
parents:
diff changeset
1071 // more "restricted" range by intersecting [xlo,xhi] with the
a61af66fc99e Initial load
duke
parents:
diff changeset
1072 // range obtained by subtracting y's range from the asserted range
a61af66fc99e Initial load
duke
parents:
diff changeset
1073 // of the I2L conversion. Here's the interval arithmetic algebra:
a61af66fc99e Initial load
duke
parents:
diff changeset
1074 // x == z-y == [zlo,zhi]-[ylo,yhi] == [zlo,zhi]+[-yhi,-ylo]
a61af66fc99e Initial load
duke
parents:
diff changeset
1075 // => x in [zlo-yhi, zhi-ylo]
a61af66fc99e Initial load
duke
parents:
diff changeset
1076 // => x in [zlo-yhi, zhi-ylo] INTERSECT [xlo,xhi]
a61af66fc99e Initial load
duke
parents:
diff changeset
1077 // => x in [xlo MAX zlo-yhi, xhi MIN zhi-ylo]
a61af66fc99e Initial load
duke
parents:
diff changeset
1078 jlong rxlo = MAX2(xlo, zlo - yhi);
a61af66fc99e Initial load
duke
parents:
diff changeset
1079 jlong rxhi = MIN2(xhi, zhi - ylo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1080 // And similarly, x changing place with y:
a61af66fc99e Initial load
duke
parents:
diff changeset
1081 jlong rylo = MAX2(ylo, zlo - xhi);
a61af66fc99e Initial load
duke
parents:
diff changeset
1082 jlong ryhi = MIN2(yhi, zhi - xlo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1083 if (rxlo > rxhi || rylo > ryhi) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1084 return this_changed; // x or y is dying; don't mess w/ it
a61af66fc99e Initial load
duke
parents:
diff changeset
1085 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1086 if (op == Op_SubI) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1087 jlong rylo0 = rylo;
a61af66fc99e Initial load
duke
parents:
diff changeset
1088 rylo = -ryhi;
a61af66fc99e Initial load
duke
parents:
diff changeset
1089 ryhi = -rylo0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1090 }
23799
535618ab1c04 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 22985
diff changeset
1091 assert(rxlo == (int)rxlo && rxhi == (int)rxhi, "x should not overflow");
535618ab1c04 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 22985
diff changeset
1092 assert(rylo == (int)rylo && ryhi == (int)ryhi, "y should not overflow");
535618ab1c04 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 22985
diff changeset
1093 Node* cx = phase->C->constrained_convI2L(phase, x, TypeInt::make(rxlo, rxhi, widen), ctrl);
535618ab1c04 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 22985
diff changeset
1094 Node* cy = phase->C->constrained_convI2L(phase, y, TypeInt::make(rylo, ryhi, widen), ctrl);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1095 switch (op) {
6804
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6795
diff changeset
1096 case Op_AddI: return new (phase->C) AddLNode(cx, cy);
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6795
diff changeset
1097 case Op_SubI: return new (phase->C) SubLNode(cx, cy);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1098 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1099 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1100 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1101 #endif //_LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
1102
a61af66fc99e Initial load
duke
parents:
diff changeset
1103 return this_changed;
a61af66fc99e Initial load
duke
parents:
diff changeset
1104 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1105
a61af66fc99e Initial load
duke
parents:
diff changeset
1106 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
1107 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1108 const Type *ConvL2DNode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
1109 const Type *t = phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
1110 if( t == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
1111 const TypeLong *tl = t->is_long();
a61af66fc99e Initial load
duke
parents:
diff changeset
1112 if( tl->is_con() ) return TypeD::make( (double)tl->get_con() );
a61af66fc99e Initial load
duke
parents:
diff changeset
1113 return bottom_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
1114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1115
a61af66fc99e Initial load
duke
parents:
diff changeset
1116 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
1117 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1118 const Type *ConvL2FNode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
1119 const Type *t = phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
1120 if( t == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
1121 const TypeLong *tl = t->is_long();
a61af66fc99e Initial load
duke
parents:
diff changeset
1122 if( tl->is_con() ) return TypeF::make( (float)tl->get_con() );
a61af66fc99e Initial load
duke
parents:
diff changeset
1123 return bottom_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
1124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1125
a61af66fc99e Initial load
duke
parents:
diff changeset
1126 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
1127 //----------------------------Identity-----------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1128 Node *ConvL2INode::Identity( PhaseTransform *phase ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1129 // Convert L2I(I2L(x)) => x
a61af66fc99e Initial load
duke
parents:
diff changeset
1130 if (in(1)->Opcode() == Op_ConvI2L) return in(1)->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1131 return this;
a61af66fc99e Initial load
duke
parents:
diff changeset
1132 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1133
a61af66fc99e Initial load
duke
parents:
diff changeset
1134 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1135 const Type *ConvL2INode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
1136 const Type *t = phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
1137 if( t == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
1138 const TypeLong *tl = t->is_long();
a61af66fc99e Initial load
duke
parents:
diff changeset
1139 if (tl->is_con())
a61af66fc99e Initial load
duke
parents:
diff changeset
1140 // Easy case.
a61af66fc99e Initial load
duke
parents:
diff changeset
1141 return TypeInt::make((jint)tl->get_con());
a61af66fc99e Initial load
duke
parents:
diff changeset
1142 return bottom_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
1143 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1144
a61af66fc99e Initial load
duke
parents:
diff changeset
1145 //------------------------------Ideal------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1146 // Return a node which is more "ideal" than the current node.
a61af66fc99e Initial load
duke
parents:
diff changeset
1147 // Blow off prior masking to int
a61af66fc99e Initial load
duke
parents:
diff changeset
1148 Node *ConvL2INode::Ideal(PhaseGVN *phase, bool can_reshape) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1149 Node *andl = in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1150 uint andl_op = andl->Opcode();
a61af66fc99e Initial load
duke
parents:
diff changeset
1151 if( andl_op == Op_AndL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1152 // Blow off prior masking to int
a61af66fc99e Initial load
duke
parents:
diff changeset
1153 if( phase->type(andl->in(2)) == TypeLong::make( 0xFFFFFFFF ) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1154 set_req(1,andl->in(1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1155 return this;
a61af66fc99e Initial load
duke
parents:
diff changeset
1156 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1157 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1158
a61af66fc99e Initial load
duke
parents:
diff changeset
1159 // Swap with a prior add: convL2I(addL(x,y)) ==> addI(convL2I(x),convL2I(y))
a61af66fc99e Initial load
duke
parents:
diff changeset
1160 // This replaces an 'AddL' with an 'AddI'.
a61af66fc99e Initial load
duke
parents:
diff changeset
1161 if( andl_op == Op_AddL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1162 // Don't do this for nodes which have more than one user since
a61af66fc99e Initial load
duke
parents:
diff changeset
1163 // we'll end up computing the long add anyway.
a61af66fc99e Initial load
duke
parents:
diff changeset
1164 if (andl->outcnt() > 1) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1165
a61af66fc99e Initial load
duke
parents:
diff changeset
1166 Node* x = andl->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1167 Node* y = andl->in(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1168 assert( x != andl && y != andl, "dead loop in ConvL2INode::Ideal" );
a61af66fc99e Initial load
duke
parents:
diff changeset
1169 if (phase->type(x) == Type::TOP) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1170 if (phase->type(y) == Type::TOP) return NULL;
6804
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6795
diff changeset
1171 Node *add1 = phase->transform(new (phase->C) ConvL2INode(x));
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6795
diff changeset
1172 Node *add2 = phase->transform(new (phase->C) ConvL2INode(y));
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6795
diff changeset
1173 return new (phase->C) AddINode(add1,add2);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1174 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1175
36
f34d9da7acb2 6667618: disable LoadL->ConvL2I ==> LoadI optimization
kvn
parents: 0
diff changeset
1176 // Disable optimization: LoadL->ConvL2I ==> LoadI.
f34d9da7acb2 6667618: disable LoadL->ConvL2I ==> LoadI optimization
kvn
parents: 0
diff changeset
1177 // It causes problems (sizes of Load and Store nodes do not match)
f34d9da7acb2 6667618: disable LoadL->ConvL2I ==> LoadI optimization
kvn
parents: 0
diff changeset
1178 // in objects initialization code and Escape Analysis.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1179 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1180 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1181
a61af66fc99e Initial load
duke
parents:
diff changeset
1182 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
1183 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1184 const Type *CastX2PNode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
1185 const Type* t = phase->type(in(1));
5901
9a72c7ece7fb 7146442: assert(false) failed: bad AD file
kvn
parents: 4006
diff changeset
1186 if (t == Type::TOP) return Type::TOP;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1187 if (t->base() == Type_X && t->singleton()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1188 uintptr_t bits = (uintptr_t) t->is_intptr_t()->get_con();
a61af66fc99e Initial load
duke
parents:
diff changeset
1189 if (bits == 0) return TypePtr::NULL_PTR;
a61af66fc99e Initial load
duke
parents:
diff changeset
1190 return TypeRawPtr::make((address) bits);
a61af66fc99e Initial load
duke
parents:
diff changeset
1191 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1192 return CastX2PNode::bottom_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
1193 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1194
a61af66fc99e Initial load
duke
parents:
diff changeset
1195 //------------------------------Idealize---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1196 static inline bool fits_in_int(const Type* t, bool but_not_min_int = false) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1197 if (t == Type::TOP) return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
1198 const TypeX* tl = t->is_intptr_t();
a61af66fc99e Initial load
duke
parents:
diff changeset
1199 jint lo = min_jint;
a61af66fc99e Initial load
duke
parents:
diff changeset
1200 jint hi = max_jint;
a61af66fc99e Initial load
duke
parents:
diff changeset
1201 if (but_not_min_int) ++lo; // caller wants to negate the value w/o overflow
a61af66fc99e Initial load
duke
parents:
diff changeset
1202 return (tl->_lo >= lo) && (tl->_hi <= hi);
a61af66fc99e Initial load
duke
parents:
diff changeset
1203 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1204
a61af66fc99e Initial load
duke
parents:
diff changeset
1205 static inline Node* addP_of_X2P(PhaseGVN *phase,
a61af66fc99e Initial load
duke
parents:
diff changeset
1206 Node* base,
a61af66fc99e Initial load
duke
parents:
diff changeset
1207 Node* dispX,
a61af66fc99e Initial load
duke
parents:
diff changeset
1208 bool negate = false) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1209 if (negate) {
6804
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6795
diff changeset
1210 dispX = new (phase->C) SubXNode(phase->MakeConX(0), phase->transform(dispX));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1211 }
6804
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6795
diff changeset
1212 return new (phase->C) AddPNode(phase->C->top(),
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6795
diff changeset
1213 phase->transform(new (phase->C) CastX2PNode(base)),
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1214 phase->transform(dispX));
a61af66fc99e Initial load
duke
parents:
diff changeset
1215 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1216
a61af66fc99e Initial load
duke
parents:
diff changeset
1217 Node *CastX2PNode::Ideal(PhaseGVN *phase, bool can_reshape) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1218 // convert CastX2P(AddX(x, y)) to AddP(CastX2P(x), y) if y fits in an int
a61af66fc99e Initial load
duke
parents:
diff changeset
1219 int op = in(1)->Opcode();
a61af66fc99e Initial load
duke
parents:
diff changeset
1220 Node* x;
a61af66fc99e Initial load
duke
parents:
diff changeset
1221 Node* y;
a61af66fc99e Initial load
duke
parents:
diff changeset
1222 switch (op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1223 case Op_SubX:
a61af66fc99e Initial load
duke
parents:
diff changeset
1224 x = in(1)->in(1);
995
ddd6f1182ae3 6883468: C2 compiler enters infinite loop in PhaseIterGVN::transform
kvn
parents: 844
diff changeset
1225 // Avoid ideal transformations ping-pong between this and AddP for raw pointers.
ddd6f1182ae3 6883468: C2 compiler enters infinite loop in PhaseIterGVN::transform
kvn
parents: 844
diff changeset
1226 if (phase->find_intptr_t_con(x, -1) == 0)
ddd6f1182ae3 6883468: C2 compiler enters infinite loop in PhaseIterGVN::transform
kvn
parents: 844
diff changeset
1227 break;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1228 y = in(1)->in(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1229 if (fits_in_int(phase->type(y), true)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1230 return addP_of_X2P(phase, x, y, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1231 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1232 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1233 case Op_AddX:
a61af66fc99e Initial load
duke
parents:
diff changeset
1234 x = in(1)->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1235 y = in(1)->in(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1236 if (fits_in_int(phase->type(y))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1237 return addP_of_X2P(phase, x, y);
a61af66fc99e Initial load
duke
parents:
diff changeset
1238 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1239 if (fits_in_int(phase->type(x))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1240 return addP_of_X2P(phase, y, x);
a61af66fc99e Initial load
duke
parents:
diff changeset
1241 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1242 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1243 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1244 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1245 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1246
a61af66fc99e Initial load
duke
parents:
diff changeset
1247 //------------------------------Identity---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1248 Node *CastX2PNode::Identity( PhaseTransform *phase ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1249 if (in(1)->Opcode() == Op_CastP2X) return in(1)->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1250 return this;
a61af66fc99e Initial load
duke
parents:
diff changeset
1251 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1252
a61af66fc99e Initial load
duke
parents:
diff changeset
1253 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
1254 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1255 const Type *CastP2XNode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
1256 const Type* t = phase->type(in(1));
5901
9a72c7ece7fb 7146442: assert(false) failed: bad AD file
kvn
parents: 4006
diff changeset
1257 if (t == Type::TOP) return Type::TOP;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1258 if (t->base() == Type::RawPtr && t->singleton()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1259 uintptr_t bits = (uintptr_t) t->is_rawptr()->get_con();
a61af66fc99e Initial load
duke
parents:
diff changeset
1260 return TypeX::make(bits);
a61af66fc99e Initial load
duke
parents:
diff changeset
1261 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1262 return CastP2XNode::bottom_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
1263 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1264
a61af66fc99e Initial load
duke
parents:
diff changeset
1265 Node *CastP2XNode::Ideal(PhaseGVN *phase, bool can_reshape) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1266 return (in(0) && remove_dead_region(phase, can_reshape)) ? this : NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1268
a61af66fc99e Initial load
duke
parents:
diff changeset
1269 //------------------------------Identity---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1270 Node *CastP2XNode::Identity( PhaseTransform *phase ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1271 if (in(1)->Opcode() == Op_CastX2P) return in(1)->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1272 return this;
a61af66fc99e Initial load
duke
parents:
diff changeset
1273 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1274
a61af66fc99e Initial load
duke
parents:
diff changeset
1275
a61af66fc99e Initial load
duke
parents:
diff changeset
1276 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
1277 //------------------------------Identity---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1278 // Remove redundant roundings
a61af66fc99e Initial load
duke
parents:
diff changeset
1279 Node *RoundFloatNode::Identity( PhaseTransform *phase ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1280 assert(Matcher::strict_fp_requires_explicit_rounding, "should only generate for Intel");
a61af66fc99e Initial load
duke
parents:
diff changeset
1281 // Do not round constants
a61af66fc99e Initial load
duke
parents:
diff changeset
1282 if (phase->type(in(1))->base() == Type::FloatCon) return in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1283 int op = in(1)->Opcode();
a61af66fc99e Initial load
duke
parents:
diff changeset
1284 // Redundant rounding
a61af66fc99e Initial load
duke
parents:
diff changeset
1285 if( op == Op_RoundFloat ) return in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1286 // Already rounded
a61af66fc99e Initial load
duke
parents:
diff changeset
1287 if( op == Op_Parm ) return in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1288 if( op == Op_LoadF ) return in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1289 return this;
a61af66fc99e Initial load
duke
parents:
diff changeset
1290 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1291
a61af66fc99e Initial load
duke
parents:
diff changeset
1292 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1293 const Type *RoundFloatNode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
1294 return phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
1295 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1296
a61af66fc99e Initial load
duke
parents:
diff changeset
1297 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
1298 //------------------------------Identity---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1299 // Remove redundant roundings. Incoming arguments are already rounded.
a61af66fc99e Initial load
duke
parents:
diff changeset
1300 Node *RoundDoubleNode::Identity( PhaseTransform *phase ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1301 assert(Matcher::strict_fp_requires_explicit_rounding, "should only generate for Intel");
a61af66fc99e Initial load
duke
parents:
diff changeset
1302 // Do not round constants
a61af66fc99e Initial load
duke
parents:
diff changeset
1303 if (phase->type(in(1))->base() == Type::DoubleCon) return in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1304 int op = in(1)->Opcode();
a61af66fc99e Initial load
duke
parents:
diff changeset
1305 // Redundant rounding
a61af66fc99e Initial load
duke
parents:
diff changeset
1306 if( op == Op_RoundDouble ) return in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1307 // Already rounded
a61af66fc99e Initial load
duke
parents:
diff changeset
1308 if( op == Op_Parm ) return in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1309 if( op == Op_LoadD ) return in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1310 if( op == Op_ConvF2D ) return in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1311 if( op == Op_ConvI2D ) return in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1312 return this;
a61af66fc99e Initial load
duke
parents:
diff changeset
1313 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1314
a61af66fc99e Initial load
duke
parents:
diff changeset
1315 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1316 const Type *RoundDoubleNode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
1317 return phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
1318 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1319
a61af66fc99e Initial load
duke
parents:
diff changeset
1320
a61af66fc99e Initial load
duke
parents:
diff changeset
1321 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
1322 // Do not allow value-numbering
a61af66fc99e Initial load
duke
parents:
diff changeset
1323 uint Opaque1Node::hash() const { return NO_HASH; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1324 uint Opaque1Node::cmp( const Node &n ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
1325 return (&n == this); // Always fail except on self
a61af66fc99e Initial load
duke
parents:
diff changeset
1326 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1327
a61af66fc99e Initial load
duke
parents:
diff changeset
1328 //------------------------------Identity---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1329 // If _major_progress, then more loop optimizations follow. Do NOT remove
a61af66fc99e Initial load
duke
parents:
diff changeset
1330 // the opaque Node until no more loop ops can happen. Note the timing of
a61af66fc99e Initial load
duke
parents:
diff changeset
1331 // _major_progress; it's set in the major loop optimizations THEN comes the
a61af66fc99e Initial load
duke
parents:
diff changeset
1332 // call to IterGVN and any chance of hitting this code. Hence there's no
a61af66fc99e Initial load
duke
parents:
diff changeset
1333 // phase-ordering problem with stripping Opaque1 in IGVN followed by some
a61af66fc99e Initial load
duke
parents:
diff changeset
1334 // more loop optimizations that require it.
a61af66fc99e Initial load
duke
parents:
diff changeset
1335 Node *Opaque1Node::Identity( PhaseTransform *phase ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1336 return phase->C->major_progress() ? this : in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1337 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1338
a61af66fc99e Initial load
duke
parents:
diff changeset
1339 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
1340 // A node to prevent unwanted optimizations. Allows constant folding. Stops
a61af66fc99e Initial load
duke
parents:
diff changeset
1341 // value-numbering, most Ideal calls or Identity functions. This Node is
a61af66fc99e Initial load
duke
parents:
diff changeset
1342 // specifically designed to prevent the pre-increment value of a loop trip
a61af66fc99e Initial load
duke
parents:
diff changeset
1343 // counter from being live out of the bottom of the loop (hence causing the
a61af66fc99e Initial load
duke
parents:
diff changeset
1344 // pre- and post-increment values both being live and thus requiring an extra
a61af66fc99e Initial load
duke
parents:
diff changeset
1345 // temp register and an extra move). If we "accidentally" optimize through
a61af66fc99e Initial load
duke
parents:
diff changeset
1346 // this kind of a Node, we'll get slightly pessimal, but correct, code. Thus
a61af66fc99e Initial load
duke
parents:
diff changeset
1347 // it's OK to be slightly sloppy on optimizations here.
a61af66fc99e Initial load
duke
parents:
diff changeset
1348
a61af66fc99e Initial load
duke
parents:
diff changeset
1349 // Do not allow value-numbering
a61af66fc99e Initial load
duke
parents:
diff changeset
1350 uint Opaque2Node::hash() const { return NO_HASH; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1351 uint Opaque2Node::cmp( const Node &n ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
1352 return (&n == this); // Always fail except on self
a61af66fc99e Initial load
duke
parents:
diff changeset
1353 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1354
22985
eb8b5cc64669 8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents: 20708
diff changeset
1355 //=============================================================================
eb8b5cc64669 8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents: 20708
diff changeset
1356
eb8b5cc64669 8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents: 20708
diff changeset
1357 uint ProfileBooleanNode::hash() const { return NO_HASH; }
eb8b5cc64669 8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents: 20708
diff changeset
1358 uint ProfileBooleanNode::cmp( const Node &n ) const {
eb8b5cc64669 8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents: 20708
diff changeset
1359 return (&n == this);
eb8b5cc64669 8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents: 20708
diff changeset
1360 }
eb8b5cc64669 8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents: 20708
diff changeset
1361
eb8b5cc64669 8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents: 20708
diff changeset
1362 Node *ProfileBooleanNode::Ideal(PhaseGVN *phase, bool can_reshape) {
eb8b5cc64669 8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents: 20708
diff changeset
1363 if (can_reshape && _delay_removal) {
eb8b5cc64669 8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents: 20708
diff changeset
1364 _delay_removal = false;
eb8b5cc64669 8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents: 20708
diff changeset
1365 return this;
eb8b5cc64669 8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents: 20708
diff changeset
1366 } else {
eb8b5cc64669 8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents: 20708
diff changeset
1367 return NULL;
eb8b5cc64669 8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents: 20708
diff changeset
1368 }
eb8b5cc64669 8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents: 20708
diff changeset
1369 }
eb8b5cc64669 8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents: 20708
diff changeset
1370
eb8b5cc64669 8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents: 20708
diff changeset
1371 Node *ProfileBooleanNode::Identity( PhaseTransform *phase ) {
eb8b5cc64669 8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents: 20708
diff changeset
1372 if (_delay_removal) {
eb8b5cc64669 8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents: 20708
diff changeset
1373 return this;
eb8b5cc64669 8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents: 20708
diff changeset
1374 } else {
eb8b5cc64669 8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents: 20708
diff changeset
1375 assert(_consumed, "profile should be consumed before elimination");
eb8b5cc64669 8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents: 20708
diff changeset
1376 return in(1);
eb8b5cc64669 8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents: 20708
diff changeset
1377 }
eb8b5cc64669 8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents: 20708
diff changeset
1378 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1379
a61af66fc99e Initial load
duke
parents:
diff changeset
1380 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1381 const Type *MoveL2DNode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
1382 const Type *t = phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
1383 if( t == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
1384 const TypeLong *tl = t->is_long();
a61af66fc99e Initial load
duke
parents:
diff changeset
1385 if( !tl->is_con() ) return bottom_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
1386 JavaValue v;
a61af66fc99e Initial load
duke
parents:
diff changeset
1387 v.set_jlong(tl->get_con());
a61af66fc99e Initial load
duke
parents:
diff changeset
1388 return TypeD::make( v.get_jdouble() );
a61af66fc99e Initial load
duke
parents:
diff changeset
1389 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1390
a61af66fc99e Initial load
duke
parents:
diff changeset
1391 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1392 const Type *MoveI2FNode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
1393 const Type *t = phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
1394 if( t == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
1395 const TypeInt *ti = t->is_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
1396 if( !ti->is_con() ) return bottom_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
1397 JavaValue v;
a61af66fc99e Initial load
duke
parents:
diff changeset
1398 v.set_jint(ti->get_con());
a61af66fc99e Initial load
duke
parents:
diff changeset
1399 return TypeF::make( v.get_jfloat() );
a61af66fc99e Initial load
duke
parents:
diff changeset
1400 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1401
a61af66fc99e Initial load
duke
parents:
diff changeset
1402 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1403 const Type *MoveF2INode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
1404 const Type *t = phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
1405 if( t == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
1406 if( t == Type::FLOAT ) return TypeInt::INT;
a61af66fc99e Initial load
duke
parents:
diff changeset
1407 const TypeF *tf = t->is_float_constant();
a61af66fc99e Initial load
duke
parents:
diff changeset
1408 JavaValue v;
a61af66fc99e Initial load
duke
parents:
diff changeset
1409 v.set_jfloat(tf->getf());
a61af66fc99e Initial load
duke
parents:
diff changeset
1410 return TypeInt::make( v.get_jint() );
a61af66fc99e Initial load
duke
parents:
diff changeset
1411 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1412
a61af66fc99e Initial load
duke
parents:
diff changeset
1413 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1414 const Type *MoveD2LNode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
1415 const Type *t = phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
1416 if( t == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
1417 if( t == Type::DOUBLE ) return TypeLong::LONG;
a61af66fc99e Initial load
duke
parents:
diff changeset
1418 const TypeD *td = t->is_double_constant();
a61af66fc99e Initial load
duke
parents:
diff changeset
1419 JavaValue v;
a61af66fc99e Initial load
duke
parents:
diff changeset
1420 v.set_jdouble(td->getd());
a61af66fc99e Initial load
duke
parents:
diff changeset
1421 return TypeLong::make( v.get_jlong() );
a61af66fc99e Initial load
duke
parents:
diff changeset
1422 }
775
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1423
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1424 //------------------------------Value------------------------------------------
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1425 const Type* CountLeadingZerosINode::Value(PhaseTransform* phase) const {
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1426 const Type* t = phase->type(in(1));
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1427 if (t == Type::TOP) return Type::TOP;
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1428 const TypeInt* ti = t->isa_int();
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1429 if (ti && ti->is_con()) {
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1430 jint i = ti->get_con();
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1431 // HD, Figure 5-6
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1432 if (i == 0)
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1433 return TypeInt::make(BitsPerInt);
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1434 int n = 1;
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1435 unsigned int x = i;
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1436 if (x >> 16 == 0) { n += 16; x <<= 16; }
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1437 if (x >> 24 == 0) { n += 8; x <<= 8; }
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1438 if (x >> 28 == 0) { n += 4; x <<= 4; }
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1439 if (x >> 30 == 0) { n += 2; x <<= 2; }
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1440 n -= x >> 31;
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1441 return TypeInt::make(n);
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1442 }
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1443 return TypeInt::INT;
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1444 }
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1445
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1446 //------------------------------Value------------------------------------------
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1447 const Type* CountLeadingZerosLNode::Value(PhaseTransform* phase) const {
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1448 const Type* t = phase->type(in(1));
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1449 if (t == Type::TOP) return Type::TOP;
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1450 const TypeLong* tl = t->isa_long();
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1451 if (tl && tl->is_con()) {
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1452 jlong l = tl->get_con();
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1453 // HD, Figure 5-6
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1454 if (l == 0)
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1455 return TypeInt::make(BitsPerLong);
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1456 int n = 1;
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1457 unsigned int x = (((julong) l) >> 32);
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1458 if (x == 0) { n += 32; x = (int) l; }
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1459 if (x >> 16 == 0) { n += 16; x <<= 16; }
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1460 if (x >> 24 == 0) { n += 8; x <<= 8; }
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1461 if (x >> 28 == 0) { n += 4; x <<= 4; }
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1462 if (x >> 30 == 0) { n += 2; x <<= 2; }
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1463 n -= x >> 31;
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1464 return TypeInt::make(n);
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1465 }
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1466 return TypeInt::INT;
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1467 }
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1468
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1469 //------------------------------Value------------------------------------------
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1470 const Type* CountTrailingZerosINode::Value(PhaseTransform* phase) const {
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1471 const Type* t = phase->type(in(1));
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1472 if (t == Type::TOP) return Type::TOP;
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1473 const TypeInt* ti = t->isa_int();
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1474 if (ti && ti->is_con()) {
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1475 jint i = ti->get_con();
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1476 // HD, Figure 5-14
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1477 int y;
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1478 if (i == 0)
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1479 return TypeInt::make(BitsPerInt);
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1480 int n = 31;
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1481 y = i << 16; if (y != 0) { n = n - 16; i = y; }
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1482 y = i << 8; if (y != 0) { n = n - 8; i = y; }
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1483 y = i << 4; if (y != 0) { n = n - 4; i = y; }
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1484 y = i << 2; if (y != 0) { n = n - 2; i = y; }
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1485 y = i << 1; if (y != 0) { n = n - 1; }
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1486 return TypeInt::make(n);
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1487 }
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1488 return TypeInt::INT;
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1489 }
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1490
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1491 //------------------------------Value------------------------------------------
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1492 const Type* CountTrailingZerosLNode::Value(PhaseTransform* phase) const {
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1493 const Type* t = phase->type(in(1));
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1494 if (t == Type::TOP) return Type::TOP;
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1495 const TypeLong* tl = t->isa_long();
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1496 if (tl && tl->is_con()) {
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1497 jlong l = tl->get_con();
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1498 // HD, Figure 5-14
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1499 int x, y;
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1500 if (l == 0)
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1501 return TypeInt::make(BitsPerLong);
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1502 int n = 63;
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1503 y = (int) l; if (y != 0) { n = n - 32; x = y; } else x = (((julong) l) >> 32);
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1504 y = x << 16; if (y != 0) { n = n - 16; x = y; }
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1505 y = x << 8; if (y != 0) { n = n - 8; x = y; }
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1506 y = x << 4; if (y != 0) { n = n - 4; x = y; }
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1507 y = x << 2; if (y != 0) { n = n - 2; x = y; }
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1508 y = x << 1; if (y != 0) { n = n - 1; }
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1509 return TypeInt::make(n);
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1510 }
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1511 return TypeInt::INT;
93c14e5562c4 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 755
diff changeset
1512 }