annotate src/share/vm/opto/mulnode.cpp @ 404:78c058bc5cdc

6717150: improper constant folding of subnormal strictfp multiplications and divides Summary: suppress constant folding of double divides and multiplications on ia32 Reviewed-by: never
author rasbold
date Tue, 14 Oct 2008 06:58:58 -0700
parents d1605aabd0a1
children 3b5ac9e7e6ea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
196
d1605aabd0a1 6719955: Update copyright year
xdono
parents: 145
diff changeset
2 * Copyright 1997-2008 Sun Microsystems, Inc. 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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 // Portions of code courtesy of Clifford Click
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 #include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
28 #include "incls/_mulnode.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
32 //------------------------------hash-------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // Hash function over MulNodes. Needs to be commutative; i.e., I swap
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // (commute) inputs to MulNodes willy-nilly so the hash function must return
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // the same value in the presence of edge swapping.
a61af66fc99e Initial load
duke
parents:
diff changeset
36 uint MulNode::hash() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
37 return (uintptr_t)in(1) + (uintptr_t)in(2) + Opcode();
a61af66fc99e Initial load
duke
parents:
diff changeset
38 }
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 //------------------------------Identity---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // Multiplying a one preserves the other argument
a61af66fc99e Initial load
duke
parents:
diff changeset
42 Node *MulNode::Identity( PhaseTransform *phase ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
43 register const Type *one = mul_id(); // The multiplicative identity
a61af66fc99e Initial load
duke
parents:
diff changeset
44 if( phase->type( in(1) )->higher_equal( one ) ) return in(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
45 if( phase->type( in(2) )->higher_equal( one ) ) return in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 return this;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 }
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 //------------------------------Ideal------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // We also canonicalize the Node, moving constants to the right input,
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // and flatten expressions (so that 1+x+2 becomes x+3).
a61af66fc99e Initial load
duke
parents:
diff changeset
53 Node *MulNode::Ideal(PhaseGVN *phase, bool can_reshape) {
a61af66fc99e Initial load
duke
parents:
diff changeset
54 const Type *t1 = phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
55 const Type *t2 = phase->type( in(2) );
a61af66fc99e Initial load
duke
parents:
diff changeset
56 Node *progress = NULL; // Progress flag
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // We are OK if right is a constant, or right is a load and
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // left is a non-constant.
a61af66fc99e Initial load
duke
parents:
diff changeset
59 if( !(t2->singleton() ||
a61af66fc99e Initial load
duke
parents:
diff changeset
60 (in(2)->is_Load() && !(t1->singleton() || in(1)->is_Load())) ) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
61 if( t1->singleton() || // Left input is a constant?
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // Otherwise, sort inputs (commutativity) to help value numbering.
a61af66fc99e Initial load
duke
parents:
diff changeset
63 (in(1)->_idx > in(2)->_idx) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
64 swap_edges(1, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
65 const Type *t = t1;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 t1 = t2;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 t2 = t;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 progress = this; // Made progress
a61af66fc99e Initial load
duke
parents:
diff changeset
69 }
a61af66fc99e Initial load
duke
parents:
diff changeset
70 }
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // If the right input is a constant, and the left input is a product of a
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // constant, flatten the expression tree.
a61af66fc99e Initial load
duke
parents:
diff changeset
74 uint op = Opcode();
a61af66fc99e Initial load
duke
parents:
diff changeset
75 if( t2->singleton() && // Right input is a constant?
a61af66fc99e Initial load
duke
parents:
diff changeset
76 op != Op_MulF && // Float & double cannot reassociate
a61af66fc99e Initial load
duke
parents:
diff changeset
77 op != Op_MulD ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
78 if( t2 == Type::TOP ) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
79 Node *mul1 = in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // Check for dead loop
a61af66fc99e Initial load
duke
parents:
diff changeset
82 int op1 = mul1->Opcode();
a61af66fc99e Initial load
duke
parents:
diff changeset
83 if( phase->eqv( mul1, this ) || phase->eqv( in(2), this ) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
84 ( op1 == mul_opcode() || op1 == add_opcode() ) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
85 ( phase->eqv( mul1->in(1), this ) || phase->eqv( mul1->in(2), this ) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
86 phase->eqv( mul1->in(1), mul1 ) || phase->eqv( mul1->in(2), mul1 ) ) )
a61af66fc99e Initial load
duke
parents:
diff changeset
87 assert(false, "dead loop in MulNode::Ideal");
a61af66fc99e Initial load
duke
parents:
diff changeset
88 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 if( mul1->Opcode() == mul_opcode() ) { // Left input is a multiply?
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // Mul of a constant?
a61af66fc99e Initial load
duke
parents:
diff changeset
92 const Type *t12 = phase->type( mul1->in(2) );
a61af66fc99e Initial load
duke
parents:
diff changeset
93 if( t12->singleton() && t12 != Type::TOP) { // Left input is an add of a constant?
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // Compute new constant; check for overflow
a61af66fc99e Initial load
duke
parents:
diff changeset
95 const Type *tcon01 = mul1->as_Mul()->mul_ring(t2,t12);
a61af66fc99e Initial load
duke
parents:
diff changeset
96 if( tcon01->singleton() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // The Mul of the flattened expression
a61af66fc99e Initial load
duke
parents:
diff changeset
98 set_req(1, mul1->in(1));
a61af66fc99e Initial load
duke
parents:
diff changeset
99 set_req(2, phase->makecon( tcon01 ));
a61af66fc99e Initial load
duke
parents:
diff changeset
100 t2 = tcon01;
a61af66fc99e Initial load
duke
parents:
diff changeset
101 progress = this; // Made progress
a61af66fc99e Initial load
duke
parents:
diff changeset
102 }
a61af66fc99e Initial load
duke
parents:
diff changeset
103 }
a61af66fc99e Initial load
duke
parents:
diff changeset
104 }
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // If the right input is a constant, and the left input is an add of a
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // constant, flatten the tree: (X+con1)*con0 ==> X*con0 + con1*con0
a61af66fc99e Initial load
duke
parents:
diff changeset
107 const Node *add1 = in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
108 if( add1->Opcode() == add_opcode() ) { // Left input is an add?
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // Add of a constant?
a61af66fc99e Initial load
duke
parents:
diff changeset
110 const Type *t12 = phase->type( add1->in(2) );
a61af66fc99e Initial load
duke
parents:
diff changeset
111 if( t12->singleton() && t12 != Type::TOP ) { // Left input is an add of a constant?
a61af66fc99e Initial load
duke
parents:
diff changeset
112 assert( add1->in(1) != add1, "dead loop in MulNode::Ideal" );
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // Compute new constant; check for overflow
a61af66fc99e Initial load
duke
parents:
diff changeset
114 const Type *tcon01 = mul_ring(t2,t12);
a61af66fc99e Initial load
duke
parents:
diff changeset
115 if( tcon01->singleton() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // Convert (X+con1)*con0 into X*con0
a61af66fc99e Initial load
duke
parents:
diff changeset
118 Node *mul = clone(); // mul = ()*con0
a61af66fc99e Initial load
duke
parents:
diff changeset
119 mul->set_req(1,add1->in(1)); // mul = X*con0
a61af66fc99e Initial load
duke
parents:
diff changeset
120 mul = phase->transform(mul);
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 Node *add2 = add1->clone();
a61af66fc99e Initial load
duke
parents:
diff changeset
123 add2->set_req(1, mul); // X*con0 + con0*con1
a61af66fc99e Initial load
duke
parents:
diff changeset
124 add2->set_req(2, phase->makecon(tcon01) );
a61af66fc99e Initial load
duke
parents:
diff changeset
125 progress = add2;
a61af66fc99e Initial load
duke
parents:
diff changeset
126 }
a61af66fc99e Initial load
duke
parents:
diff changeset
127 }
a61af66fc99e Initial load
duke
parents:
diff changeset
128 } // End of is left input an add
a61af66fc99e Initial load
duke
parents:
diff changeset
129 } // End of is right input a Mul
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 return progress;
a61af66fc99e Initial load
duke
parents:
diff changeset
132 }
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 //------------------------------Value-----------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
135 const Type *MulNode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 const Type *t1 = phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
137 const Type *t2 = phase->type( in(2) );
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // Either input is TOP ==> the result is TOP
a61af66fc99e Initial load
duke
parents:
diff changeset
139 if( t1 == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
140 if( t2 == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142 // Either input is ZERO ==> the result is ZERO.
a61af66fc99e Initial load
duke
parents:
diff changeset
143 // Not valid for floats or doubles since +0.0 * -0.0 --> +0.0
a61af66fc99e Initial load
duke
parents:
diff changeset
144 int op = Opcode();
a61af66fc99e Initial load
duke
parents:
diff changeset
145 if( op == Op_MulI || op == Op_AndI || op == Op_MulL || op == Op_AndL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
146 const Type *zero = add_id(); // The multiplicative zero
a61af66fc99e Initial load
duke
parents:
diff changeset
147 if( t1->higher_equal( zero ) ) return zero;
a61af66fc99e Initial load
duke
parents:
diff changeset
148 if( t2->higher_equal( zero ) ) return zero;
a61af66fc99e Initial load
duke
parents:
diff changeset
149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // Either input is BOTTOM ==> the result is the local BOTTOM
a61af66fc99e Initial load
duke
parents:
diff changeset
152 if( t1 == Type::BOTTOM || t2 == Type::BOTTOM )
a61af66fc99e Initial load
duke
parents:
diff changeset
153 return bottom_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
154
404
78c058bc5cdc 6717150: improper constant folding of subnormal strictfp multiplications and divides
rasbold
parents: 196
diff changeset
155 #if defined(IA32)
78c058bc5cdc 6717150: improper constant folding of subnormal strictfp multiplications and divides
rasbold
parents: 196
diff changeset
156 // Can't trust native compilers to properly fold strict double
78c058bc5cdc 6717150: improper constant folding of subnormal strictfp multiplications and divides
rasbold
parents: 196
diff changeset
157 // multiplication with round-to-zero on this platform.
78c058bc5cdc 6717150: improper constant folding of subnormal strictfp multiplications and divides
rasbold
parents: 196
diff changeset
158 if (op == Op_MulD && phase->C->method()->is_strict()) {
78c058bc5cdc 6717150: improper constant folding of subnormal strictfp multiplications and divides
rasbold
parents: 196
diff changeset
159 return TypeD::DOUBLE;
78c058bc5cdc 6717150: improper constant folding of subnormal strictfp multiplications and divides
rasbold
parents: 196
diff changeset
160 }
78c058bc5cdc 6717150: improper constant folding of subnormal strictfp multiplications and divides
rasbold
parents: 196
diff changeset
161 #endif
78c058bc5cdc 6717150: improper constant folding of subnormal strictfp multiplications and divides
rasbold
parents: 196
diff changeset
162
0
a61af66fc99e Initial load
duke
parents:
diff changeset
163 return mul_ring(t1,t2); // Local flavor of type multiplication
a61af66fc99e Initial load
duke
parents:
diff changeset
164 }
a61af66fc99e Initial load
duke
parents:
diff changeset
165
a61af66fc99e Initial load
duke
parents:
diff changeset
166
a61af66fc99e Initial load
duke
parents:
diff changeset
167 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
168 //------------------------------Ideal------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
169 // Check for power-of-2 multiply, then try the regular MulNode::Ideal
a61af66fc99e Initial load
duke
parents:
diff changeset
170 Node *MulINode::Ideal(PhaseGVN *phase, bool can_reshape) {
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // Swap constant to right
a61af66fc99e Initial load
duke
parents:
diff changeset
172 jint con;
a61af66fc99e Initial load
duke
parents:
diff changeset
173 if ((con = in(1)->find_int_con(0)) != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
174 swap_edges(1, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
175 // Finish rest of method to use info in 'con'
a61af66fc99e Initial load
duke
parents:
diff changeset
176 } else if ((con = in(2)->find_int_con(0)) == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
177 return MulNode::Ideal(phase, can_reshape);
a61af66fc99e Initial load
duke
parents:
diff changeset
178 }
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180 // Now we have a constant Node on the right and the constant in con
a61af66fc99e Initial load
duke
parents:
diff changeset
181 if( con == 0 ) return NULL; // By zero is handled by Value call
a61af66fc99e Initial load
duke
parents:
diff changeset
182 if( con == 1 ) return NULL; // By one is handled by Identity call
a61af66fc99e Initial load
duke
parents:
diff changeset
183
a61af66fc99e Initial load
duke
parents:
diff changeset
184 // Check for negative constant; if so negate the final result
a61af66fc99e Initial load
duke
parents:
diff changeset
185 bool sign_flip = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
186 if( con < 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
187 con = -con;
a61af66fc99e Initial load
duke
parents:
diff changeset
188 sign_flip = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
189 }
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 // Get low bit; check for being the only bit
a61af66fc99e Initial load
duke
parents:
diff changeset
192 Node *res = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
193 jint bit1 = con & -con; // Extract low bit
a61af66fc99e Initial load
duke
parents:
diff changeset
194 if( bit1 == con ) { // Found a power of 2?
a61af66fc99e Initial load
duke
parents:
diff changeset
195 res = new (phase->C, 3) LShiftINode( in(1), phase->intcon(log2_intptr(bit1)) );
a61af66fc99e Initial load
duke
parents:
diff changeset
196 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
197
a61af66fc99e Initial load
duke
parents:
diff changeset
198 // Check for constant with 2 bits set
a61af66fc99e Initial load
duke
parents:
diff changeset
199 jint bit2 = con-bit1;
a61af66fc99e Initial load
duke
parents:
diff changeset
200 bit2 = bit2 & -bit2; // Extract 2nd bit
a61af66fc99e Initial load
duke
parents:
diff changeset
201 if( bit2 + bit1 == con ) { // Found all bits in con?
a61af66fc99e Initial load
duke
parents:
diff changeset
202 Node *n1 = phase->transform( new (phase->C, 3) LShiftINode( in(1), phase->intcon(log2_intptr(bit1)) ) );
a61af66fc99e Initial load
duke
parents:
diff changeset
203 Node *n2 = phase->transform( new (phase->C, 3) LShiftINode( in(1), phase->intcon(log2_intptr(bit2)) ) );
a61af66fc99e Initial load
duke
parents:
diff changeset
204 res = new (phase->C, 3) AddINode( n2, n1 );
a61af66fc99e Initial load
duke
parents:
diff changeset
205
a61af66fc99e Initial load
duke
parents:
diff changeset
206 } else if (is_power_of_2(con+1)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 // Sleezy: power-of-2 -1. Next time be generic.
a61af66fc99e Initial load
duke
parents:
diff changeset
208 jint temp = (jint) (con + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
209 Node *n1 = phase->transform( new (phase->C, 3) LShiftINode( in(1), phase->intcon(log2_intptr(temp)) ) );
a61af66fc99e Initial load
duke
parents:
diff changeset
210 res = new (phase->C, 3) SubINode( n1, in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
211 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
212 return MulNode::Ideal(phase, can_reshape);
a61af66fc99e Initial load
duke
parents:
diff changeset
213 }
a61af66fc99e Initial load
duke
parents:
diff changeset
214 }
a61af66fc99e Initial load
duke
parents:
diff changeset
215
a61af66fc99e Initial load
duke
parents:
diff changeset
216 if( sign_flip ) { // Need to negate result?
a61af66fc99e Initial load
duke
parents:
diff changeset
217 res = phase->transform(res);// Transform, before making the zero con
a61af66fc99e Initial load
duke
parents:
diff changeset
218 res = new (phase->C, 3) SubINode(phase->intcon(0),res);
a61af66fc99e Initial load
duke
parents:
diff changeset
219 }
a61af66fc99e Initial load
duke
parents:
diff changeset
220
a61af66fc99e Initial load
duke
parents:
diff changeset
221 return res; // Return final result
a61af66fc99e Initial load
duke
parents:
diff changeset
222 }
a61af66fc99e Initial load
duke
parents:
diff changeset
223
a61af66fc99e Initial load
duke
parents:
diff changeset
224 //------------------------------mul_ring---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
225 // Compute the product type of two integer ranges into this node.
a61af66fc99e Initial load
duke
parents:
diff changeset
226 const Type *MulINode::mul_ring(const Type *t0, const Type *t1) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
227 const TypeInt *r0 = t0->is_int(); // Handy access
a61af66fc99e Initial load
duke
parents:
diff changeset
228 const TypeInt *r1 = t1->is_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
229
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // Fetch endpoints of all ranges
a61af66fc99e Initial load
duke
parents:
diff changeset
231 int32 lo0 = r0->_lo;
a61af66fc99e Initial load
duke
parents:
diff changeset
232 double a = (double)lo0;
a61af66fc99e Initial load
duke
parents:
diff changeset
233 int32 hi0 = r0->_hi;
a61af66fc99e Initial load
duke
parents:
diff changeset
234 double b = (double)hi0;
a61af66fc99e Initial load
duke
parents:
diff changeset
235 int32 lo1 = r1->_lo;
a61af66fc99e Initial load
duke
parents:
diff changeset
236 double c = (double)lo1;
a61af66fc99e Initial load
duke
parents:
diff changeset
237 int32 hi1 = r1->_hi;
a61af66fc99e Initial load
duke
parents:
diff changeset
238 double d = (double)hi1;
a61af66fc99e Initial load
duke
parents:
diff changeset
239
a61af66fc99e Initial load
duke
parents:
diff changeset
240 // Compute all endpoints & check for overflow
a61af66fc99e Initial load
duke
parents:
diff changeset
241 int32 A = lo0*lo1;
a61af66fc99e Initial load
duke
parents:
diff changeset
242 if( (double)A != a*c ) return TypeInt::INT; // Overflow?
a61af66fc99e Initial load
duke
parents:
diff changeset
243 int32 B = lo0*hi1;
a61af66fc99e Initial load
duke
parents:
diff changeset
244 if( (double)B != a*d ) return TypeInt::INT; // Overflow?
a61af66fc99e Initial load
duke
parents:
diff changeset
245 int32 C = hi0*lo1;
a61af66fc99e Initial load
duke
parents:
diff changeset
246 if( (double)C != b*c ) return TypeInt::INT; // Overflow?
a61af66fc99e Initial load
duke
parents:
diff changeset
247 int32 D = hi0*hi1;
a61af66fc99e Initial load
duke
parents:
diff changeset
248 if( (double)D != b*d ) return TypeInt::INT; // Overflow?
a61af66fc99e Initial load
duke
parents:
diff changeset
249
a61af66fc99e Initial load
duke
parents:
diff changeset
250 if( A < B ) { lo0 = A; hi0 = B; } // Sort range endpoints
a61af66fc99e Initial load
duke
parents:
diff changeset
251 else { lo0 = B; hi0 = A; }
a61af66fc99e Initial load
duke
parents:
diff changeset
252 if( C < D ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
253 if( C < lo0 ) lo0 = C;
a61af66fc99e Initial load
duke
parents:
diff changeset
254 if( D > hi0 ) hi0 = D;
a61af66fc99e Initial load
duke
parents:
diff changeset
255 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
256 if( D < lo0 ) lo0 = D;
a61af66fc99e Initial load
duke
parents:
diff changeset
257 if( C > hi0 ) hi0 = C;
a61af66fc99e Initial load
duke
parents:
diff changeset
258 }
a61af66fc99e Initial load
duke
parents:
diff changeset
259 return TypeInt::make(lo0, hi0, MAX2(r0->_widen,r1->_widen));
a61af66fc99e Initial load
duke
parents:
diff changeset
260 }
a61af66fc99e Initial load
duke
parents:
diff changeset
261
a61af66fc99e Initial load
duke
parents:
diff changeset
262
a61af66fc99e Initial load
duke
parents:
diff changeset
263 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
264 //------------------------------Ideal------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
265 // Check for power-of-2 multiply, then try the regular MulNode::Ideal
a61af66fc99e Initial load
duke
parents:
diff changeset
266 Node *MulLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
a61af66fc99e Initial load
duke
parents:
diff changeset
267 // Swap constant to right
a61af66fc99e Initial load
duke
parents:
diff changeset
268 jlong con;
a61af66fc99e Initial load
duke
parents:
diff changeset
269 if ((con = in(1)->find_long_con(0)) != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
270 swap_edges(1, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
271 // Finish rest of method to use info in 'con'
a61af66fc99e Initial load
duke
parents:
diff changeset
272 } else if ((con = in(2)->find_long_con(0)) == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
273 return MulNode::Ideal(phase, can_reshape);
a61af66fc99e Initial load
duke
parents:
diff changeset
274 }
a61af66fc99e Initial load
duke
parents:
diff changeset
275
a61af66fc99e Initial load
duke
parents:
diff changeset
276 // Now we have a constant Node on the right and the constant in con
a61af66fc99e Initial load
duke
parents:
diff changeset
277 if( con == CONST64(0) ) return NULL; // By zero is handled by Value call
a61af66fc99e Initial load
duke
parents:
diff changeset
278 if( con == CONST64(1) ) return NULL; // By one is handled by Identity call
a61af66fc99e Initial load
duke
parents:
diff changeset
279
a61af66fc99e Initial load
duke
parents:
diff changeset
280 // Check for negative constant; if so negate the final result
a61af66fc99e Initial load
duke
parents:
diff changeset
281 bool sign_flip = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
282 if( con < 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
283 con = -con;
a61af66fc99e Initial load
duke
parents:
diff changeset
284 sign_flip = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
285 }
a61af66fc99e Initial load
duke
parents:
diff changeset
286
a61af66fc99e Initial load
duke
parents:
diff changeset
287 // Get low bit; check for being the only bit
a61af66fc99e Initial load
duke
parents:
diff changeset
288 Node *res = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
289 jlong bit1 = con & -con; // Extract low bit
a61af66fc99e Initial load
duke
parents:
diff changeset
290 if( bit1 == con ) { // Found a power of 2?
a61af66fc99e Initial load
duke
parents:
diff changeset
291 res = new (phase->C, 3) LShiftLNode( in(1), phase->intcon(log2_long(bit1)) );
a61af66fc99e Initial load
duke
parents:
diff changeset
292 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
293
a61af66fc99e Initial load
duke
parents:
diff changeset
294 // Check for constant with 2 bits set
a61af66fc99e Initial load
duke
parents:
diff changeset
295 jlong bit2 = con-bit1;
a61af66fc99e Initial load
duke
parents:
diff changeset
296 bit2 = bit2 & -bit2; // Extract 2nd bit
a61af66fc99e Initial load
duke
parents:
diff changeset
297 if( bit2 + bit1 == con ) { // Found all bits in con?
a61af66fc99e Initial load
duke
parents:
diff changeset
298 Node *n1 = phase->transform( new (phase->C, 3) LShiftLNode( in(1), phase->intcon(log2_long(bit1)) ) );
a61af66fc99e Initial load
duke
parents:
diff changeset
299 Node *n2 = phase->transform( new (phase->C, 3) LShiftLNode( in(1), phase->intcon(log2_long(bit2)) ) );
a61af66fc99e Initial load
duke
parents:
diff changeset
300 res = new (phase->C, 3) AddLNode( n2, n1 );
a61af66fc99e Initial load
duke
parents:
diff changeset
301
a61af66fc99e Initial load
duke
parents:
diff changeset
302 } else if (is_power_of_2_long(con+1)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
303 // Sleezy: power-of-2 -1. Next time be generic.
a61af66fc99e Initial load
duke
parents:
diff changeset
304 jlong temp = (jlong) (con + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
305 Node *n1 = phase->transform( new (phase->C, 3) LShiftLNode( in(1), phase->intcon(log2_long(temp)) ) );
a61af66fc99e Initial load
duke
parents:
diff changeset
306 res = new (phase->C, 3) SubLNode( n1, in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
307 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
308 return MulNode::Ideal(phase, can_reshape);
a61af66fc99e Initial load
duke
parents:
diff changeset
309 }
a61af66fc99e Initial load
duke
parents:
diff changeset
310 }
a61af66fc99e Initial load
duke
parents:
diff changeset
311
a61af66fc99e Initial load
duke
parents:
diff changeset
312 if( sign_flip ) { // Need to negate result?
a61af66fc99e Initial load
duke
parents:
diff changeset
313 res = phase->transform(res);// Transform, before making the zero con
a61af66fc99e Initial load
duke
parents:
diff changeset
314 res = new (phase->C, 3) SubLNode(phase->longcon(0),res);
a61af66fc99e Initial load
duke
parents:
diff changeset
315 }
a61af66fc99e Initial load
duke
parents:
diff changeset
316
a61af66fc99e Initial load
duke
parents:
diff changeset
317 return res; // Return final result
a61af66fc99e Initial load
duke
parents:
diff changeset
318 }
a61af66fc99e Initial load
duke
parents:
diff changeset
319
a61af66fc99e Initial load
duke
parents:
diff changeset
320 //------------------------------mul_ring---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
321 // Compute the product type of two integer ranges into this node.
a61af66fc99e Initial load
duke
parents:
diff changeset
322 const Type *MulLNode::mul_ring(const Type *t0, const Type *t1) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
323 const TypeLong *r0 = t0->is_long(); // Handy access
a61af66fc99e Initial load
duke
parents:
diff changeset
324 const TypeLong *r1 = t1->is_long();
a61af66fc99e Initial load
duke
parents:
diff changeset
325
a61af66fc99e Initial load
duke
parents:
diff changeset
326 // Fetch endpoints of all ranges
a61af66fc99e Initial load
duke
parents:
diff changeset
327 jlong lo0 = r0->_lo;
a61af66fc99e Initial load
duke
parents:
diff changeset
328 double a = (double)lo0;
a61af66fc99e Initial load
duke
parents:
diff changeset
329 jlong hi0 = r0->_hi;
a61af66fc99e Initial load
duke
parents:
diff changeset
330 double b = (double)hi0;
a61af66fc99e Initial load
duke
parents:
diff changeset
331 jlong lo1 = r1->_lo;
a61af66fc99e Initial load
duke
parents:
diff changeset
332 double c = (double)lo1;
a61af66fc99e Initial load
duke
parents:
diff changeset
333 jlong hi1 = r1->_hi;
a61af66fc99e Initial load
duke
parents:
diff changeset
334 double d = (double)hi1;
a61af66fc99e Initial load
duke
parents:
diff changeset
335
a61af66fc99e Initial load
duke
parents:
diff changeset
336 // Compute all endpoints & check for overflow
a61af66fc99e Initial load
duke
parents:
diff changeset
337 jlong A = lo0*lo1;
a61af66fc99e Initial load
duke
parents:
diff changeset
338 if( (double)A != a*c ) return TypeLong::LONG; // Overflow?
a61af66fc99e Initial load
duke
parents:
diff changeset
339 jlong B = lo0*hi1;
a61af66fc99e Initial load
duke
parents:
diff changeset
340 if( (double)B != a*d ) return TypeLong::LONG; // Overflow?
a61af66fc99e Initial load
duke
parents:
diff changeset
341 jlong C = hi0*lo1;
a61af66fc99e Initial load
duke
parents:
diff changeset
342 if( (double)C != b*c ) return TypeLong::LONG; // Overflow?
a61af66fc99e Initial load
duke
parents:
diff changeset
343 jlong D = hi0*hi1;
a61af66fc99e Initial load
duke
parents:
diff changeset
344 if( (double)D != b*d ) return TypeLong::LONG; // Overflow?
a61af66fc99e Initial load
duke
parents:
diff changeset
345
a61af66fc99e Initial load
duke
parents:
diff changeset
346 if( A < B ) { lo0 = A; hi0 = B; } // Sort range endpoints
a61af66fc99e Initial load
duke
parents:
diff changeset
347 else { lo0 = B; hi0 = A; }
a61af66fc99e Initial load
duke
parents:
diff changeset
348 if( C < D ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
349 if( C < lo0 ) lo0 = C;
a61af66fc99e Initial load
duke
parents:
diff changeset
350 if( D > hi0 ) hi0 = D;
a61af66fc99e Initial load
duke
parents:
diff changeset
351 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
352 if( D < lo0 ) lo0 = D;
a61af66fc99e Initial load
duke
parents:
diff changeset
353 if( C > hi0 ) hi0 = C;
a61af66fc99e Initial load
duke
parents:
diff changeset
354 }
a61af66fc99e Initial load
duke
parents:
diff changeset
355 return TypeLong::make(lo0, hi0, MAX2(r0->_widen,r1->_widen));
a61af66fc99e Initial load
duke
parents:
diff changeset
356 }
a61af66fc99e Initial load
duke
parents:
diff changeset
357
a61af66fc99e Initial load
duke
parents:
diff changeset
358 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
359 //------------------------------mul_ring---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
360 // Compute the product type of two double ranges into this node.
a61af66fc99e Initial load
duke
parents:
diff changeset
361 const Type *MulFNode::mul_ring(const Type *t0, const Type *t1) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
362 if( t0 == Type::FLOAT || t1 == Type::FLOAT ) return Type::FLOAT;
a61af66fc99e Initial load
duke
parents:
diff changeset
363 return TypeF::make( t0->getf() * t1->getf() );
a61af66fc99e Initial load
duke
parents:
diff changeset
364 }
a61af66fc99e Initial load
duke
parents:
diff changeset
365
a61af66fc99e Initial load
duke
parents:
diff changeset
366 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
367 //------------------------------mul_ring---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
368 // Compute the product type of two double ranges into this node.
a61af66fc99e Initial load
duke
parents:
diff changeset
369 const Type *MulDNode::mul_ring(const Type *t0, const Type *t1) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
370 if( t0 == Type::DOUBLE || t1 == Type::DOUBLE ) return Type::DOUBLE;
404
78c058bc5cdc 6717150: improper constant folding of subnormal strictfp multiplications and divides
rasbold
parents: 196
diff changeset
371 // We must be multiplying 2 double constants.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
372 return TypeD::make( t0->getd() * t1->getd() );
a61af66fc99e Initial load
duke
parents:
diff changeset
373 }
a61af66fc99e Initial load
duke
parents:
diff changeset
374
a61af66fc99e Initial load
duke
parents:
diff changeset
375 //=============================================================================
145
f3de1255b035 6603011: RFE: Optimize long division
rasbold
parents: 0
diff changeset
376 //------------------------------Value------------------------------------------
f3de1255b035 6603011: RFE: Optimize long division
rasbold
parents: 0
diff changeset
377 const Type *MulHiLNode::Value( PhaseTransform *phase ) const {
f3de1255b035 6603011: RFE: Optimize long division
rasbold
parents: 0
diff changeset
378 // Either input is TOP ==> the result is TOP
f3de1255b035 6603011: RFE: Optimize long division
rasbold
parents: 0
diff changeset
379 const Type *t1 = phase->type( in(1) );
f3de1255b035 6603011: RFE: Optimize long division
rasbold
parents: 0
diff changeset
380 const Type *t2 = phase->type( in(2) );
f3de1255b035 6603011: RFE: Optimize long division
rasbold
parents: 0
diff changeset
381 if( t1 == Type::TOP ) return Type::TOP;
f3de1255b035 6603011: RFE: Optimize long division
rasbold
parents: 0
diff changeset
382 if( t2 == Type::TOP ) return Type::TOP;
f3de1255b035 6603011: RFE: Optimize long division
rasbold
parents: 0
diff changeset
383
f3de1255b035 6603011: RFE: Optimize long division
rasbold
parents: 0
diff changeset
384 // Either input is BOTTOM ==> the result is the local BOTTOM
f3de1255b035 6603011: RFE: Optimize long division
rasbold
parents: 0
diff changeset
385 const Type *bot = bottom_type();
f3de1255b035 6603011: RFE: Optimize long division
rasbold
parents: 0
diff changeset
386 if( (t1 == bot) || (t2 == bot) ||
f3de1255b035 6603011: RFE: Optimize long division
rasbold
parents: 0
diff changeset
387 (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) )
f3de1255b035 6603011: RFE: Optimize long division
rasbold
parents: 0
diff changeset
388 return bot;
f3de1255b035 6603011: RFE: Optimize long division
rasbold
parents: 0
diff changeset
389
f3de1255b035 6603011: RFE: Optimize long division
rasbold
parents: 0
diff changeset
390 // It is not worth trying to constant fold this stuff!
f3de1255b035 6603011: RFE: Optimize long division
rasbold
parents: 0
diff changeset
391 return TypeLong::LONG;
f3de1255b035 6603011: RFE: Optimize long division
rasbold
parents: 0
diff changeset
392 }
f3de1255b035 6603011: RFE: Optimize long division
rasbold
parents: 0
diff changeset
393
f3de1255b035 6603011: RFE: Optimize long division
rasbold
parents: 0
diff changeset
394 //=============================================================================
0
a61af66fc99e Initial load
duke
parents:
diff changeset
395 //------------------------------mul_ring---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
396 // Supplied function returns the product of the inputs IN THE CURRENT RING.
a61af66fc99e Initial load
duke
parents:
diff changeset
397 // For the logical operations the ring's MUL is really a logical AND function.
a61af66fc99e Initial load
duke
parents:
diff changeset
398 // This also type-checks the inputs for sanity. Guaranteed never to
a61af66fc99e Initial load
duke
parents:
diff changeset
399 // be passed a TOP or BOTTOM type, these are filtered out by pre-check.
a61af66fc99e Initial load
duke
parents:
diff changeset
400 const Type *AndINode::mul_ring( const Type *t0, const Type *t1 ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
401 const TypeInt *r0 = t0->is_int(); // Handy access
a61af66fc99e Initial load
duke
parents:
diff changeset
402 const TypeInt *r1 = t1->is_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
403 int widen = MAX2(r0->_widen,r1->_widen);
a61af66fc99e Initial load
duke
parents:
diff changeset
404
a61af66fc99e Initial load
duke
parents:
diff changeset
405 // If either input is a constant, might be able to trim cases
a61af66fc99e Initial load
duke
parents:
diff changeset
406 if( !r0->is_con() && !r1->is_con() )
a61af66fc99e Initial load
duke
parents:
diff changeset
407 return TypeInt::INT; // No constants to be had
a61af66fc99e Initial load
duke
parents:
diff changeset
408
a61af66fc99e Initial load
duke
parents:
diff changeset
409 // Both constants? Return bits
a61af66fc99e Initial load
duke
parents:
diff changeset
410 if( r0->is_con() && r1->is_con() )
a61af66fc99e Initial load
duke
parents:
diff changeset
411 return TypeInt::make( r0->get_con() & r1->get_con() );
a61af66fc99e Initial load
duke
parents:
diff changeset
412
a61af66fc99e Initial load
duke
parents:
diff changeset
413 if( r0->is_con() && r0->get_con() > 0 )
a61af66fc99e Initial load
duke
parents:
diff changeset
414 return TypeInt::make(0, r0->get_con(), widen);
a61af66fc99e Initial load
duke
parents:
diff changeset
415
a61af66fc99e Initial load
duke
parents:
diff changeset
416 if( r1->is_con() && r1->get_con() > 0 )
a61af66fc99e Initial load
duke
parents:
diff changeset
417 return TypeInt::make(0, r1->get_con(), widen);
a61af66fc99e Initial load
duke
parents:
diff changeset
418
a61af66fc99e Initial load
duke
parents:
diff changeset
419 if( r0 == TypeInt::BOOL || r1 == TypeInt::BOOL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
420 return TypeInt::BOOL;
a61af66fc99e Initial load
duke
parents:
diff changeset
421 }
a61af66fc99e Initial load
duke
parents:
diff changeset
422
a61af66fc99e Initial load
duke
parents:
diff changeset
423 return TypeInt::INT; // No constants to be had
a61af66fc99e Initial load
duke
parents:
diff changeset
424 }
a61af66fc99e Initial load
duke
parents:
diff changeset
425
a61af66fc99e Initial load
duke
parents:
diff changeset
426 //------------------------------Identity---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
427 // Masking off the high bits of an unsigned load is not required
a61af66fc99e Initial load
duke
parents:
diff changeset
428 Node *AndINode::Identity( PhaseTransform *phase ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
429
a61af66fc99e Initial load
duke
parents:
diff changeset
430 // x & x => x
a61af66fc99e Initial load
duke
parents:
diff changeset
431 if (phase->eqv(in(1), in(2))) return in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
432
a61af66fc99e Initial load
duke
parents:
diff changeset
433 Node *load = in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
434 const TypeInt *t2 = phase->type( in(2) )->isa_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
435 if( t2 && t2->is_con() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
436 int con = t2->get_con();
a61af66fc99e Initial load
duke
parents:
diff changeset
437 // Masking off high bits which are always zero is useless.
a61af66fc99e Initial load
duke
parents:
diff changeset
438 const TypeInt* t1 = phase->type( in(1) )->isa_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
439 if (t1 != NULL && t1->_lo >= 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
440 jint t1_support = ((jint)1 << (1 + log2_intptr(t1->_hi))) - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
441 if ((t1_support & con) == t1_support)
a61af66fc99e Initial load
duke
parents:
diff changeset
442 return load;
a61af66fc99e Initial load
duke
parents:
diff changeset
443 }
a61af66fc99e Initial load
duke
parents:
diff changeset
444 uint lop = load->Opcode();
a61af66fc99e Initial load
duke
parents:
diff changeset
445 if( lop == Op_LoadC &&
a61af66fc99e Initial load
duke
parents:
diff changeset
446 con == 0x0000FFFF ) // Already zero-extended
a61af66fc99e Initial load
duke
parents:
diff changeset
447 return load;
a61af66fc99e Initial load
duke
parents:
diff changeset
448 // Masking off the high bits of a unsigned-shift-right is not
a61af66fc99e Initial load
duke
parents:
diff changeset
449 // needed either.
a61af66fc99e Initial load
duke
parents:
diff changeset
450 if( lop == Op_URShiftI ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
451 const TypeInt *t12 = phase->type( load->in(2) )->isa_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
452 if( t12 && t12->is_con() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
453 int shift_con = t12->get_con();
a61af66fc99e Initial load
duke
parents:
diff changeset
454 int mask = max_juint >> shift_con;
a61af66fc99e Initial load
duke
parents:
diff changeset
455 if( (mask&con) == mask ) // If AND is useless, skip it
a61af66fc99e Initial load
duke
parents:
diff changeset
456 return load;
a61af66fc99e Initial load
duke
parents:
diff changeset
457 }
a61af66fc99e Initial load
duke
parents:
diff changeset
458 }
a61af66fc99e Initial load
duke
parents:
diff changeset
459 }
a61af66fc99e Initial load
duke
parents:
diff changeset
460 return MulNode::Identity(phase);
a61af66fc99e Initial load
duke
parents:
diff changeset
461 }
a61af66fc99e Initial load
duke
parents:
diff changeset
462
a61af66fc99e Initial load
duke
parents:
diff changeset
463 //------------------------------Ideal------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
464 Node *AndINode::Ideal(PhaseGVN *phase, bool can_reshape) {
a61af66fc99e Initial load
duke
parents:
diff changeset
465 // Special case constant AND mask
a61af66fc99e Initial load
duke
parents:
diff changeset
466 const TypeInt *t2 = phase->type( in(2) )->isa_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
467 if( !t2 || !t2->is_con() ) return MulNode::Ideal(phase, can_reshape);
a61af66fc99e Initial load
duke
parents:
diff changeset
468 const int mask = t2->get_con();
a61af66fc99e Initial load
duke
parents:
diff changeset
469 Node *load = in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
470 uint lop = load->Opcode();
a61af66fc99e Initial load
duke
parents:
diff changeset
471
a61af66fc99e Initial load
duke
parents:
diff changeset
472 // Masking bits off of a Character? Hi bits are already zero.
a61af66fc99e Initial load
duke
parents:
diff changeset
473 if( lop == Op_LoadC &&
a61af66fc99e Initial load
duke
parents:
diff changeset
474 (mask & 0xFFFF0000) ) // Can we make a smaller mask?
a61af66fc99e Initial load
duke
parents:
diff changeset
475 return new (phase->C, 3) AndINode(load,phase->intcon(mask&0xFFFF));
a61af66fc99e Initial load
duke
parents:
diff changeset
476
a61af66fc99e Initial load
duke
parents:
diff changeset
477 // Masking bits off of a Short? Loading a Character does some masking
a61af66fc99e Initial load
duke
parents:
diff changeset
478 if( lop == Op_LoadS &&
a61af66fc99e Initial load
duke
parents:
diff changeset
479 (mask & 0xFFFF0000) == 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
480 Node *ldc = new (phase->C, 3) LoadCNode(load->in(MemNode::Control),
a61af66fc99e Initial load
duke
parents:
diff changeset
481 load->in(MemNode::Memory),
a61af66fc99e Initial load
duke
parents:
diff changeset
482 load->in(MemNode::Address),
a61af66fc99e Initial load
duke
parents:
diff changeset
483 load->adr_type());
a61af66fc99e Initial load
duke
parents:
diff changeset
484 ldc = phase->transform(ldc);
a61af66fc99e Initial load
duke
parents:
diff changeset
485 return new (phase->C, 3) AndINode(ldc,phase->intcon(mask&0xFFFF));
a61af66fc99e Initial load
duke
parents:
diff changeset
486 }
a61af66fc99e Initial load
duke
parents:
diff changeset
487
a61af66fc99e Initial load
duke
parents:
diff changeset
488 // Masking sign bits off of a Byte? Let the matcher use an unsigned load
a61af66fc99e Initial load
duke
parents:
diff changeset
489 if( lop == Op_LoadB &&
a61af66fc99e Initial load
duke
parents:
diff changeset
490 (!in(0) && load->in(0)) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
491 (mask == 0x000000FF) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
492 // Associate this node with the LoadB, so the matcher can see them together.
a61af66fc99e Initial load
duke
parents:
diff changeset
493 // If we don't do this, it is common for the LoadB to have one control
a61af66fc99e Initial load
duke
parents:
diff changeset
494 // edge, and the store or call containing this AndI to have a different
a61af66fc99e Initial load
duke
parents:
diff changeset
495 // control edge. This will cause Label_Root to group the AndI with
a61af66fc99e Initial load
duke
parents:
diff changeset
496 // the encoding store or call, so the matcher has no chance to match
a61af66fc99e Initial load
duke
parents:
diff changeset
497 // this AndI together with the LoadB. Setting the control edge here
a61af66fc99e Initial load
duke
parents:
diff changeset
498 // prevents Label_Root from grouping the AndI with the store or call,
a61af66fc99e Initial load
duke
parents:
diff changeset
499 // if it has a control edge that is inconsistent with the LoadB.
a61af66fc99e Initial load
duke
parents:
diff changeset
500 set_req(0, load->in(0));
a61af66fc99e Initial load
duke
parents:
diff changeset
501 return this;
a61af66fc99e Initial load
duke
parents:
diff changeset
502 }
a61af66fc99e Initial load
duke
parents:
diff changeset
503
a61af66fc99e Initial load
duke
parents:
diff changeset
504 // Masking off sign bits? Dont make them!
a61af66fc99e Initial load
duke
parents:
diff changeset
505 if( lop == Op_RShiftI ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
506 const TypeInt *t12 = phase->type(load->in(2))->isa_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
507 if( t12 && t12->is_con() ) { // Shift is by a constant
a61af66fc99e Initial load
duke
parents:
diff changeset
508 int shift = t12->get_con();
a61af66fc99e Initial load
duke
parents:
diff changeset
509 shift &= BitsPerJavaInteger-1; // semantics of Java shifts
a61af66fc99e Initial load
duke
parents:
diff changeset
510 const int sign_bits_mask = ~right_n_bits(BitsPerJavaInteger - shift);
a61af66fc99e Initial load
duke
parents:
diff changeset
511 // If the AND'ing of the 2 masks has no bits, then only original shifted
a61af66fc99e Initial load
duke
parents:
diff changeset
512 // bits survive. NO sign-extension bits survive the maskings.
a61af66fc99e Initial load
duke
parents:
diff changeset
513 if( (sign_bits_mask & mask) == 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
514 // Use zero-fill shift instead
a61af66fc99e Initial load
duke
parents:
diff changeset
515 Node *zshift = phase->transform(new (phase->C, 3) URShiftINode(load->in(1),load->in(2)));
a61af66fc99e Initial load
duke
parents:
diff changeset
516 return new (phase->C, 3) AndINode( zshift, in(2) );
a61af66fc99e Initial load
duke
parents:
diff changeset
517 }
a61af66fc99e Initial load
duke
parents:
diff changeset
518 }
a61af66fc99e Initial load
duke
parents:
diff changeset
519 }
a61af66fc99e Initial load
duke
parents:
diff changeset
520
a61af66fc99e Initial load
duke
parents:
diff changeset
521 // Check for 'negate/and-1', a pattern emitted when someone asks for
a61af66fc99e Initial load
duke
parents:
diff changeset
522 // 'mod 2'. Negate leaves the low order bit unchanged (think: complement
a61af66fc99e Initial load
duke
parents:
diff changeset
523 // plus 1) and the mask is of the low order bit. Skip the negate.
a61af66fc99e Initial load
duke
parents:
diff changeset
524 if( lop == Op_SubI && mask == 1 && load->in(1) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
525 phase->type(load->in(1)) == TypeInt::ZERO )
a61af66fc99e Initial load
duke
parents:
diff changeset
526 return new (phase->C, 3) AndINode( load->in(2), in(2) );
a61af66fc99e Initial load
duke
parents:
diff changeset
527
a61af66fc99e Initial load
duke
parents:
diff changeset
528 return MulNode::Ideal(phase, can_reshape);
a61af66fc99e Initial load
duke
parents:
diff changeset
529 }
a61af66fc99e Initial load
duke
parents:
diff changeset
530
a61af66fc99e Initial load
duke
parents:
diff changeset
531 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
532 //------------------------------mul_ring---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
533 // Supplied function returns the product of the inputs IN THE CURRENT RING.
a61af66fc99e Initial load
duke
parents:
diff changeset
534 // For the logical operations the ring's MUL is really a logical AND function.
a61af66fc99e Initial load
duke
parents:
diff changeset
535 // This also type-checks the inputs for sanity. Guaranteed never to
a61af66fc99e Initial load
duke
parents:
diff changeset
536 // be passed a TOP or BOTTOM type, these are filtered out by pre-check.
a61af66fc99e Initial load
duke
parents:
diff changeset
537 const Type *AndLNode::mul_ring( const Type *t0, const Type *t1 ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
538 const TypeLong *r0 = t0->is_long(); // Handy access
a61af66fc99e Initial load
duke
parents:
diff changeset
539 const TypeLong *r1 = t1->is_long();
a61af66fc99e Initial load
duke
parents:
diff changeset
540 int widen = MAX2(r0->_widen,r1->_widen);
a61af66fc99e Initial load
duke
parents:
diff changeset
541
a61af66fc99e Initial load
duke
parents:
diff changeset
542 // If either input is a constant, might be able to trim cases
a61af66fc99e Initial load
duke
parents:
diff changeset
543 if( !r0->is_con() && !r1->is_con() )
a61af66fc99e Initial load
duke
parents:
diff changeset
544 return TypeLong::LONG; // No constants to be had
a61af66fc99e Initial load
duke
parents:
diff changeset
545
a61af66fc99e Initial load
duke
parents:
diff changeset
546 // Both constants? Return bits
a61af66fc99e Initial load
duke
parents:
diff changeset
547 if( r0->is_con() && r1->is_con() )
a61af66fc99e Initial load
duke
parents:
diff changeset
548 return TypeLong::make( r0->get_con() & r1->get_con() );
a61af66fc99e Initial load
duke
parents:
diff changeset
549
a61af66fc99e Initial load
duke
parents:
diff changeset
550 if( r0->is_con() && r0->get_con() > 0 )
a61af66fc99e Initial load
duke
parents:
diff changeset
551 return TypeLong::make(CONST64(0), r0->get_con(), widen);
a61af66fc99e Initial load
duke
parents:
diff changeset
552
a61af66fc99e Initial load
duke
parents:
diff changeset
553 if( r1->is_con() && r1->get_con() > 0 )
a61af66fc99e Initial load
duke
parents:
diff changeset
554 return TypeLong::make(CONST64(0), r1->get_con(), widen);
a61af66fc99e Initial load
duke
parents:
diff changeset
555
a61af66fc99e Initial load
duke
parents:
diff changeset
556 return TypeLong::LONG; // No constants to be had
a61af66fc99e Initial load
duke
parents:
diff changeset
557 }
a61af66fc99e Initial load
duke
parents:
diff changeset
558
a61af66fc99e Initial load
duke
parents:
diff changeset
559 //------------------------------Identity---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
560 // Masking off the high bits of an unsigned load is not required
a61af66fc99e Initial load
duke
parents:
diff changeset
561 Node *AndLNode::Identity( PhaseTransform *phase ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
562
a61af66fc99e Initial load
duke
parents:
diff changeset
563 // x & x => x
a61af66fc99e Initial load
duke
parents:
diff changeset
564 if (phase->eqv(in(1), in(2))) return in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
565
a61af66fc99e Initial load
duke
parents:
diff changeset
566 Node *usr = in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
567 const TypeLong *t2 = phase->type( in(2) )->isa_long();
a61af66fc99e Initial load
duke
parents:
diff changeset
568 if( t2 && t2->is_con() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
569 jlong con = t2->get_con();
a61af66fc99e Initial load
duke
parents:
diff changeset
570 // Masking off high bits which are always zero is useless.
a61af66fc99e Initial load
duke
parents:
diff changeset
571 const TypeLong* t1 = phase->type( in(1) )->isa_long();
a61af66fc99e Initial load
duke
parents:
diff changeset
572 if (t1 != NULL && t1->_lo >= 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
573 jlong t1_support = ((jlong)1 << (1 + log2_long(t1->_hi))) - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
574 if ((t1_support & con) == t1_support)
a61af66fc99e Initial load
duke
parents:
diff changeset
575 return usr;
a61af66fc99e Initial load
duke
parents:
diff changeset
576 }
a61af66fc99e Initial load
duke
parents:
diff changeset
577 uint lop = usr->Opcode();
a61af66fc99e Initial load
duke
parents:
diff changeset
578 // Masking off the high bits of a unsigned-shift-right is not
a61af66fc99e Initial load
duke
parents:
diff changeset
579 // needed either.
a61af66fc99e Initial load
duke
parents:
diff changeset
580 if( lop == Op_URShiftL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
581 const TypeInt *t12 = phase->type( usr->in(2) )->isa_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
582 if( t12 && t12->is_con() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
583 int shift_con = t12->get_con();
a61af66fc99e Initial load
duke
parents:
diff changeset
584 jlong mask = max_julong >> shift_con;
a61af66fc99e Initial load
duke
parents:
diff changeset
585 if( (mask&con) == mask ) // If AND is useless, skip it
a61af66fc99e Initial load
duke
parents:
diff changeset
586 return usr;
a61af66fc99e Initial load
duke
parents:
diff changeset
587 }
a61af66fc99e Initial load
duke
parents:
diff changeset
588 }
a61af66fc99e Initial load
duke
parents:
diff changeset
589 }
a61af66fc99e Initial load
duke
parents:
diff changeset
590 return MulNode::Identity(phase);
a61af66fc99e Initial load
duke
parents:
diff changeset
591 }
a61af66fc99e Initial load
duke
parents:
diff changeset
592
a61af66fc99e Initial load
duke
parents:
diff changeset
593 //------------------------------Ideal------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
594 Node *AndLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
a61af66fc99e Initial load
duke
parents:
diff changeset
595 // Special case constant AND mask
a61af66fc99e Initial load
duke
parents:
diff changeset
596 const TypeLong *t2 = phase->type( in(2) )->isa_long();
a61af66fc99e Initial load
duke
parents:
diff changeset
597 if( !t2 || !t2->is_con() ) return MulNode::Ideal(phase, can_reshape);
a61af66fc99e Initial load
duke
parents:
diff changeset
598 const jlong mask = t2->get_con();
a61af66fc99e Initial load
duke
parents:
diff changeset
599
a61af66fc99e Initial load
duke
parents:
diff changeset
600 Node *rsh = in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
601 uint rop = rsh->Opcode();
a61af66fc99e Initial load
duke
parents:
diff changeset
602
a61af66fc99e Initial load
duke
parents:
diff changeset
603 // Masking off sign bits? Dont make them!
a61af66fc99e Initial load
duke
parents:
diff changeset
604 if( rop == Op_RShiftL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
605 const TypeInt *t12 = phase->type(rsh->in(2))->isa_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
606 if( t12 && t12->is_con() ) { // Shift is by a constant
a61af66fc99e Initial load
duke
parents:
diff changeset
607 int shift = t12->get_con();
a61af66fc99e Initial load
duke
parents:
diff changeset
608 shift &= (BitsPerJavaInteger*2)-1; // semantics of Java shifts
a61af66fc99e Initial load
duke
parents:
diff changeset
609 const jlong sign_bits_mask = ~(((jlong)CONST64(1) << (jlong)(BitsPerJavaInteger*2 - shift)) -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
610 // If the AND'ing of the 2 masks has no bits, then only original shifted
a61af66fc99e Initial load
duke
parents:
diff changeset
611 // bits survive. NO sign-extension bits survive the maskings.
a61af66fc99e Initial load
duke
parents:
diff changeset
612 if( (sign_bits_mask & mask) == 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
613 // Use zero-fill shift instead
a61af66fc99e Initial load
duke
parents:
diff changeset
614 Node *zshift = phase->transform(new (phase->C, 3) URShiftLNode(rsh->in(1),rsh->in(2)));
a61af66fc99e Initial load
duke
parents:
diff changeset
615 return new (phase->C, 3) AndLNode( zshift, in(2) );
a61af66fc99e Initial load
duke
parents:
diff changeset
616 }
a61af66fc99e Initial load
duke
parents:
diff changeset
617 }
a61af66fc99e Initial load
duke
parents:
diff changeset
618 }
a61af66fc99e Initial load
duke
parents:
diff changeset
619
a61af66fc99e Initial load
duke
parents:
diff changeset
620 return MulNode::Ideal(phase, can_reshape);
a61af66fc99e Initial load
duke
parents:
diff changeset
621 }
a61af66fc99e Initial load
duke
parents:
diff changeset
622
a61af66fc99e Initial load
duke
parents:
diff changeset
623 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
624 //------------------------------Identity---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
625 Node *LShiftINode::Identity( PhaseTransform *phase ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
626 const TypeInt *ti = phase->type( in(2) )->isa_int(); // shift count is an int
a61af66fc99e Initial load
duke
parents:
diff changeset
627 return ( ti && ti->is_con() && ( ti->get_con() & ( BitsPerInt - 1 ) ) == 0 ) ? in(1) : this;
a61af66fc99e Initial load
duke
parents:
diff changeset
628 }
a61af66fc99e Initial load
duke
parents:
diff changeset
629
a61af66fc99e Initial load
duke
parents:
diff changeset
630 //------------------------------Ideal------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
631 // If the right input is a constant, and the left input is an add of a
a61af66fc99e Initial load
duke
parents:
diff changeset
632 // constant, flatten the tree: (X+con1)<<con0 ==> X<<con0 + con1<<con0
a61af66fc99e Initial load
duke
parents:
diff changeset
633 Node *LShiftINode::Ideal(PhaseGVN *phase, bool can_reshape) {
a61af66fc99e Initial load
duke
parents:
diff changeset
634 const Type *t = phase->type( in(2) );
a61af66fc99e Initial load
duke
parents:
diff changeset
635 if( t == Type::TOP ) return NULL; // Right input is dead
a61af66fc99e Initial load
duke
parents:
diff changeset
636 const TypeInt *t2 = t->isa_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
637 if( !t2 || !t2->is_con() ) return NULL; // Right input is a constant
a61af66fc99e Initial load
duke
parents:
diff changeset
638 const int con = t2->get_con() & ( BitsPerInt - 1 ); // masked shift count
a61af66fc99e Initial load
duke
parents:
diff changeset
639
a61af66fc99e Initial load
duke
parents:
diff changeset
640 if ( con == 0 ) return NULL; // let Identity() handle 0 shift count
a61af66fc99e Initial load
duke
parents:
diff changeset
641
a61af66fc99e Initial load
duke
parents:
diff changeset
642 // Left input is an add of a constant?
a61af66fc99e Initial load
duke
parents:
diff changeset
643 Node *add1 = in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
644 int add1_op = add1->Opcode();
a61af66fc99e Initial load
duke
parents:
diff changeset
645 if( add1_op == Op_AddI ) { // Left input is an add?
a61af66fc99e Initial load
duke
parents:
diff changeset
646 assert( add1 != add1->in(1), "dead loop in LShiftINode::Ideal" );
a61af66fc99e Initial load
duke
parents:
diff changeset
647 const TypeInt *t12 = phase->type(add1->in(2))->isa_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
648 if( t12 && t12->is_con() ){ // Left input is an add of a con?
a61af66fc99e Initial load
duke
parents:
diff changeset
649 // Transform is legal, but check for profit. Avoid breaking 'i2s'
a61af66fc99e Initial load
duke
parents:
diff changeset
650 // and 'i2b' patterns which typically fold into 'StoreC/StoreB'.
a61af66fc99e Initial load
duke
parents:
diff changeset
651 if( con < 16 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
652 // Compute X << con0
a61af66fc99e Initial load
duke
parents:
diff changeset
653 Node *lsh = phase->transform( new (phase->C, 3) LShiftINode( add1->in(1), in(2) ) );
a61af66fc99e Initial load
duke
parents:
diff changeset
654 // Compute X<<con0 + (con1<<con0)
a61af66fc99e Initial load
duke
parents:
diff changeset
655 return new (phase->C, 3) AddINode( lsh, phase->intcon(t12->get_con() << con));
a61af66fc99e Initial load
duke
parents:
diff changeset
656 }
a61af66fc99e Initial load
duke
parents:
diff changeset
657 }
a61af66fc99e Initial load
duke
parents:
diff changeset
658 }
a61af66fc99e Initial load
duke
parents:
diff changeset
659
a61af66fc99e Initial load
duke
parents:
diff changeset
660 // Check for "(x>>c0)<<c0" which just masks off low bits
a61af66fc99e Initial load
duke
parents:
diff changeset
661 if( (add1_op == Op_RShiftI || add1_op == Op_URShiftI ) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
662 add1->in(2) == in(2) )
a61af66fc99e Initial load
duke
parents:
diff changeset
663 // Convert to "(x & -(1<<c0))"
a61af66fc99e Initial load
duke
parents:
diff changeset
664 return new (phase->C, 3) AndINode(add1->in(1),phase->intcon( -(1<<con)));
a61af66fc99e Initial load
duke
parents:
diff changeset
665
a61af66fc99e Initial load
duke
parents:
diff changeset
666 // Check for "((x>>c0) & Y)<<c0" which just masks off more low bits
a61af66fc99e Initial load
duke
parents:
diff changeset
667 if( add1_op == Op_AndI ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
668 Node *add2 = add1->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
669 int add2_op = add2->Opcode();
a61af66fc99e Initial load
duke
parents:
diff changeset
670 if( (add2_op == Op_RShiftI || add2_op == Op_URShiftI ) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
671 add2->in(2) == in(2) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
672 // Convert to "(x & (Y<<c0))"
a61af66fc99e Initial load
duke
parents:
diff changeset
673 Node *y_sh = phase->transform( new (phase->C, 3) LShiftINode( add1->in(2), in(2) ) );
a61af66fc99e Initial load
duke
parents:
diff changeset
674 return new (phase->C, 3) AndINode( add2->in(1), y_sh );
a61af66fc99e Initial load
duke
parents:
diff changeset
675 }
a61af66fc99e Initial load
duke
parents:
diff changeset
676 }
a61af66fc99e Initial load
duke
parents:
diff changeset
677
a61af66fc99e Initial load
duke
parents:
diff changeset
678 // Check for ((x & ((1<<(32-c0))-1)) << c0) which ANDs off high bits
a61af66fc99e Initial load
duke
parents:
diff changeset
679 // before shifting them away.
a61af66fc99e Initial load
duke
parents:
diff changeset
680 const jint bits_mask = right_n_bits(BitsPerJavaInteger-con);
a61af66fc99e Initial load
duke
parents:
diff changeset
681 if( add1_op == Op_AndI &&
a61af66fc99e Initial load
duke
parents:
diff changeset
682 phase->type(add1->in(2)) == TypeInt::make( bits_mask ) )
a61af66fc99e Initial load
duke
parents:
diff changeset
683 return new (phase->C, 3) LShiftINode( add1->in(1), in(2) );
a61af66fc99e Initial load
duke
parents:
diff changeset
684
a61af66fc99e Initial load
duke
parents:
diff changeset
685 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
686 }
a61af66fc99e Initial load
duke
parents:
diff changeset
687
a61af66fc99e Initial load
duke
parents:
diff changeset
688 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
689 // A LShiftINode shifts its input2 left by input1 amount.
a61af66fc99e Initial load
duke
parents:
diff changeset
690 const Type *LShiftINode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
691 const Type *t1 = phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
692 const Type *t2 = phase->type( in(2) );
a61af66fc99e Initial load
duke
parents:
diff changeset
693 // Either input is TOP ==> the result is TOP
a61af66fc99e Initial load
duke
parents:
diff changeset
694 if( t1 == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
695 if( t2 == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
696
a61af66fc99e Initial load
duke
parents:
diff changeset
697 // Left input is ZERO ==> the result is ZERO.
a61af66fc99e Initial load
duke
parents:
diff changeset
698 if( t1 == TypeInt::ZERO ) return TypeInt::ZERO;
a61af66fc99e Initial load
duke
parents:
diff changeset
699 // Shift by zero does nothing
a61af66fc99e Initial load
duke
parents:
diff changeset
700 if( t2 == TypeInt::ZERO ) return t1;
a61af66fc99e Initial load
duke
parents:
diff changeset
701
a61af66fc99e Initial load
duke
parents:
diff changeset
702 // Either input is BOTTOM ==> the result is BOTTOM
a61af66fc99e Initial load
duke
parents:
diff changeset
703 if( (t1 == TypeInt::INT) || (t2 == TypeInt::INT) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
704 (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) )
a61af66fc99e Initial load
duke
parents:
diff changeset
705 return TypeInt::INT;
a61af66fc99e Initial load
duke
parents:
diff changeset
706
a61af66fc99e Initial load
duke
parents:
diff changeset
707 const TypeInt *r1 = t1->is_int(); // Handy access
a61af66fc99e Initial load
duke
parents:
diff changeset
708 const TypeInt *r2 = t2->is_int(); // Handy access
a61af66fc99e Initial load
duke
parents:
diff changeset
709
a61af66fc99e Initial load
duke
parents:
diff changeset
710 if (!r2->is_con())
a61af66fc99e Initial load
duke
parents:
diff changeset
711 return TypeInt::INT;
a61af66fc99e Initial load
duke
parents:
diff changeset
712
a61af66fc99e Initial load
duke
parents:
diff changeset
713 uint shift = r2->get_con();
a61af66fc99e Initial load
duke
parents:
diff changeset
714 shift &= BitsPerJavaInteger-1; // semantics of Java shifts
a61af66fc99e Initial load
duke
parents:
diff changeset
715 // Shift by a multiple of 32 does nothing:
a61af66fc99e Initial load
duke
parents:
diff changeset
716 if (shift == 0) return t1;
a61af66fc99e Initial load
duke
parents:
diff changeset
717
a61af66fc99e Initial load
duke
parents:
diff changeset
718 // If the shift is a constant, shift the bounds of the type,
a61af66fc99e Initial load
duke
parents:
diff changeset
719 // unless this could lead to an overflow.
a61af66fc99e Initial load
duke
parents:
diff changeset
720 if (!r1->is_con()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
721 jint lo = r1->_lo, hi = r1->_hi;
a61af66fc99e Initial load
duke
parents:
diff changeset
722 if (((lo << shift) >> shift) == lo &&
a61af66fc99e Initial load
duke
parents:
diff changeset
723 ((hi << shift) >> shift) == hi) {
a61af66fc99e Initial load
duke
parents:
diff changeset
724 // No overflow. The range shifts up cleanly.
a61af66fc99e Initial load
duke
parents:
diff changeset
725 return TypeInt::make((jint)lo << (jint)shift,
a61af66fc99e Initial load
duke
parents:
diff changeset
726 (jint)hi << (jint)shift,
a61af66fc99e Initial load
duke
parents:
diff changeset
727 MAX2(r1->_widen,r2->_widen));
a61af66fc99e Initial load
duke
parents:
diff changeset
728 }
a61af66fc99e Initial load
duke
parents:
diff changeset
729 return TypeInt::INT;
a61af66fc99e Initial load
duke
parents:
diff changeset
730 }
a61af66fc99e Initial load
duke
parents:
diff changeset
731
a61af66fc99e Initial load
duke
parents:
diff changeset
732 return TypeInt::make( (jint)r1->get_con() << (jint)shift );
a61af66fc99e Initial load
duke
parents:
diff changeset
733 }
a61af66fc99e Initial load
duke
parents:
diff changeset
734
a61af66fc99e Initial load
duke
parents:
diff changeset
735 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
736 //------------------------------Identity---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
737 Node *LShiftLNode::Identity( PhaseTransform *phase ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
738 const TypeInt *ti = phase->type( in(2) )->isa_int(); // shift count is an int
a61af66fc99e Initial load
duke
parents:
diff changeset
739 return ( ti && ti->is_con() && ( ti->get_con() & ( BitsPerLong - 1 ) ) == 0 ) ? in(1) : this;
a61af66fc99e Initial load
duke
parents:
diff changeset
740 }
a61af66fc99e Initial load
duke
parents:
diff changeset
741
a61af66fc99e Initial load
duke
parents:
diff changeset
742 //------------------------------Ideal------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
743 // If the right input is a constant, and the left input is an add of a
a61af66fc99e Initial load
duke
parents:
diff changeset
744 // constant, flatten the tree: (X+con1)<<con0 ==> X<<con0 + con1<<con0
a61af66fc99e Initial load
duke
parents:
diff changeset
745 Node *LShiftLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
a61af66fc99e Initial load
duke
parents:
diff changeset
746 const Type *t = phase->type( in(2) );
a61af66fc99e Initial load
duke
parents:
diff changeset
747 if( t == Type::TOP ) return NULL; // Right input is dead
a61af66fc99e Initial load
duke
parents:
diff changeset
748 const TypeInt *t2 = t->isa_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
749 if( !t2 || !t2->is_con() ) return NULL; // Right input is a constant
a61af66fc99e Initial load
duke
parents:
diff changeset
750 const int con = t2->get_con() & ( BitsPerLong - 1 ); // masked shift count
a61af66fc99e Initial load
duke
parents:
diff changeset
751
a61af66fc99e Initial load
duke
parents:
diff changeset
752 if ( con == 0 ) return NULL; // let Identity() handle 0 shift count
a61af66fc99e Initial load
duke
parents:
diff changeset
753
a61af66fc99e Initial load
duke
parents:
diff changeset
754 // Left input is an add of a constant?
a61af66fc99e Initial load
duke
parents:
diff changeset
755 Node *add1 = in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
756 int add1_op = add1->Opcode();
a61af66fc99e Initial load
duke
parents:
diff changeset
757 if( add1_op == Op_AddL ) { // Left input is an add?
a61af66fc99e Initial load
duke
parents:
diff changeset
758 // Avoid dead data cycles from dead loops
a61af66fc99e Initial load
duke
parents:
diff changeset
759 assert( add1 != add1->in(1), "dead loop in LShiftLNode::Ideal" );
a61af66fc99e Initial load
duke
parents:
diff changeset
760 const TypeLong *t12 = phase->type(add1->in(2))->isa_long();
a61af66fc99e Initial load
duke
parents:
diff changeset
761 if( t12 && t12->is_con() ){ // Left input is an add of a con?
a61af66fc99e Initial load
duke
parents:
diff changeset
762 // Compute X << con0
a61af66fc99e Initial load
duke
parents:
diff changeset
763 Node *lsh = phase->transform( new (phase->C, 3) LShiftLNode( add1->in(1), in(2) ) );
a61af66fc99e Initial load
duke
parents:
diff changeset
764 // Compute X<<con0 + (con1<<con0)
a61af66fc99e Initial load
duke
parents:
diff changeset
765 return new (phase->C, 3) AddLNode( lsh, phase->longcon(t12->get_con() << con));
a61af66fc99e Initial load
duke
parents:
diff changeset
766 }
a61af66fc99e Initial load
duke
parents:
diff changeset
767 }
a61af66fc99e Initial load
duke
parents:
diff changeset
768
a61af66fc99e Initial load
duke
parents:
diff changeset
769 // Check for "(x>>c0)<<c0" which just masks off low bits
a61af66fc99e Initial load
duke
parents:
diff changeset
770 if( (add1_op == Op_RShiftL || add1_op == Op_URShiftL ) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
771 add1->in(2) == in(2) )
a61af66fc99e Initial load
duke
parents:
diff changeset
772 // Convert to "(x & -(1<<c0))"
a61af66fc99e Initial load
duke
parents:
diff changeset
773 return new (phase->C, 3) AndLNode(add1->in(1),phase->longcon( -(CONST64(1)<<con)));
a61af66fc99e Initial load
duke
parents:
diff changeset
774
a61af66fc99e Initial load
duke
parents:
diff changeset
775 // Check for "((x>>c0) & Y)<<c0" which just masks off more low bits
a61af66fc99e Initial load
duke
parents:
diff changeset
776 if( add1_op == Op_AndL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
777 Node *add2 = add1->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
778 int add2_op = add2->Opcode();
a61af66fc99e Initial load
duke
parents:
diff changeset
779 if( (add2_op == Op_RShiftL || add2_op == Op_URShiftL ) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
780 add2->in(2) == in(2) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
781 // Convert to "(x & (Y<<c0))"
a61af66fc99e Initial load
duke
parents:
diff changeset
782 Node *y_sh = phase->transform( new (phase->C, 3) LShiftLNode( add1->in(2), in(2) ) );
a61af66fc99e Initial load
duke
parents:
diff changeset
783 return new (phase->C, 3) AndLNode( add2->in(1), y_sh );
a61af66fc99e Initial load
duke
parents:
diff changeset
784 }
a61af66fc99e Initial load
duke
parents:
diff changeset
785 }
a61af66fc99e Initial load
duke
parents:
diff changeset
786
a61af66fc99e Initial load
duke
parents:
diff changeset
787 // Check for ((x & ((CONST64(1)<<(64-c0))-1)) << c0) which ANDs off high bits
a61af66fc99e Initial load
duke
parents:
diff changeset
788 // before shifting them away.
a61af66fc99e Initial load
duke
parents:
diff changeset
789 const jlong bits_mask = ((jlong)CONST64(1) << (jlong)(BitsPerJavaInteger*2 - con)) - CONST64(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
790 if( add1_op == Op_AndL &&
a61af66fc99e Initial load
duke
parents:
diff changeset
791 phase->type(add1->in(2)) == TypeLong::make( bits_mask ) )
a61af66fc99e Initial load
duke
parents:
diff changeset
792 return new (phase->C, 3) LShiftLNode( add1->in(1), in(2) );
a61af66fc99e Initial load
duke
parents:
diff changeset
793
a61af66fc99e Initial load
duke
parents:
diff changeset
794 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
795 }
a61af66fc99e Initial load
duke
parents:
diff changeset
796
a61af66fc99e Initial load
duke
parents:
diff changeset
797 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
798 // A LShiftLNode shifts its input2 left by input1 amount.
a61af66fc99e Initial load
duke
parents:
diff changeset
799 const Type *LShiftLNode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
800 const Type *t1 = phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
801 const Type *t2 = phase->type( in(2) );
a61af66fc99e Initial load
duke
parents:
diff changeset
802 // Either input is TOP ==> the result is TOP
a61af66fc99e Initial load
duke
parents:
diff changeset
803 if( t1 == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
804 if( t2 == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
805
a61af66fc99e Initial load
duke
parents:
diff changeset
806 // Left input is ZERO ==> the result is ZERO.
a61af66fc99e Initial load
duke
parents:
diff changeset
807 if( t1 == TypeLong::ZERO ) return TypeLong::ZERO;
a61af66fc99e Initial load
duke
parents:
diff changeset
808 // Shift by zero does nothing
a61af66fc99e Initial load
duke
parents:
diff changeset
809 if( t2 == TypeInt::ZERO ) return t1;
a61af66fc99e Initial load
duke
parents:
diff changeset
810
a61af66fc99e Initial load
duke
parents:
diff changeset
811 // Either input is BOTTOM ==> the result is BOTTOM
a61af66fc99e Initial load
duke
parents:
diff changeset
812 if( (t1 == TypeLong::LONG) || (t2 == TypeInt::INT) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
813 (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) )
a61af66fc99e Initial load
duke
parents:
diff changeset
814 return TypeLong::LONG;
a61af66fc99e Initial load
duke
parents:
diff changeset
815
a61af66fc99e Initial load
duke
parents:
diff changeset
816 const TypeLong *r1 = t1->is_long(); // Handy access
a61af66fc99e Initial load
duke
parents:
diff changeset
817 const TypeInt *r2 = t2->is_int(); // Handy access
a61af66fc99e Initial load
duke
parents:
diff changeset
818
a61af66fc99e Initial load
duke
parents:
diff changeset
819 if (!r2->is_con())
a61af66fc99e Initial load
duke
parents:
diff changeset
820 return TypeLong::LONG;
a61af66fc99e Initial load
duke
parents:
diff changeset
821
a61af66fc99e Initial load
duke
parents:
diff changeset
822 uint shift = r2->get_con();
a61af66fc99e Initial load
duke
parents:
diff changeset
823 shift &= (BitsPerJavaInteger*2)-1; // semantics of Java shifts
a61af66fc99e Initial load
duke
parents:
diff changeset
824 // Shift by a multiple of 64 does nothing:
a61af66fc99e Initial load
duke
parents:
diff changeset
825 if (shift == 0) return t1;
a61af66fc99e Initial load
duke
parents:
diff changeset
826
a61af66fc99e Initial load
duke
parents:
diff changeset
827 // If the shift is a constant, shift the bounds of the type,
a61af66fc99e Initial load
duke
parents:
diff changeset
828 // unless this could lead to an overflow.
a61af66fc99e Initial load
duke
parents:
diff changeset
829 if (!r1->is_con()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
830 jlong lo = r1->_lo, hi = r1->_hi;
a61af66fc99e Initial load
duke
parents:
diff changeset
831 if (((lo << shift) >> shift) == lo &&
a61af66fc99e Initial load
duke
parents:
diff changeset
832 ((hi << shift) >> shift) == hi) {
a61af66fc99e Initial load
duke
parents:
diff changeset
833 // No overflow. The range shifts up cleanly.
a61af66fc99e Initial load
duke
parents:
diff changeset
834 return TypeLong::make((jlong)lo << (jint)shift,
a61af66fc99e Initial load
duke
parents:
diff changeset
835 (jlong)hi << (jint)shift,
a61af66fc99e Initial load
duke
parents:
diff changeset
836 MAX2(r1->_widen,r2->_widen));
a61af66fc99e Initial load
duke
parents:
diff changeset
837 }
a61af66fc99e Initial load
duke
parents:
diff changeset
838 return TypeLong::LONG;
a61af66fc99e Initial load
duke
parents:
diff changeset
839 }
a61af66fc99e Initial load
duke
parents:
diff changeset
840
a61af66fc99e Initial load
duke
parents:
diff changeset
841 return TypeLong::make( (jlong)r1->get_con() << (jint)shift );
a61af66fc99e Initial load
duke
parents:
diff changeset
842 }
a61af66fc99e Initial load
duke
parents:
diff changeset
843
a61af66fc99e Initial load
duke
parents:
diff changeset
844 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
845 //------------------------------Identity---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
846 Node *RShiftINode::Identity( PhaseTransform *phase ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
847 const TypeInt *t2 = phase->type(in(2))->isa_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
848 if( !t2 ) return this;
a61af66fc99e Initial load
duke
parents:
diff changeset
849 if ( t2->is_con() && ( t2->get_con() & ( BitsPerInt - 1 ) ) == 0 )
a61af66fc99e Initial load
duke
parents:
diff changeset
850 return in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
851
a61af66fc99e Initial load
duke
parents:
diff changeset
852 // Check for useless sign-masking
a61af66fc99e Initial load
duke
parents:
diff changeset
853 if( in(1)->Opcode() == Op_LShiftI &&
a61af66fc99e Initial load
duke
parents:
diff changeset
854 in(1)->req() == 3 &&
a61af66fc99e Initial load
duke
parents:
diff changeset
855 in(1)->in(2) == in(2) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
856 t2->is_con() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
857 uint shift = t2->get_con();
a61af66fc99e Initial load
duke
parents:
diff changeset
858 shift &= BitsPerJavaInteger-1; // semantics of Java shifts
a61af66fc99e Initial load
duke
parents:
diff changeset
859 // Compute masks for which this shifting doesn't change
a61af66fc99e Initial load
duke
parents:
diff changeset
860 int lo = (-1 << (BitsPerJavaInteger - shift-1)); // FFFF8000
a61af66fc99e Initial load
duke
parents:
diff changeset
861 int hi = ~lo; // 00007FFF
a61af66fc99e Initial load
duke
parents:
diff changeset
862 const TypeInt *t11 = phase->type(in(1)->in(1))->isa_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
863 if( !t11 ) return this;
a61af66fc99e Initial load
duke
parents:
diff changeset
864 // Does actual value fit inside of mask?
a61af66fc99e Initial load
duke
parents:
diff changeset
865 if( lo <= t11->_lo && t11->_hi <= hi )
a61af66fc99e Initial load
duke
parents:
diff changeset
866 return in(1)->in(1); // Then shifting is a nop
a61af66fc99e Initial load
duke
parents:
diff changeset
867 }
a61af66fc99e Initial load
duke
parents:
diff changeset
868
a61af66fc99e Initial load
duke
parents:
diff changeset
869 return this;
a61af66fc99e Initial load
duke
parents:
diff changeset
870 }
a61af66fc99e Initial load
duke
parents:
diff changeset
871
a61af66fc99e Initial load
duke
parents:
diff changeset
872 //------------------------------Ideal------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
873 Node *RShiftINode::Ideal(PhaseGVN *phase, bool can_reshape) {
a61af66fc99e Initial load
duke
parents:
diff changeset
874 // Inputs may be TOP if they are dead.
a61af66fc99e Initial load
duke
parents:
diff changeset
875 const TypeInt *t1 = phase->type( in(1) )->isa_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
876 if( !t1 ) return NULL; // Left input is an integer
a61af66fc99e Initial load
duke
parents:
diff changeset
877 const TypeInt *t2 = phase->type( in(2) )->isa_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
878 if( !t2 || !t2->is_con() ) return NULL; // Right input is a constant
a61af66fc99e Initial load
duke
parents:
diff changeset
879 const TypeInt *t3; // type of in(1).in(2)
a61af66fc99e Initial load
duke
parents:
diff changeset
880 int shift = t2->get_con();
a61af66fc99e Initial load
duke
parents:
diff changeset
881 shift &= BitsPerJavaInteger-1; // semantics of Java shifts
a61af66fc99e Initial load
duke
parents:
diff changeset
882
a61af66fc99e Initial load
duke
parents:
diff changeset
883 if ( shift == 0 ) return NULL; // let Identity() handle 0 shift count
a61af66fc99e Initial load
duke
parents:
diff changeset
884
a61af66fc99e Initial load
duke
parents:
diff changeset
885 // Check for (x & 0xFF000000) >> 24, whose mask can be made smaller.
a61af66fc99e Initial load
duke
parents:
diff changeset
886 // Such expressions arise normally from shift chains like (byte)(x >> 24).
a61af66fc99e Initial load
duke
parents:
diff changeset
887 const Node *mask = in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
888 if( mask->Opcode() == Op_AndI &&
a61af66fc99e Initial load
duke
parents:
diff changeset
889 (t3 = phase->type(mask->in(2))->isa_int()) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
890 t3->is_con() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
891 Node *x = mask->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
892 jint maskbits = t3->get_con();
a61af66fc99e Initial load
duke
parents:
diff changeset
893 // Convert to "(x >> shift) & (mask >> shift)"
a61af66fc99e Initial load
duke
parents:
diff changeset
894 Node *shr_nomask = phase->transform( new (phase->C, 3) RShiftINode(mask->in(1), in(2)) );
a61af66fc99e Initial load
duke
parents:
diff changeset
895 return new (phase->C, 3) AndINode(shr_nomask, phase->intcon( maskbits >> shift));
a61af66fc99e Initial load
duke
parents:
diff changeset
896 }
a61af66fc99e Initial load
duke
parents:
diff changeset
897
a61af66fc99e Initial load
duke
parents:
diff changeset
898 // Check for "(short[i] <<16)>>16" which simply sign-extends
a61af66fc99e Initial load
duke
parents:
diff changeset
899 const Node *shl = in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
900 if( shl->Opcode() != Op_LShiftI ) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
901
a61af66fc99e Initial load
duke
parents:
diff changeset
902 if( shift == 16 &&
a61af66fc99e Initial load
duke
parents:
diff changeset
903 (t3 = phase->type(shl->in(2))->isa_int()) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
904 t3->is_con(16) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
905 Node *ld = shl->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
906 if( ld->Opcode() == Op_LoadS ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
907 // Sign extension is just useless here. Return a RShiftI of zero instead
a61af66fc99e Initial load
duke
parents:
diff changeset
908 // returning 'ld' directly. We cannot return an old Node directly as
a61af66fc99e Initial load
duke
parents:
diff changeset
909 // that is the job of 'Identity' calls and Identity calls only work on
a61af66fc99e Initial load
duke
parents:
diff changeset
910 // direct inputs ('ld' is an extra Node removed from 'this'). The
a61af66fc99e Initial load
duke
parents:
diff changeset
911 // combined optimization requires Identity only return direct inputs.
a61af66fc99e Initial load
duke
parents:
diff changeset
912 set_req(1, ld);
a61af66fc99e Initial load
duke
parents:
diff changeset
913 set_req(2, phase->intcon(0));
a61af66fc99e Initial load
duke
parents:
diff changeset
914 return this;
a61af66fc99e Initial load
duke
parents:
diff changeset
915 }
a61af66fc99e Initial load
duke
parents:
diff changeset
916 else if( ld->Opcode() == Op_LoadC )
a61af66fc99e Initial load
duke
parents:
diff changeset
917 // Replace zero-extension-load with sign-extension-load
a61af66fc99e Initial load
duke
parents:
diff changeset
918 return new (phase->C, 3) LoadSNode( ld->in(MemNode::Control),
a61af66fc99e Initial load
duke
parents:
diff changeset
919 ld->in(MemNode::Memory),
a61af66fc99e Initial load
duke
parents:
diff changeset
920 ld->in(MemNode::Address),
a61af66fc99e Initial load
duke
parents:
diff changeset
921 ld->adr_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 // Check for "(byte[i] <<24)>>24" which simply sign-extends
a61af66fc99e Initial load
duke
parents:
diff changeset
925 if( shift == 24 &&
a61af66fc99e Initial load
duke
parents:
diff changeset
926 (t3 = phase->type(shl->in(2))->isa_int()) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
927 t3->is_con(24) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
928 Node *ld = shl->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
929 if( ld->Opcode() == Op_LoadB ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
930 // Sign extension is just useless here
a61af66fc99e Initial load
duke
parents:
diff changeset
931 set_req(1, ld);
a61af66fc99e Initial load
duke
parents:
diff changeset
932 set_req(2, phase->intcon(0));
a61af66fc99e Initial load
duke
parents:
diff changeset
933 return this;
a61af66fc99e Initial load
duke
parents:
diff changeset
934 }
a61af66fc99e Initial load
duke
parents:
diff changeset
935 }
a61af66fc99e Initial load
duke
parents:
diff changeset
936
a61af66fc99e Initial load
duke
parents:
diff changeset
937 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
938 }
a61af66fc99e Initial load
duke
parents:
diff changeset
939
a61af66fc99e Initial load
duke
parents:
diff changeset
940 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
941 // A RShiftINode shifts its input2 right by input1 amount.
a61af66fc99e Initial load
duke
parents:
diff changeset
942 const Type *RShiftINode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
943 const Type *t1 = phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
944 const Type *t2 = phase->type( in(2) );
a61af66fc99e Initial load
duke
parents:
diff changeset
945 // Either input is TOP ==> the result is TOP
a61af66fc99e Initial load
duke
parents:
diff changeset
946 if( t1 == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
947 if( t2 == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
948
a61af66fc99e Initial load
duke
parents:
diff changeset
949 // Left input is ZERO ==> the result is ZERO.
a61af66fc99e Initial load
duke
parents:
diff changeset
950 if( t1 == TypeInt::ZERO ) return TypeInt::ZERO;
a61af66fc99e Initial load
duke
parents:
diff changeset
951 // Shift by zero does nothing
a61af66fc99e Initial load
duke
parents:
diff changeset
952 if( t2 == TypeInt::ZERO ) return t1;
a61af66fc99e Initial load
duke
parents:
diff changeset
953
a61af66fc99e Initial load
duke
parents:
diff changeset
954 // Either input is BOTTOM ==> the result is BOTTOM
a61af66fc99e Initial load
duke
parents:
diff changeset
955 if (t1 == Type::BOTTOM || t2 == Type::BOTTOM)
a61af66fc99e Initial load
duke
parents:
diff changeset
956 return TypeInt::INT;
a61af66fc99e Initial load
duke
parents:
diff changeset
957
a61af66fc99e Initial load
duke
parents:
diff changeset
958 if (t2 == TypeInt::INT)
a61af66fc99e Initial load
duke
parents:
diff changeset
959 return TypeInt::INT;
a61af66fc99e Initial load
duke
parents:
diff changeset
960
a61af66fc99e Initial load
duke
parents:
diff changeset
961 const TypeInt *r1 = t1->is_int(); // Handy access
a61af66fc99e Initial load
duke
parents:
diff changeset
962 const TypeInt *r2 = t2->is_int(); // Handy access
a61af66fc99e Initial load
duke
parents:
diff changeset
963
a61af66fc99e Initial load
duke
parents:
diff changeset
964 // If the shift is a constant, just shift the bounds of the type.
a61af66fc99e Initial load
duke
parents:
diff changeset
965 // For example, if the shift is 31, we just propagate sign bits.
a61af66fc99e Initial load
duke
parents:
diff changeset
966 if (r2->is_con()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
967 uint shift = r2->get_con();
a61af66fc99e Initial load
duke
parents:
diff changeset
968 shift &= BitsPerJavaInteger-1; // semantics of Java shifts
a61af66fc99e Initial load
duke
parents:
diff changeset
969 // Shift by a multiple of 32 does nothing:
a61af66fc99e Initial load
duke
parents:
diff changeset
970 if (shift == 0) return t1;
a61af66fc99e Initial load
duke
parents:
diff changeset
971 // Calculate reasonably aggressive bounds for the result.
a61af66fc99e Initial load
duke
parents:
diff changeset
972 // This is necessary if we are to correctly type things
a61af66fc99e Initial load
duke
parents:
diff changeset
973 // like (x<<24>>24) == ((byte)x).
a61af66fc99e Initial load
duke
parents:
diff changeset
974 jint lo = (jint)r1->_lo >> (jint)shift;
a61af66fc99e Initial load
duke
parents:
diff changeset
975 jint hi = (jint)r1->_hi >> (jint)shift;
a61af66fc99e Initial load
duke
parents:
diff changeset
976 assert(lo <= hi, "must have valid bounds");
a61af66fc99e Initial load
duke
parents:
diff changeset
977 const TypeInt* ti = TypeInt::make(lo, hi, MAX2(r1->_widen,r2->_widen));
a61af66fc99e Initial load
duke
parents:
diff changeset
978 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
979 // Make sure we get the sign-capture idiom correct.
a61af66fc99e Initial load
duke
parents:
diff changeset
980 if (shift == BitsPerJavaInteger-1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
981 if (r1->_lo >= 0) assert(ti == TypeInt::ZERO, ">>31 of + is 0");
a61af66fc99e Initial load
duke
parents:
diff changeset
982 if (r1->_hi < 0) assert(ti == TypeInt::MINUS_1, ">>31 of - is -1");
a61af66fc99e Initial load
duke
parents:
diff changeset
983 }
a61af66fc99e Initial load
duke
parents:
diff changeset
984 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
985 return ti;
a61af66fc99e Initial load
duke
parents:
diff changeset
986 }
a61af66fc99e Initial load
duke
parents:
diff changeset
987
a61af66fc99e Initial load
duke
parents:
diff changeset
988 if( !r1->is_con() || !r2->is_con() )
a61af66fc99e Initial load
duke
parents:
diff changeset
989 return TypeInt::INT;
a61af66fc99e Initial load
duke
parents:
diff changeset
990
a61af66fc99e Initial load
duke
parents:
diff changeset
991 // Signed shift right
a61af66fc99e Initial load
duke
parents:
diff changeset
992 return TypeInt::make( r1->get_con() >> (r2->get_con()&31) );
a61af66fc99e Initial load
duke
parents:
diff changeset
993 }
a61af66fc99e Initial load
duke
parents:
diff changeset
994
a61af66fc99e Initial load
duke
parents:
diff changeset
995 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
996 //------------------------------Identity---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
997 Node *RShiftLNode::Identity( PhaseTransform *phase ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
998 const TypeInt *ti = phase->type( in(2) )->isa_int(); // shift count is an int
a61af66fc99e Initial load
duke
parents:
diff changeset
999 return ( ti && ti->is_con() && ( ti->get_con() & ( BitsPerLong - 1 ) ) == 0 ) ? in(1) : this;
a61af66fc99e Initial load
duke
parents:
diff changeset
1000 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1001
a61af66fc99e Initial load
duke
parents:
diff changeset
1002 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1003 // A RShiftLNode shifts its input2 right by input1 amount.
a61af66fc99e Initial load
duke
parents:
diff changeset
1004 const Type *RShiftLNode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
1005 const Type *t1 = phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
1006 const Type *t2 = phase->type( in(2) );
a61af66fc99e Initial load
duke
parents:
diff changeset
1007 // Either input is TOP ==> the result is TOP
a61af66fc99e Initial load
duke
parents:
diff changeset
1008 if( t1 == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
1009 if( t2 == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
1010
a61af66fc99e Initial load
duke
parents:
diff changeset
1011 // Left input is ZERO ==> the result is ZERO.
a61af66fc99e Initial load
duke
parents:
diff changeset
1012 if( t1 == TypeLong::ZERO ) return TypeLong::ZERO;
a61af66fc99e Initial load
duke
parents:
diff changeset
1013 // Shift by zero does nothing
a61af66fc99e Initial load
duke
parents:
diff changeset
1014 if( t2 == TypeInt::ZERO ) return t1;
a61af66fc99e Initial load
duke
parents:
diff changeset
1015
a61af66fc99e Initial load
duke
parents:
diff changeset
1016 // Either input is BOTTOM ==> the result is BOTTOM
a61af66fc99e Initial load
duke
parents:
diff changeset
1017 if (t1 == Type::BOTTOM || t2 == Type::BOTTOM)
a61af66fc99e Initial load
duke
parents:
diff changeset
1018 return TypeLong::LONG;
a61af66fc99e Initial load
duke
parents:
diff changeset
1019
a61af66fc99e Initial load
duke
parents:
diff changeset
1020 if (t2 == TypeInt::INT)
a61af66fc99e Initial load
duke
parents:
diff changeset
1021 return TypeLong::LONG;
a61af66fc99e Initial load
duke
parents:
diff changeset
1022
a61af66fc99e Initial load
duke
parents:
diff changeset
1023 const TypeLong *r1 = t1->is_long(); // Handy access
a61af66fc99e Initial load
duke
parents:
diff changeset
1024 const TypeInt *r2 = t2->is_int (); // Handy access
a61af66fc99e Initial load
duke
parents:
diff changeset
1025
a61af66fc99e Initial load
duke
parents:
diff changeset
1026 // If the shift is a constant, just shift the bounds of the type.
a61af66fc99e Initial load
duke
parents:
diff changeset
1027 // For example, if the shift is 63, we just propagate sign bits.
a61af66fc99e Initial load
duke
parents:
diff changeset
1028 if (r2->is_con()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1029 uint shift = r2->get_con();
a61af66fc99e Initial load
duke
parents:
diff changeset
1030 shift &= (2*BitsPerJavaInteger)-1; // semantics of Java shifts
a61af66fc99e Initial load
duke
parents:
diff changeset
1031 // Shift by a multiple of 64 does nothing:
a61af66fc99e Initial load
duke
parents:
diff changeset
1032 if (shift == 0) return t1;
a61af66fc99e Initial load
duke
parents:
diff changeset
1033 // Calculate reasonably aggressive bounds for the result.
a61af66fc99e Initial load
duke
parents:
diff changeset
1034 // This is necessary if we are to correctly type things
a61af66fc99e Initial load
duke
parents:
diff changeset
1035 // like (x<<24>>24) == ((byte)x).
a61af66fc99e Initial load
duke
parents:
diff changeset
1036 jlong lo = (jlong)r1->_lo >> (jlong)shift;
a61af66fc99e Initial load
duke
parents:
diff changeset
1037 jlong hi = (jlong)r1->_hi >> (jlong)shift;
a61af66fc99e Initial load
duke
parents:
diff changeset
1038 assert(lo <= hi, "must have valid bounds");
a61af66fc99e Initial load
duke
parents:
diff changeset
1039 const TypeLong* tl = TypeLong::make(lo, hi, MAX2(r1->_widen,r2->_widen));
a61af66fc99e Initial load
duke
parents:
diff changeset
1040 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
1041 // Make sure we get the sign-capture idiom correct.
a61af66fc99e Initial load
duke
parents:
diff changeset
1042 if (shift == (2*BitsPerJavaInteger)-1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1043 if (r1->_lo >= 0) assert(tl == TypeLong::ZERO, ">>63 of + is 0");
a61af66fc99e Initial load
duke
parents:
diff changeset
1044 if (r1->_hi < 0) assert(tl == TypeLong::MINUS_1, ">>63 of - is -1");
a61af66fc99e Initial load
duke
parents:
diff changeset
1045 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1046 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1047 return tl;
a61af66fc99e Initial load
duke
parents:
diff changeset
1048 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1049
a61af66fc99e Initial load
duke
parents:
diff changeset
1050 return TypeLong::LONG; // Give up
a61af66fc99e Initial load
duke
parents:
diff changeset
1051 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1052
a61af66fc99e Initial load
duke
parents:
diff changeset
1053 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
1054 //------------------------------Identity---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1055 Node *URShiftINode::Identity( PhaseTransform *phase ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1056 const TypeInt *ti = phase->type( in(2) )->isa_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
1057 if ( ti && ti->is_con() && ( ti->get_con() & ( BitsPerInt - 1 ) ) == 0 ) return in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1058
a61af66fc99e Initial load
duke
parents:
diff changeset
1059 // Check for "((x << LogBytesPerWord) + (wordSize-1)) >> LogBytesPerWord" which is just "x".
a61af66fc99e Initial load
duke
parents:
diff changeset
1060 // Happens during new-array length computation.
a61af66fc99e Initial load
duke
parents:
diff changeset
1061 // Safe if 'x' is in the range [0..(max_int>>LogBytesPerWord)]
a61af66fc99e Initial load
duke
parents:
diff changeset
1062 Node *add = in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1063 if( add->Opcode() == Op_AddI ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1064 const TypeInt *t2 = phase->type(add->in(2))->isa_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
1065 if( t2 && t2->is_con(wordSize - 1) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1066 add->in(1)->Opcode() == Op_LShiftI ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1067 // Check that shift_counts are LogBytesPerWord
a61af66fc99e Initial load
duke
parents:
diff changeset
1068 Node *lshift_count = add->in(1)->in(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1069 const TypeInt *t_lshift_count = phase->type(lshift_count)->isa_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
1070 if( t_lshift_count && t_lshift_count->is_con(LogBytesPerWord) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1071 t_lshift_count == phase->type(in(2)) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1072 Node *x = add->in(1)->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1073 const TypeInt *t_x = phase->type(x)->isa_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
1074 if( t_x != NULL && 0 <= t_x->_lo && t_x->_hi <= (max_jint>>LogBytesPerWord) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1075 return x;
a61af66fc99e Initial load
duke
parents:
diff changeset
1076 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1077 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1078 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1079 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1080
a61af66fc99e Initial load
duke
parents:
diff changeset
1081 return (phase->type(in(2))->higher_equal(TypeInt::ZERO)) ? in(1) : this;
a61af66fc99e Initial load
duke
parents:
diff changeset
1082 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1083
a61af66fc99e Initial load
duke
parents:
diff changeset
1084 //------------------------------Ideal------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1085 Node *URShiftINode::Ideal(PhaseGVN *phase, bool can_reshape) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1086 const TypeInt *t2 = phase->type( in(2) )->isa_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
1087 if( !t2 || !t2->is_con() ) return NULL; // Right input is a constant
a61af66fc99e Initial load
duke
parents:
diff changeset
1088 const int con = t2->get_con() & 31; // Shift count is always masked
a61af66fc99e Initial load
duke
parents:
diff changeset
1089 if ( con == 0 ) return NULL; // let Identity() handle a 0 shift count
a61af66fc99e Initial load
duke
parents:
diff changeset
1090 // We'll be wanting the right-shift amount as a mask of that many bits
a61af66fc99e Initial load
duke
parents:
diff changeset
1091 const int mask = right_n_bits(BitsPerJavaInteger - con);
a61af66fc99e Initial load
duke
parents:
diff changeset
1092
a61af66fc99e Initial load
duke
parents:
diff changeset
1093 int in1_op = in(1)->Opcode();
a61af66fc99e Initial load
duke
parents:
diff changeset
1094
a61af66fc99e Initial load
duke
parents:
diff changeset
1095 // Check for ((x>>>a)>>>b) and replace with (x>>>(a+b)) when a+b < 32
a61af66fc99e Initial load
duke
parents:
diff changeset
1096 if( in1_op == Op_URShiftI ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1097 const TypeInt *t12 = phase->type( in(1)->in(2) )->isa_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
1098 if( t12 && t12->is_con() ) { // Right input is a constant
a61af66fc99e Initial load
duke
parents:
diff changeset
1099 assert( in(1) != in(1)->in(1), "dead loop in URShiftINode::Ideal" );
a61af66fc99e Initial load
duke
parents:
diff changeset
1100 const int con2 = t12->get_con() & 31; // Shift count is always masked
a61af66fc99e Initial load
duke
parents:
diff changeset
1101 const int con3 = con+con2;
a61af66fc99e Initial load
duke
parents:
diff changeset
1102 if( con3 < 32 ) // Only merge shifts if total is < 32
a61af66fc99e Initial load
duke
parents:
diff changeset
1103 return new (phase->C, 3) URShiftINode( in(1)->in(1), phase->intcon(con3) );
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 // Check for ((x << z) + Y) >>> z. Replace with x + con>>>z
a61af66fc99e Initial load
duke
parents:
diff changeset
1108 // The idiom for rounding to a power of 2 is "(Q+(2^z-1)) >>> z".
a61af66fc99e Initial load
duke
parents:
diff changeset
1109 // If Q is "X << z" the rounding is useless. Look for patterns like
a61af66fc99e Initial load
duke
parents:
diff changeset
1110 // ((X<<Z) + Y) >>> Z and replace with (X + Y>>>Z) & Z-mask.
a61af66fc99e Initial load
duke
parents:
diff changeset
1111 Node *add = in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1112 if( in1_op == Op_AddI ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1113 Node *lshl = add->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1114 if( lshl->Opcode() == Op_LShiftI &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1115 phase->type(lshl->in(2)) == t2 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1116 Node *y_z = phase->transform( new (phase->C, 3) URShiftINode(add->in(2),in(2)) );
a61af66fc99e Initial load
duke
parents:
diff changeset
1117 Node *sum = phase->transform( new (phase->C, 3) AddINode( lshl->in(1), y_z ) );
a61af66fc99e Initial load
duke
parents:
diff changeset
1118 return new (phase->C, 3) AndINode( sum, phase->intcon(mask) );
a61af66fc99e Initial load
duke
parents:
diff changeset
1119 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1121
a61af66fc99e Initial load
duke
parents:
diff changeset
1122 // Check for (x & mask) >>> z. Replace with (x >>> z) & (mask >>> z)
a61af66fc99e Initial load
duke
parents:
diff changeset
1123 // This shortens the mask. Also, if we are extracting a high byte and
a61af66fc99e Initial load
duke
parents:
diff changeset
1124 // storing it to a buffer, the mask will be removed completely.
a61af66fc99e Initial load
duke
parents:
diff changeset
1125 Node *andi = in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1126 if( in1_op == Op_AndI ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1127 const TypeInt *t3 = phase->type( andi->in(2) )->isa_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
1128 if( t3 && t3->is_con() ) { // Right input is a constant
a61af66fc99e Initial load
duke
parents:
diff changeset
1129 jint mask2 = t3->get_con();
a61af66fc99e Initial load
duke
parents:
diff changeset
1130 mask2 >>= con; // *signed* shift downward (high-order zeroes do not help)
a61af66fc99e Initial load
duke
parents:
diff changeset
1131 Node *newshr = phase->transform( new (phase->C, 3) URShiftINode(andi->in(1), in(2)) );
a61af66fc99e Initial load
duke
parents:
diff changeset
1132 return new (phase->C, 3) AndINode(newshr, phase->intcon(mask2));
a61af66fc99e Initial load
duke
parents:
diff changeset
1133 // The negative values are easier to materialize than positive ones.
a61af66fc99e Initial load
duke
parents:
diff changeset
1134 // A typical case from address arithmetic is ((x & ~15) >> 4).
a61af66fc99e Initial load
duke
parents:
diff changeset
1135 // It's better to change that to ((x >> 4) & ~0) versus
a61af66fc99e Initial load
duke
parents:
diff changeset
1136 // ((x >> 4) & 0x0FFFFFFF). The difference is greatest in LP64.
a61af66fc99e Initial load
duke
parents:
diff changeset
1137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1138 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1139
a61af66fc99e Initial load
duke
parents:
diff changeset
1140 // Check for "(X << z ) >>> z" which simply zero-extends
a61af66fc99e Initial load
duke
parents:
diff changeset
1141 Node *shl = in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1142 if( in1_op == Op_LShiftI &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1143 phase->type(shl->in(2)) == t2 )
a61af66fc99e Initial load
duke
parents:
diff changeset
1144 return new (phase->C, 3) AndINode( shl->in(1), phase->intcon(mask) );
a61af66fc99e Initial load
duke
parents:
diff changeset
1145
a61af66fc99e Initial load
duke
parents:
diff changeset
1146 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1147 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1148
a61af66fc99e Initial load
duke
parents:
diff changeset
1149 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1150 // A URShiftINode shifts its input2 right by input1 amount.
a61af66fc99e Initial load
duke
parents:
diff changeset
1151 const Type *URShiftINode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
1152 // (This is a near clone of RShiftINode::Value.)
a61af66fc99e Initial load
duke
parents:
diff changeset
1153 const Type *t1 = phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
1154 const Type *t2 = phase->type( in(2) );
a61af66fc99e Initial load
duke
parents:
diff changeset
1155 // Either input is TOP ==> the result is TOP
a61af66fc99e Initial load
duke
parents:
diff changeset
1156 if( t1 == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
1157 if( t2 == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
1158
a61af66fc99e Initial load
duke
parents:
diff changeset
1159 // Left input is ZERO ==> the result is ZERO.
a61af66fc99e Initial load
duke
parents:
diff changeset
1160 if( t1 == TypeInt::ZERO ) return TypeInt::ZERO;
a61af66fc99e Initial load
duke
parents:
diff changeset
1161 // Shift by zero does nothing
a61af66fc99e Initial load
duke
parents:
diff changeset
1162 if( t2 == TypeInt::ZERO ) return t1;
a61af66fc99e Initial load
duke
parents:
diff changeset
1163
a61af66fc99e Initial load
duke
parents:
diff changeset
1164 // Either input is BOTTOM ==> the result is BOTTOM
a61af66fc99e Initial load
duke
parents:
diff changeset
1165 if (t1 == Type::BOTTOM || t2 == Type::BOTTOM)
a61af66fc99e Initial load
duke
parents:
diff changeset
1166 return TypeInt::INT;
a61af66fc99e Initial load
duke
parents:
diff changeset
1167
a61af66fc99e Initial load
duke
parents:
diff changeset
1168 if (t2 == TypeInt::INT)
a61af66fc99e Initial load
duke
parents:
diff changeset
1169 return TypeInt::INT;
a61af66fc99e Initial load
duke
parents:
diff changeset
1170
a61af66fc99e Initial load
duke
parents:
diff changeset
1171 const TypeInt *r1 = t1->is_int(); // Handy access
a61af66fc99e Initial load
duke
parents:
diff changeset
1172 const TypeInt *r2 = t2->is_int(); // Handy access
a61af66fc99e Initial load
duke
parents:
diff changeset
1173
a61af66fc99e Initial load
duke
parents:
diff changeset
1174 if (r2->is_con()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1175 uint shift = r2->get_con();
a61af66fc99e Initial load
duke
parents:
diff changeset
1176 shift &= BitsPerJavaInteger-1; // semantics of Java shifts
a61af66fc99e Initial load
duke
parents:
diff changeset
1177 // Shift by a multiple of 32 does nothing:
a61af66fc99e Initial load
duke
parents:
diff changeset
1178 if (shift == 0) return t1;
a61af66fc99e Initial load
duke
parents:
diff changeset
1179 // Calculate reasonably aggressive bounds for the result.
a61af66fc99e Initial load
duke
parents:
diff changeset
1180 jint lo = (juint)r1->_lo >> (juint)shift;
a61af66fc99e Initial load
duke
parents:
diff changeset
1181 jint hi = (juint)r1->_hi >> (juint)shift;
a61af66fc99e Initial load
duke
parents:
diff changeset
1182 if (r1->_hi >= 0 && r1->_lo < 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1183 // If the type has both negative and positive values,
a61af66fc99e Initial load
duke
parents:
diff changeset
1184 // there are two separate sub-domains to worry about:
a61af66fc99e Initial load
duke
parents:
diff changeset
1185 // The positive half and the negative half.
a61af66fc99e Initial load
duke
parents:
diff changeset
1186 jint neg_lo = lo;
a61af66fc99e Initial load
duke
parents:
diff changeset
1187 jint neg_hi = (juint)-1 >> (juint)shift;
a61af66fc99e Initial load
duke
parents:
diff changeset
1188 jint pos_lo = (juint) 0 >> (juint)shift;
a61af66fc99e Initial load
duke
parents:
diff changeset
1189 jint pos_hi = hi;
a61af66fc99e Initial load
duke
parents:
diff changeset
1190 lo = MIN2(neg_lo, pos_lo); // == 0
a61af66fc99e Initial load
duke
parents:
diff changeset
1191 hi = MAX2(neg_hi, pos_hi); // == -1 >>> shift;
a61af66fc99e Initial load
duke
parents:
diff changeset
1192 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1193 assert(lo <= hi, "must have valid bounds");
a61af66fc99e Initial load
duke
parents:
diff changeset
1194 const TypeInt* ti = TypeInt::make(lo, hi, MAX2(r1->_widen,r2->_widen));
a61af66fc99e Initial load
duke
parents:
diff changeset
1195 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
1196 // Make sure we get the sign-capture idiom correct.
a61af66fc99e Initial load
duke
parents:
diff changeset
1197 if (shift == BitsPerJavaInteger-1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1198 if (r1->_lo >= 0) assert(ti == TypeInt::ZERO, ">>>31 of + is 0");
a61af66fc99e Initial load
duke
parents:
diff changeset
1199 if (r1->_hi < 0) assert(ti == TypeInt::ONE, ">>>31 of - is +1");
a61af66fc99e Initial load
duke
parents:
diff changeset
1200 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1201 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1202 return ti;
a61af66fc99e Initial load
duke
parents:
diff changeset
1203 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1204
a61af66fc99e Initial load
duke
parents:
diff changeset
1205 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1206 // Do not support shifted oops in info for GC
a61af66fc99e Initial load
duke
parents:
diff changeset
1207 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1208 // else if( t1->base() == Type::InstPtr ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1209 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1210 // const TypeInstPtr *o = t1->is_instptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1211 // if( t1->singleton() )
a61af66fc99e Initial load
duke
parents:
diff changeset
1212 // return TypeInt::make( ((uint32)o->const_oop() + o->_offset) >> shift );
a61af66fc99e Initial load
duke
parents:
diff changeset
1213 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
1214 // else if( t1->base() == Type::KlassPtr ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1215 // const TypeKlassPtr *o = t1->is_klassptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1216 // if( t1->singleton() )
a61af66fc99e Initial load
duke
parents:
diff changeset
1217 // return TypeInt::make( ((uint32)o->const_oop() + o->_offset) >> shift );
a61af66fc99e Initial load
duke
parents:
diff changeset
1218 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
1219
a61af66fc99e Initial load
duke
parents:
diff changeset
1220 return TypeInt::INT;
a61af66fc99e Initial load
duke
parents:
diff changeset
1221 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1222
a61af66fc99e Initial load
duke
parents:
diff changeset
1223 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
1224 //------------------------------Identity---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1225 Node *URShiftLNode::Identity( PhaseTransform *phase ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1226 const TypeInt *ti = phase->type( in(2) )->isa_int(); // shift count is an int
a61af66fc99e Initial load
duke
parents:
diff changeset
1227 return ( ti && ti->is_con() && ( ti->get_con() & ( BitsPerLong - 1 ) ) == 0 ) ? in(1) : this;
a61af66fc99e Initial load
duke
parents:
diff changeset
1228 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1229
a61af66fc99e Initial load
duke
parents:
diff changeset
1230 //------------------------------Ideal------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1231 Node *URShiftLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1232 const TypeInt *t2 = phase->type( in(2) )->isa_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
1233 if( !t2 || !t2->is_con() ) return NULL; // Right input is a constant
a61af66fc99e Initial load
duke
parents:
diff changeset
1234 const int con = t2->get_con() & ( BitsPerLong - 1 ); // Shift count is always masked
a61af66fc99e Initial load
duke
parents:
diff changeset
1235 if ( con == 0 ) return NULL; // let Identity() handle a 0 shift count
a61af66fc99e Initial load
duke
parents:
diff changeset
1236 // note: mask computation below does not work for 0 shift count
a61af66fc99e Initial load
duke
parents:
diff changeset
1237 // We'll be wanting the right-shift amount as a mask of that many bits
a61af66fc99e Initial load
duke
parents:
diff changeset
1238 const jlong mask = (((jlong)CONST64(1) << (jlong)(BitsPerJavaInteger*2 - con)) -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1239
a61af66fc99e Initial load
duke
parents:
diff changeset
1240 // Check for ((x << z) + Y) >>> z. Replace with x + con>>>z
a61af66fc99e Initial load
duke
parents:
diff changeset
1241 // The idiom for rounding to a power of 2 is "(Q+(2^z-1)) >>> z".
a61af66fc99e Initial load
duke
parents:
diff changeset
1242 // If Q is "X << z" the rounding is useless. Look for patterns like
a61af66fc99e Initial load
duke
parents:
diff changeset
1243 // ((X<<Z) + Y) >>> Z and replace with (X + Y>>>Z) & Z-mask.
a61af66fc99e Initial load
duke
parents:
diff changeset
1244 Node *add = in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1245 if( add->Opcode() == Op_AddL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1246 Node *lshl = add->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1247 if( lshl->Opcode() == Op_LShiftL &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1248 phase->type(lshl->in(2)) == t2 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1249 Node *y_z = phase->transform( new (phase->C, 3) URShiftLNode(add->in(2),in(2)) );
a61af66fc99e Initial load
duke
parents:
diff changeset
1250 Node *sum = phase->transform( new (phase->C, 3) AddLNode( lshl->in(1), y_z ) );
a61af66fc99e Initial load
duke
parents:
diff changeset
1251 return new (phase->C, 3) AndLNode( sum, phase->longcon(mask) );
a61af66fc99e Initial load
duke
parents:
diff changeset
1252 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1253 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1254
a61af66fc99e Initial load
duke
parents:
diff changeset
1255 // Check for (x & mask) >>> z. Replace with (x >>> z) & (mask >>> z)
a61af66fc99e Initial load
duke
parents:
diff changeset
1256 // This shortens the mask. Also, if we are extracting a high byte and
a61af66fc99e Initial load
duke
parents:
diff changeset
1257 // storing it to a buffer, the mask will be removed completely.
a61af66fc99e Initial load
duke
parents:
diff changeset
1258 Node *andi = in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1259 if( andi->Opcode() == Op_AndL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1260 const TypeLong *t3 = phase->type( andi->in(2) )->isa_long();
a61af66fc99e Initial load
duke
parents:
diff changeset
1261 if( t3 && t3->is_con() ) { // Right input is a constant
a61af66fc99e Initial load
duke
parents:
diff changeset
1262 jlong mask2 = t3->get_con();
a61af66fc99e Initial load
duke
parents:
diff changeset
1263 mask2 >>= con; // *signed* shift downward (high-order zeroes do not help)
a61af66fc99e Initial load
duke
parents:
diff changeset
1264 Node *newshr = phase->transform( new (phase->C, 3) URShiftLNode(andi->in(1), in(2)) );
a61af66fc99e Initial load
duke
parents:
diff changeset
1265 return new (phase->C, 3) AndLNode(newshr, phase->longcon(mask2));
a61af66fc99e Initial load
duke
parents:
diff changeset
1266 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1268
a61af66fc99e Initial load
duke
parents:
diff changeset
1269 // Check for "(X << z ) >>> z" which simply zero-extends
a61af66fc99e Initial load
duke
parents:
diff changeset
1270 Node *shl = in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1271 if( shl->Opcode() == Op_LShiftL &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1272 phase->type(shl->in(2)) == t2 )
a61af66fc99e Initial load
duke
parents:
diff changeset
1273 return new (phase->C, 3) AndLNode( shl->in(1), phase->longcon(mask) );
a61af66fc99e Initial load
duke
parents:
diff changeset
1274
a61af66fc99e Initial load
duke
parents:
diff changeset
1275 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1276 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1277
a61af66fc99e Initial load
duke
parents:
diff changeset
1278 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
1279 // A URShiftINode shifts its input2 right by input1 amount.
a61af66fc99e Initial load
duke
parents:
diff changeset
1280 const Type *URShiftLNode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
1281 // (This is a near clone of RShiftLNode::Value.)
a61af66fc99e Initial load
duke
parents:
diff changeset
1282 const Type *t1 = phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
1283 const Type *t2 = phase->type( in(2) );
a61af66fc99e Initial load
duke
parents:
diff changeset
1284 // Either input is TOP ==> the result is TOP
a61af66fc99e Initial load
duke
parents:
diff changeset
1285 if( t1 == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
1286 if( t2 == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
1287
a61af66fc99e Initial load
duke
parents:
diff changeset
1288 // Left input is ZERO ==> the result is ZERO.
a61af66fc99e Initial load
duke
parents:
diff changeset
1289 if( t1 == TypeLong::ZERO ) return TypeLong::ZERO;
a61af66fc99e Initial load
duke
parents:
diff changeset
1290 // Shift by zero does nothing
a61af66fc99e Initial load
duke
parents:
diff changeset
1291 if( t2 == TypeInt::ZERO ) return t1;
a61af66fc99e Initial load
duke
parents:
diff changeset
1292
a61af66fc99e Initial load
duke
parents:
diff changeset
1293 // Either input is BOTTOM ==> the result is BOTTOM
a61af66fc99e Initial load
duke
parents:
diff changeset
1294 if (t1 == Type::BOTTOM || t2 == Type::BOTTOM)
a61af66fc99e Initial load
duke
parents:
diff changeset
1295 return TypeLong::LONG;
a61af66fc99e Initial load
duke
parents:
diff changeset
1296
a61af66fc99e Initial load
duke
parents:
diff changeset
1297 if (t2 == TypeInt::INT)
a61af66fc99e Initial load
duke
parents:
diff changeset
1298 return TypeLong::LONG;
a61af66fc99e Initial load
duke
parents:
diff changeset
1299
a61af66fc99e Initial load
duke
parents:
diff changeset
1300 const TypeLong *r1 = t1->is_long(); // Handy access
a61af66fc99e Initial load
duke
parents:
diff changeset
1301 const TypeInt *r2 = t2->is_int (); // Handy access
a61af66fc99e Initial load
duke
parents:
diff changeset
1302
a61af66fc99e Initial load
duke
parents:
diff changeset
1303 if (r2->is_con()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1304 uint shift = r2->get_con();
a61af66fc99e Initial load
duke
parents:
diff changeset
1305 shift &= (2*BitsPerJavaInteger)-1; // semantics of Java shifts
a61af66fc99e Initial load
duke
parents:
diff changeset
1306 // Shift by a multiple of 64 does nothing:
a61af66fc99e Initial load
duke
parents:
diff changeset
1307 if (shift == 0) return t1;
a61af66fc99e Initial load
duke
parents:
diff changeset
1308 // Calculate reasonably aggressive bounds for the result.
a61af66fc99e Initial load
duke
parents:
diff changeset
1309 jlong lo = (julong)r1->_lo >> (juint)shift;
a61af66fc99e Initial load
duke
parents:
diff changeset
1310 jlong hi = (julong)r1->_hi >> (juint)shift;
a61af66fc99e Initial load
duke
parents:
diff changeset
1311 if (r1->_hi >= 0 && r1->_lo < 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1312 // If the type has both negative and positive values,
a61af66fc99e Initial load
duke
parents:
diff changeset
1313 // there are two separate sub-domains to worry about:
a61af66fc99e Initial load
duke
parents:
diff changeset
1314 // The positive half and the negative half.
a61af66fc99e Initial load
duke
parents:
diff changeset
1315 jlong neg_lo = lo;
a61af66fc99e Initial load
duke
parents:
diff changeset
1316 jlong neg_hi = (julong)-1 >> (juint)shift;
a61af66fc99e Initial load
duke
parents:
diff changeset
1317 jlong pos_lo = (julong) 0 >> (juint)shift;
a61af66fc99e Initial load
duke
parents:
diff changeset
1318 jlong pos_hi = hi;
a61af66fc99e Initial load
duke
parents:
diff changeset
1319 //lo = MIN2(neg_lo, pos_lo); // == 0
a61af66fc99e Initial load
duke
parents:
diff changeset
1320 lo = neg_lo < pos_lo ? neg_lo : pos_lo;
a61af66fc99e Initial load
duke
parents:
diff changeset
1321 //hi = MAX2(neg_hi, pos_hi); // == -1 >>> shift;
a61af66fc99e Initial load
duke
parents:
diff changeset
1322 hi = neg_hi > pos_hi ? neg_hi : pos_hi;
a61af66fc99e Initial load
duke
parents:
diff changeset
1323 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1324 assert(lo <= hi, "must have valid bounds");
a61af66fc99e Initial load
duke
parents:
diff changeset
1325 const TypeLong* tl = TypeLong::make(lo, hi, MAX2(r1->_widen,r2->_widen));
a61af66fc99e Initial load
duke
parents:
diff changeset
1326 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
1327 // Make sure we get the sign-capture idiom correct.
a61af66fc99e Initial load
duke
parents:
diff changeset
1328 if (shift == (2*BitsPerJavaInteger)-1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1329 if (r1->_lo >= 0) assert(tl == TypeLong::ZERO, ">>>63 of + is 0");
a61af66fc99e Initial load
duke
parents:
diff changeset
1330 if (r1->_hi < 0) assert(tl == TypeLong::ONE, ">>>63 of - is +1");
a61af66fc99e Initial load
duke
parents:
diff changeset
1331 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1332 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1333 return tl;
a61af66fc99e Initial load
duke
parents:
diff changeset
1334 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1335
a61af66fc99e Initial load
duke
parents:
diff changeset
1336 return TypeLong::LONG; // Give up
a61af66fc99e Initial load
duke
parents:
diff changeset
1337 }