1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/opto/mulnode.cpp Wed Apr 27 01:25:04 2016 +0800 1.3 @@ -0,0 +1,1355 @@ 1.4 +/* 1.5 + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#include "precompiled.hpp" 1.29 +#include "memory/allocation.inline.hpp" 1.30 +#include "opto/addnode.hpp" 1.31 +#include "opto/connode.hpp" 1.32 +#include "opto/memnode.hpp" 1.33 +#include "opto/mulnode.hpp" 1.34 +#include "opto/phaseX.hpp" 1.35 +#include "opto/subnode.hpp" 1.36 + 1.37 +// Portions of code courtesy of Clifford Click 1.38 + 1.39 + 1.40 +//============================================================================= 1.41 +//------------------------------hash------------------------------------------- 1.42 +// Hash function over MulNodes. Needs to be commutative; i.e., I swap 1.43 +// (commute) inputs to MulNodes willy-nilly so the hash function must return 1.44 +// the same value in the presence of edge swapping. 1.45 +uint MulNode::hash() const { 1.46 + return (uintptr_t)in(1) + (uintptr_t)in(2) + Opcode(); 1.47 +} 1.48 + 1.49 +//------------------------------Identity--------------------------------------- 1.50 +// Multiplying a one preserves the other argument 1.51 +Node *MulNode::Identity( PhaseTransform *phase ) { 1.52 + register const Type *one = mul_id(); // The multiplicative identity 1.53 + if( phase->type( in(1) )->higher_equal( one ) ) return in(2); 1.54 + if( phase->type( in(2) )->higher_equal( one ) ) return in(1); 1.55 + 1.56 + return this; 1.57 +} 1.58 + 1.59 +//------------------------------Ideal------------------------------------------ 1.60 +// We also canonicalize the Node, moving constants to the right input, 1.61 +// and flatten expressions (so that 1+x+2 becomes x+3). 1.62 +Node *MulNode::Ideal(PhaseGVN *phase, bool can_reshape) { 1.63 + const Type *t1 = phase->type( in(1) ); 1.64 + const Type *t2 = phase->type( in(2) ); 1.65 + Node *progress = NULL; // Progress flag 1.66 + // We are OK if right is a constant, or right is a load and 1.67 + // left is a non-constant. 1.68 + if( !(t2->singleton() || 1.69 + (in(2)->is_Load() && !(t1->singleton() || in(1)->is_Load())) ) ) { 1.70 + if( t1->singleton() || // Left input is a constant? 1.71 + // Otherwise, sort inputs (commutativity) to help value numbering. 1.72 + (in(1)->_idx > in(2)->_idx) ) { 1.73 + swap_edges(1, 2); 1.74 + const Type *t = t1; 1.75 + t1 = t2; 1.76 + t2 = t; 1.77 + progress = this; // Made progress 1.78 + } 1.79 + } 1.80 + 1.81 + // If the right input is a constant, and the left input is a product of a 1.82 + // constant, flatten the expression tree. 1.83 + uint op = Opcode(); 1.84 + if( t2->singleton() && // Right input is a constant? 1.85 + op != Op_MulF && // Float & double cannot reassociate 1.86 + op != Op_MulD ) { 1.87 + if( t2 == Type::TOP ) return NULL; 1.88 + Node *mul1 = in(1); 1.89 +#ifdef ASSERT 1.90 + // Check for dead loop 1.91 + int op1 = mul1->Opcode(); 1.92 + if( phase->eqv( mul1, this ) || phase->eqv( in(2), this ) || 1.93 + ( op1 == mul_opcode() || op1 == add_opcode() ) && 1.94 + ( phase->eqv( mul1->in(1), this ) || phase->eqv( mul1->in(2), this ) || 1.95 + phase->eqv( mul1->in(1), mul1 ) || phase->eqv( mul1->in(2), mul1 ) ) ) 1.96 + assert(false, "dead loop in MulNode::Ideal"); 1.97 +#endif 1.98 + 1.99 + if( mul1->Opcode() == mul_opcode() ) { // Left input is a multiply? 1.100 + // Mul of a constant? 1.101 + const Type *t12 = phase->type( mul1->in(2) ); 1.102 + if( t12->singleton() && t12 != Type::TOP) { // Left input is an add of a constant? 1.103 + // Compute new constant; check for overflow 1.104 + const Type *tcon01 = ((MulNode*)mul1)->mul_ring(t2,t12); 1.105 + if( tcon01->singleton() ) { 1.106 + // The Mul of the flattened expression 1.107 + set_req(1, mul1->in(1)); 1.108 + set_req(2, phase->makecon( tcon01 )); 1.109 + t2 = tcon01; 1.110 + progress = this; // Made progress 1.111 + } 1.112 + } 1.113 + } 1.114 + // If the right input is a constant, and the left input is an add of a 1.115 + // constant, flatten the tree: (X+con1)*con0 ==> X*con0 + con1*con0 1.116 + const Node *add1 = in(1); 1.117 + if( add1->Opcode() == add_opcode() ) { // Left input is an add? 1.118 + // Add of a constant? 1.119 + const Type *t12 = phase->type( add1->in(2) ); 1.120 + if( t12->singleton() && t12 != Type::TOP ) { // Left input is an add of a constant? 1.121 + assert( add1->in(1) != add1, "dead loop in MulNode::Ideal" ); 1.122 + // Compute new constant; check for overflow 1.123 + const Type *tcon01 = mul_ring(t2,t12); 1.124 + if( tcon01->singleton() ) { 1.125 + 1.126 + // Convert (X+con1)*con0 into X*con0 1.127 + Node *mul = clone(); // mul = ()*con0 1.128 + mul->set_req(1,add1->in(1)); // mul = X*con0 1.129 + mul = phase->transform(mul); 1.130 + 1.131 + Node *add2 = add1->clone(); 1.132 + add2->set_req(1, mul); // X*con0 + con0*con1 1.133 + add2->set_req(2, phase->makecon(tcon01) ); 1.134 + progress = add2; 1.135 + } 1.136 + } 1.137 + } // End of is left input an add 1.138 + } // End of is right input a Mul 1.139 + 1.140 + return progress; 1.141 +} 1.142 + 1.143 +//------------------------------Value----------------------------------------- 1.144 +const Type *MulNode::Value( PhaseTransform *phase ) const { 1.145 + const Type *t1 = phase->type( in(1) ); 1.146 + const Type *t2 = phase->type( in(2) ); 1.147 + // Either input is TOP ==> the result is TOP 1.148 + if( t1 == Type::TOP ) return Type::TOP; 1.149 + if( t2 == Type::TOP ) return Type::TOP; 1.150 + 1.151 + // Either input is ZERO ==> the result is ZERO. 1.152 + // Not valid for floats or doubles since +0.0 * -0.0 --> +0.0 1.153 + int op = Opcode(); 1.154 + if( op == Op_MulI || op == Op_AndI || op == Op_MulL || op == Op_AndL ) { 1.155 + const Type *zero = add_id(); // The multiplicative zero 1.156 + if( t1->higher_equal( zero ) ) return zero; 1.157 + if( t2->higher_equal( zero ) ) return zero; 1.158 + } 1.159 + 1.160 + // Either input is BOTTOM ==> the result is the local BOTTOM 1.161 + if( t1 == Type::BOTTOM || t2 == Type::BOTTOM ) 1.162 + return bottom_type(); 1.163 + 1.164 +#if defined(IA32) 1.165 + // Can't trust native compilers to properly fold strict double 1.166 + // multiplication with round-to-zero on this platform. 1.167 + if (op == Op_MulD && phase->C->method()->is_strict()) { 1.168 + return TypeD::DOUBLE; 1.169 + } 1.170 +#endif 1.171 + 1.172 + return mul_ring(t1,t2); // Local flavor of type multiplication 1.173 +} 1.174 + 1.175 + 1.176 +//============================================================================= 1.177 +//------------------------------Ideal------------------------------------------ 1.178 +// Check for power-of-2 multiply, then try the regular MulNode::Ideal 1.179 +Node *MulINode::Ideal(PhaseGVN *phase, bool can_reshape) { 1.180 + // Swap constant to right 1.181 + jint con; 1.182 + if ((con = in(1)->find_int_con(0)) != 0) { 1.183 + swap_edges(1, 2); 1.184 + // Finish rest of method to use info in 'con' 1.185 + } else if ((con = in(2)->find_int_con(0)) == 0) { 1.186 + return MulNode::Ideal(phase, can_reshape); 1.187 + } 1.188 + 1.189 + // Now we have a constant Node on the right and the constant in con 1.190 + if( con == 0 ) return NULL; // By zero is handled by Value call 1.191 + if( con == 1 ) return NULL; // By one is handled by Identity call 1.192 + 1.193 + // Check for negative constant; if so negate the final result 1.194 + bool sign_flip = false; 1.195 + if( con < 0 ) { 1.196 + con = -con; 1.197 + sign_flip = true; 1.198 + } 1.199 + 1.200 + // Get low bit; check for being the only bit 1.201 + Node *res = NULL; 1.202 + jint bit1 = con & -con; // Extract low bit 1.203 + if( bit1 == con ) { // Found a power of 2? 1.204 + res = new (phase->C) LShiftINode( in(1), phase->intcon(log2_intptr(bit1)) ); 1.205 + } else { 1.206 + 1.207 + // Check for constant with 2 bits set 1.208 + jint bit2 = con-bit1; 1.209 + bit2 = bit2 & -bit2; // Extract 2nd bit 1.210 + if( bit2 + bit1 == con ) { // Found all bits in con? 1.211 + Node *n1 = phase->transform( new (phase->C) LShiftINode( in(1), phase->intcon(log2_intptr(bit1)) ) ); 1.212 + Node *n2 = phase->transform( new (phase->C) LShiftINode( in(1), phase->intcon(log2_intptr(bit2)) ) ); 1.213 + res = new (phase->C) AddINode( n2, n1 ); 1.214 + 1.215 + } else if (is_power_of_2(con+1)) { 1.216 + // Sleezy: power-of-2 -1. Next time be generic. 1.217 + jint temp = (jint) (con + 1); 1.218 + Node *n1 = phase->transform( new (phase->C) LShiftINode( in(1), phase->intcon(log2_intptr(temp)) ) ); 1.219 + res = new (phase->C) SubINode( n1, in(1) ); 1.220 + } else { 1.221 + return MulNode::Ideal(phase, can_reshape); 1.222 + } 1.223 + } 1.224 + 1.225 + if( sign_flip ) { // Need to negate result? 1.226 + res = phase->transform(res);// Transform, before making the zero con 1.227 + res = new (phase->C) SubINode(phase->intcon(0),res); 1.228 + } 1.229 + 1.230 + return res; // Return final result 1.231 +} 1.232 + 1.233 +//------------------------------mul_ring--------------------------------------- 1.234 +// Compute the product type of two integer ranges into this node. 1.235 +const Type *MulINode::mul_ring(const Type *t0, const Type *t1) const { 1.236 + const TypeInt *r0 = t0->is_int(); // Handy access 1.237 + const TypeInt *r1 = t1->is_int(); 1.238 + 1.239 + // Fetch endpoints of all ranges 1.240 + int32 lo0 = r0->_lo; 1.241 + double a = (double)lo0; 1.242 + int32 hi0 = r0->_hi; 1.243 + double b = (double)hi0; 1.244 + int32 lo1 = r1->_lo; 1.245 + double c = (double)lo1; 1.246 + int32 hi1 = r1->_hi; 1.247 + double d = (double)hi1; 1.248 + 1.249 + // Compute all endpoints & check for overflow 1.250 + int32 A = lo0*lo1; 1.251 + if( (double)A != a*c ) return TypeInt::INT; // Overflow? 1.252 + int32 B = lo0*hi1; 1.253 + if( (double)B != a*d ) return TypeInt::INT; // Overflow? 1.254 + int32 C = hi0*lo1; 1.255 + if( (double)C != b*c ) return TypeInt::INT; // Overflow? 1.256 + int32 D = hi0*hi1; 1.257 + if( (double)D != b*d ) return TypeInt::INT; // Overflow? 1.258 + 1.259 + if( A < B ) { lo0 = A; hi0 = B; } // Sort range endpoints 1.260 + else { lo0 = B; hi0 = A; } 1.261 + if( C < D ) { 1.262 + if( C < lo0 ) lo0 = C; 1.263 + if( D > hi0 ) hi0 = D; 1.264 + } else { 1.265 + if( D < lo0 ) lo0 = D; 1.266 + if( C > hi0 ) hi0 = C; 1.267 + } 1.268 + return TypeInt::make(lo0, hi0, MAX2(r0->_widen,r1->_widen)); 1.269 +} 1.270 + 1.271 + 1.272 +//============================================================================= 1.273 +//------------------------------Ideal------------------------------------------ 1.274 +// Check for power-of-2 multiply, then try the regular MulNode::Ideal 1.275 +Node *MulLNode::Ideal(PhaseGVN *phase, bool can_reshape) { 1.276 + // Swap constant to right 1.277 + jlong con; 1.278 + if ((con = in(1)->find_long_con(0)) != 0) { 1.279 + swap_edges(1, 2); 1.280 + // Finish rest of method to use info in 'con' 1.281 + } else if ((con = in(2)->find_long_con(0)) == 0) { 1.282 + return MulNode::Ideal(phase, can_reshape); 1.283 + } 1.284 + 1.285 + // Now we have a constant Node on the right and the constant in con 1.286 + if( con == CONST64(0) ) return NULL; // By zero is handled by Value call 1.287 + if( con == CONST64(1) ) return NULL; // By one is handled by Identity call 1.288 + 1.289 + // Check for negative constant; if so negate the final result 1.290 + bool sign_flip = false; 1.291 + if( con < 0 ) { 1.292 + con = -con; 1.293 + sign_flip = true; 1.294 + } 1.295 + 1.296 + // Get low bit; check for being the only bit 1.297 + Node *res = NULL; 1.298 + jlong bit1 = con & -con; // Extract low bit 1.299 + if( bit1 == con ) { // Found a power of 2? 1.300 + res = new (phase->C) LShiftLNode( in(1), phase->intcon(log2_long(bit1)) ); 1.301 + } else { 1.302 + 1.303 + // Check for constant with 2 bits set 1.304 + jlong bit2 = con-bit1; 1.305 + bit2 = bit2 & -bit2; // Extract 2nd bit 1.306 + if( bit2 + bit1 == con ) { // Found all bits in con? 1.307 + Node *n1 = phase->transform( new (phase->C) LShiftLNode( in(1), phase->intcon(log2_long(bit1)) ) ); 1.308 + Node *n2 = phase->transform( new (phase->C) LShiftLNode( in(1), phase->intcon(log2_long(bit2)) ) ); 1.309 + res = new (phase->C) AddLNode( n2, n1 ); 1.310 + 1.311 + } else if (is_power_of_2_long(con+1)) { 1.312 + // Sleezy: power-of-2 -1. Next time be generic. 1.313 + jlong temp = (jlong) (con + 1); 1.314 + Node *n1 = phase->transform( new (phase->C) LShiftLNode( in(1), phase->intcon(log2_long(temp)) ) ); 1.315 + res = new (phase->C) SubLNode( n1, in(1) ); 1.316 + } else { 1.317 + return MulNode::Ideal(phase, can_reshape); 1.318 + } 1.319 + } 1.320 + 1.321 + if( sign_flip ) { // Need to negate result? 1.322 + res = phase->transform(res);// Transform, before making the zero con 1.323 + res = new (phase->C) SubLNode(phase->longcon(0),res); 1.324 + } 1.325 + 1.326 + return res; // Return final result 1.327 +} 1.328 + 1.329 +//------------------------------mul_ring--------------------------------------- 1.330 +// Compute the product type of two integer ranges into this node. 1.331 +const Type *MulLNode::mul_ring(const Type *t0, const Type *t1) const { 1.332 + const TypeLong *r0 = t0->is_long(); // Handy access 1.333 + const TypeLong *r1 = t1->is_long(); 1.334 + 1.335 + // Fetch endpoints of all ranges 1.336 + jlong lo0 = r0->_lo; 1.337 + double a = (double)lo0; 1.338 + jlong hi0 = r0->_hi; 1.339 + double b = (double)hi0; 1.340 + jlong lo1 = r1->_lo; 1.341 + double c = (double)lo1; 1.342 + jlong hi1 = r1->_hi; 1.343 + double d = (double)hi1; 1.344 + 1.345 + // Compute all endpoints & check for overflow 1.346 + jlong A = lo0*lo1; 1.347 + if( (double)A != a*c ) return TypeLong::LONG; // Overflow? 1.348 + jlong B = lo0*hi1; 1.349 + if( (double)B != a*d ) return TypeLong::LONG; // Overflow? 1.350 + jlong C = hi0*lo1; 1.351 + if( (double)C != b*c ) return TypeLong::LONG; // Overflow? 1.352 + jlong D = hi0*hi1; 1.353 + if( (double)D != b*d ) return TypeLong::LONG; // Overflow? 1.354 + 1.355 + if( A < B ) { lo0 = A; hi0 = B; } // Sort range endpoints 1.356 + else { lo0 = B; hi0 = A; } 1.357 + if( C < D ) { 1.358 + if( C < lo0 ) lo0 = C; 1.359 + if( D > hi0 ) hi0 = D; 1.360 + } else { 1.361 + if( D < lo0 ) lo0 = D; 1.362 + if( C > hi0 ) hi0 = C; 1.363 + } 1.364 + return TypeLong::make(lo0, hi0, MAX2(r0->_widen,r1->_widen)); 1.365 +} 1.366 + 1.367 +//============================================================================= 1.368 +//------------------------------mul_ring--------------------------------------- 1.369 +// Compute the product type of two double ranges into this node. 1.370 +const Type *MulFNode::mul_ring(const Type *t0, const Type *t1) const { 1.371 + if( t0 == Type::FLOAT || t1 == Type::FLOAT ) return Type::FLOAT; 1.372 + return TypeF::make( t0->getf() * t1->getf() ); 1.373 +} 1.374 + 1.375 +//============================================================================= 1.376 +//------------------------------mul_ring--------------------------------------- 1.377 +// Compute the product type of two double ranges into this node. 1.378 +const Type *MulDNode::mul_ring(const Type *t0, const Type *t1) const { 1.379 + if( t0 == Type::DOUBLE || t1 == Type::DOUBLE ) return Type::DOUBLE; 1.380 + // We must be multiplying 2 double constants. 1.381 + return TypeD::make( t0->getd() * t1->getd() ); 1.382 +} 1.383 + 1.384 +//============================================================================= 1.385 +//------------------------------Value------------------------------------------ 1.386 +const Type *MulHiLNode::Value( PhaseTransform *phase ) const { 1.387 + // Either input is TOP ==> the result is TOP 1.388 + const Type *t1 = phase->type( in(1) ); 1.389 + const Type *t2 = phase->type( in(2) ); 1.390 + if( t1 == Type::TOP ) return Type::TOP; 1.391 + if( t2 == Type::TOP ) return Type::TOP; 1.392 + 1.393 + // Either input is BOTTOM ==> the result is the local BOTTOM 1.394 + const Type *bot = bottom_type(); 1.395 + if( (t1 == bot) || (t2 == bot) || 1.396 + (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) ) 1.397 + return bot; 1.398 + 1.399 + // It is not worth trying to constant fold this stuff! 1.400 + return TypeLong::LONG; 1.401 +} 1.402 + 1.403 +//============================================================================= 1.404 +//------------------------------mul_ring--------------------------------------- 1.405 +// Supplied function returns the product of the inputs IN THE CURRENT RING. 1.406 +// For the logical operations the ring's MUL is really a logical AND function. 1.407 +// This also type-checks the inputs for sanity. Guaranteed never to 1.408 +// be passed a TOP or BOTTOM type, these are filtered out by pre-check. 1.409 +const Type *AndINode::mul_ring( const Type *t0, const Type *t1 ) const { 1.410 + const TypeInt *r0 = t0->is_int(); // Handy access 1.411 + const TypeInt *r1 = t1->is_int(); 1.412 + int widen = MAX2(r0->_widen,r1->_widen); 1.413 + 1.414 + // If either input is a constant, might be able to trim cases 1.415 + if( !r0->is_con() && !r1->is_con() ) 1.416 + return TypeInt::INT; // No constants to be had 1.417 + 1.418 + // Both constants? Return bits 1.419 + if( r0->is_con() && r1->is_con() ) 1.420 + return TypeInt::make( r0->get_con() & r1->get_con() ); 1.421 + 1.422 + if( r0->is_con() && r0->get_con() > 0 ) 1.423 + return TypeInt::make(0, r0->get_con(), widen); 1.424 + 1.425 + if( r1->is_con() && r1->get_con() > 0 ) 1.426 + return TypeInt::make(0, r1->get_con(), widen); 1.427 + 1.428 + if( r0 == TypeInt::BOOL || r1 == TypeInt::BOOL ) { 1.429 + return TypeInt::BOOL; 1.430 + } 1.431 + 1.432 + return TypeInt::INT; // No constants to be had 1.433 +} 1.434 + 1.435 +//------------------------------Identity--------------------------------------- 1.436 +// Masking off the high bits of an unsigned load is not required 1.437 +Node *AndINode::Identity( PhaseTransform *phase ) { 1.438 + 1.439 + // x & x => x 1.440 + if (phase->eqv(in(1), in(2))) return in(1); 1.441 + 1.442 + Node* in1 = in(1); 1.443 + uint op = in1->Opcode(); 1.444 + const TypeInt* t2 = phase->type(in(2))->isa_int(); 1.445 + if (t2 && t2->is_con()) { 1.446 + int con = t2->get_con(); 1.447 + // Masking off high bits which are always zero is useless. 1.448 + const TypeInt* t1 = phase->type( in(1) )->isa_int(); 1.449 + if (t1 != NULL && t1->_lo >= 0) { 1.450 + jint t1_support = right_n_bits(1 + log2_intptr(t1->_hi)); 1.451 + if ((t1_support & con) == t1_support) 1.452 + return in1; 1.453 + } 1.454 + // Masking off the high bits of a unsigned-shift-right is not 1.455 + // needed either. 1.456 + if (op == Op_URShiftI) { 1.457 + const TypeInt* t12 = phase->type(in1->in(2))->isa_int(); 1.458 + if (t12 && t12->is_con()) { // Shift is by a constant 1.459 + int shift = t12->get_con(); 1.460 + shift &= BitsPerJavaInteger - 1; // semantics of Java shifts 1.461 + int mask = max_juint >> shift; 1.462 + if ((mask & con) == mask) // If AND is useless, skip it 1.463 + return in1; 1.464 + } 1.465 + } 1.466 + } 1.467 + return MulNode::Identity(phase); 1.468 +} 1.469 + 1.470 +//------------------------------Ideal------------------------------------------ 1.471 +Node *AndINode::Ideal(PhaseGVN *phase, bool can_reshape) { 1.472 + // Special case constant AND mask 1.473 + const TypeInt *t2 = phase->type( in(2) )->isa_int(); 1.474 + if( !t2 || !t2->is_con() ) return MulNode::Ideal(phase, can_reshape); 1.475 + const int mask = t2->get_con(); 1.476 + Node *load = in(1); 1.477 + uint lop = load->Opcode(); 1.478 + 1.479 + // Masking bits off of a Character? Hi bits are already zero. 1.480 + if( lop == Op_LoadUS && 1.481 + (mask & 0xFFFF0000) ) // Can we make a smaller mask? 1.482 + return new (phase->C) AndINode(load,phase->intcon(mask&0xFFFF)); 1.483 + 1.484 + // Masking bits off of a Short? Loading a Character does some masking 1.485 + if (can_reshape && 1.486 + load->outcnt() == 1 && load->unique_out() == this) { 1.487 + if (lop == Op_LoadS && (mask & 0xFFFF0000) == 0 ) { 1.488 + Node *ldus = new (phase->C) LoadUSNode(load->in(MemNode::Control), 1.489 + load->in(MemNode::Memory), 1.490 + load->in(MemNode::Address), 1.491 + load->adr_type(), 1.492 + TypeInt::CHAR, MemNode::unordered); 1.493 + ldus = phase->transform(ldus); 1.494 + return new (phase->C) AndINode(ldus, phase->intcon(mask & 0xFFFF)); 1.495 + } 1.496 + 1.497 + // Masking sign bits off of a Byte? Do an unsigned byte load plus 1.498 + // an and. 1.499 + if (lop == Op_LoadB && (mask & 0xFFFFFF00) == 0) { 1.500 + Node* ldub = new (phase->C) LoadUBNode(load->in(MemNode::Control), 1.501 + load->in(MemNode::Memory), 1.502 + load->in(MemNode::Address), 1.503 + load->adr_type(), 1.504 + TypeInt::UBYTE, MemNode::unordered); 1.505 + ldub = phase->transform(ldub); 1.506 + return new (phase->C) AndINode(ldub, phase->intcon(mask)); 1.507 + } 1.508 + } 1.509 + 1.510 + // Masking off sign bits? Dont make them! 1.511 + if( lop == Op_RShiftI ) { 1.512 + const TypeInt *t12 = phase->type(load->in(2))->isa_int(); 1.513 + if( t12 && t12->is_con() ) { // Shift is by a constant 1.514 + int shift = t12->get_con(); 1.515 + shift &= BitsPerJavaInteger-1; // semantics of Java shifts 1.516 + const int sign_bits_mask = ~right_n_bits(BitsPerJavaInteger - shift); 1.517 + // If the AND'ing of the 2 masks has no bits, then only original shifted 1.518 + // bits survive. NO sign-extension bits survive the maskings. 1.519 + if( (sign_bits_mask & mask) == 0 ) { 1.520 + // Use zero-fill shift instead 1.521 + Node *zshift = phase->transform(new (phase->C) URShiftINode(load->in(1),load->in(2))); 1.522 + return new (phase->C) AndINode( zshift, in(2) ); 1.523 + } 1.524 + } 1.525 + } 1.526 + 1.527 + // Check for 'negate/and-1', a pattern emitted when someone asks for 1.528 + // 'mod 2'. Negate leaves the low order bit unchanged (think: complement 1.529 + // plus 1) and the mask is of the low order bit. Skip the negate. 1.530 + if( lop == Op_SubI && mask == 1 && load->in(1) && 1.531 + phase->type(load->in(1)) == TypeInt::ZERO ) 1.532 + return new (phase->C) AndINode( load->in(2), in(2) ); 1.533 + 1.534 + return MulNode::Ideal(phase, can_reshape); 1.535 +} 1.536 + 1.537 +//============================================================================= 1.538 +//------------------------------mul_ring--------------------------------------- 1.539 +// Supplied function returns the product of the inputs IN THE CURRENT RING. 1.540 +// For the logical operations the ring's MUL is really a logical AND function. 1.541 +// This also type-checks the inputs for sanity. Guaranteed never to 1.542 +// be passed a TOP or BOTTOM type, these are filtered out by pre-check. 1.543 +const Type *AndLNode::mul_ring( const Type *t0, const Type *t1 ) const { 1.544 + const TypeLong *r0 = t0->is_long(); // Handy access 1.545 + const TypeLong *r1 = t1->is_long(); 1.546 + int widen = MAX2(r0->_widen,r1->_widen); 1.547 + 1.548 + // If either input is a constant, might be able to trim cases 1.549 + if( !r0->is_con() && !r1->is_con() ) 1.550 + return TypeLong::LONG; // No constants to be had 1.551 + 1.552 + // Both constants? Return bits 1.553 + if( r0->is_con() && r1->is_con() ) 1.554 + return TypeLong::make( r0->get_con() & r1->get_con() ); 1.555 + 1.556 + if( r0->is_con() && r0->get_con() > 0 ) 1.557 + return TypeLong::make(CONST64(0), r0->get_con(), widen); 1.558 + 1.559 + if( r1->is_con() && r1->get_con() > 0 ) 1.560 + return TypeLong::make(CONST64(0), r1->get_con(), widen); 1.561 + 1.562 + return TypeLong::LONG; // No constants to be had 1.563 +} 1.564 + 1.565 +//------------------------------Identity--------------------------------------- 1.566 +// Masking off the high bits of an unsigned load is not required 1.567 +Node *AndLNode::Identity( PhaseTransform *phase ) { 1.568 + 1.569 + // x & x => x 1.570 + if (phase->eqv(in(1), in(2))) return in(1); 1.571 + 1.572 + Node *usr = in(1); 1.573 + const TypeLong *t2 = phase->type( in(2) )->isa_long(); 1.574 + if( t2 && t2->is_con() ) { 1.575 + jlong con = t2->get_con(); 1.576 + // Masking off high bits which are always zero is useless. 1.577 + const TypeLong* t1 = phase->type( in(1) )->isa_long(); 1.578 + if (t1 != NULL && t1->_lo >= 0) { 1.579 + jlong t1_support = ((jlong)1 << (1 + log2_long(t1->_hi))) - 1; 1.580 + if ((t1_support & con) == t1_support) 1.581 + return usr; 1.582 + } 1.583 + uint lop = usr->Opcode(); 1.584 + // Masking off the high bits of a unsigned-shift-right is not 1.585 + // needed either. 1.586 + if( lop == Op_URShiftL ) { 1.587 + const TypeInt *t12 = phase->type( usr->in(2) )->isa_int(); 1.588 + if( t12 && t12->is_con() ) { // Shift is by a constant 1.589 + int shift = t12->get_con(); 1.590 + shift &= BitsPerJavaLong - 1; // semantics of Java shifts 1.591 + jlong mask = max_julong >> shift; 1.592 + if( (mask&con) == mask ) // If AND is useless, skip it 1.593 + return usr; 1.594 + } 1.595 + } 1.596 + } 1.597 + return MulNode::Identity(phase); 1.598 +} 1.599 + 1.600 +//------------------------------Ideal------------------------------------------ 1.601 +Node *AndLNode::Ideal(PhaseGVN *phase, bool can_reshape) { 1.602 + // Special case constant AND mask 1.603 + const TypeLong *t2 = phase->type( in(2) )->isa_long(); 1.604 + if( !t2 || !t2->is_con() ) return MulNode::Ideal(phase, can_reshape); 1.605 + const jlong mask = t2->get_con(); 1.606 + 1.607 + Node* in1 = in(1); 1.608 + uint op = in1->Opcode(); 1.609 + 1.610 + // Are we masking a long that was converted from an int with a mask 1.611 + // that fits in 32-bits? Commute them and use an AndINode. Don't 1.612 + // convert masks which would cause a sign extension of the integer 1.613 + // value. This check includes UI2L masks (0x00000000FFFFFFFF) which 1.614 + // would be optimized away later in Identity. 1.615 + if (op == Op_ConvI2L && (mask & CONST64(0xFFFFFFFF80000000)) == 0) { 1.616 + Node* andi = new (phase->C) AndINode(in1->in(1), phase->intcon(mask)); 1.617 + andi = phase->transform(andi); 1.618 + return new (phase->C) ConvI2LNode(andi); 1.619 + } 1.620 + 1.621 + // Masking off sign bits? Dont make them! 1.622 + if (op == Op_RShiftL) { 1.623 + const TypeInt* t12 = phase->type(in1->in(2))->isa_int(); 1.624 + if( t12 && t12->is_con() ) { // Shift is by a constant 1.625 + int shift = t12->get_con(); 1.626 + shift &= BitsPerJavaLong - 1; // semantics of Java shifts 1.627 + const jlong sign_bits_mask = ~(((jlong)CONST64(1) << (jlong)(BitsPerJavaLong - shift)) -1); 1.628 + // If the AND'ing of the 2 masks has no bits, then only original shifted 1.629 + // bits survive. NO sign-extension bits survive the maskings. 1.630 + if( (sign_bits_mask & mask) == 0 ) { 1.631 + // Use zero-fill shift instead 1.632 + Node *zshift = phase->transform(new (phase->C) URShiftLNode(in1->in(1), in1->in(2))); 1.633 + return new (phase->C) AndLNode(zshift, in(2)); 1.634 + } 1.635 + } 1.636 + } 1.637 + 1.638 + return MulNode::Ideal(phase, can_reshape); 1.639 +} 1.640 + 1.641 +//============================================================================= 1.642 +//------------------------------Identity--------------------------------------- 1.643 +Node *LShiftINode::Identity( PhaseTransform *phase ) { 1.644 + const TypeInt *ti = phase->type( in(2) )->isa_int(); // shift count is an int 1.645 + return ( ti && ti->is_con() && ( ti->get_con() & ( BitsPerInt - 1 ) ) == 0 ) ? in(1) : this; 1.646 +} 1.647 + 1.648 +//------------------------------Ideal------------------------------------------ 1.649 +// If the right input is a constant, and the left input is an add of a 1.650 +// constant, flatten the tree: (X+con1)<<con0 ==> X<<con0 + con1<<con0 1.651 +Node *LShiftINode::Ideal(PhaseGVN *phase, bool can_reshape) { 1.652 + const Type *t = phase->type( in(2) ); 1.653 + if( t == Type::TOP ) return NULL; // Right input is dead 1.654 + const TypeInt *t2 = t->isa_int(); 1.655 + if( !t2 || !t2->is_con() ) return NULL; // Right input is a constant 1.656 + const int con = t2->get_con() & ( BitsPerInt - 1 ); // masked shift count 1.657 + 1.658 + if ( con == 0 ) return NULL; // let Identity() handle 0 shift count 1.659 + 1.660 + // Left input is an add of a constant? 1.661 + Node *add1 = in(1); 1.662 + int add1_op = add1->Opcode(); 1.663 + if( add1_op == Op_AddI ) { // Left input is an add? 1.664 + assert( add1 != add1->in(1), "dead loop in LShiftINode::Ideal" ); 1.665 + const TypeInt *t12 = phase->type(add1->in(2))->isa_int(); 1.666 + if( t12 && t12->is_con() ){ // Left input is an add of a con? 1.667 + // Transform is legal, but check for profit. Avoid breaking 'i2s' 1.668 + // and 'i2b' patterns which typically fold into 'StoreC/StoreB'. 1.669 + if( con < 16 ) { 1.670 + // Compute X << con0 1.671 + Node *lsh = phase->transform( new (phase->C) LShiftINode( add1->in(1), in(2) ) ); 1.672 + // Compute X<<con0 + (con1<<con0) 1.673 + return new (phase->C) AddINode( lsh, phase->intcon(t12->get_con() << con)); 1.674 + } 1.675 + } 1.676 + } 1.677 + 1.678 + // Check for "(x>>c0)<<c0" which just masks off low bits 1.679 + if( (add1_op == Op_RShiftI || add1_op == Op_URShiftI ) && 1.680 + add1->in(2) == in(2) ) 1.681 + // Convert to "(x & -(1<<c0))" 1.682 + return new (phase->C) AndINode(add1->in(1),phase->intcon( -(1<<con))); 1.683 + 1.684 + // Check for "((x>>c0) & Y)<<c0" which just masks off more low bits 1.685 + if( add1_op == Op_AndI ) { 1.686 + Node *add2 = add1->in(1); 1.687 + int add2_op = add2->Opcode(); 1.688 + if( (add2_op == Op_RShiftI || add2_op == Op_URShiftI ) && 1.689 + add2->in(2) == in(2) ) { 1.690 + // Convert to "(x & (Y<<c0))" 1.691 + Node *y_sh = phase->transform( new (phase->C) LShiftINode( add1->in(2), in(2) ) ); 1.692 + return new (phase->C) AndINode( add2->in(1), y_sh ); 1.693 + } 1.694 + } 1.695 + 1.696 + // Check for ((x & ((1<<(32-c0))-1)) << c0) which ANDs off high bits 1.697 + // before shifting them away. 1.698 + const jint bits_mask = right_n_bits(BitsPerJavaInteger-con); 1.699 + if( add1_op == Op_AndI && 1.700 + phase->type(add1->in(2)) == TypeInt::make( bits_mask ) ) 1.701 + return new (phase->C) LShiftINode( add1->in(1), in(2) ); 1.702 + 1.703 + return NULL; 1.704 +} 1.705 + 1.706 +//------------------------------Value------------------------------------------ 1.707 +// A LShiftINode shifts its input2 left by input1 amount. 1.708 +const Type *LShiftINode::Value( PhaseTransform *phase ) const { 1.709 + const Type *t1 = phase->type( in(1) ); 1.710 + const Type *t2 = phase->type( in(2) ); 1.711 + // Either input is TOP ==> the result is TOP 1.712 + if( t1 == Type::TOP ) return Type::TOP; 1.713 + if( t2 == Type::TOP ) return Type::TOP; 1.714 + 1.715 + // Left input is ZERO ==> the result is ZERO. 1.716 + if( t1 == TypeInt::ZERO ) return TypeInt::ZERO; 1.717 + // Shift by zero does nothing 1.718 + if( t2 == TypeInt::ZERO ) return t1; 1.719 + 1.720 + // Either input is BOTTOM ==> the result is BOTTOM 1.721 + if( (t1 == TypeInt::INT) || (t2 == TypeInt::INT) || 1.722 + (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) ) 1.723 + return TypeInt::INT; 1.724 + 1.725 + const TypeInt *r1 = t1->is_int(); // Handy access 1.726 + const TypeInt *r2 = t2->is_int(); // Handy access 1.727 + 1.728 + if (!r2->is_con()) 1.729 + return TypeInt::INT; 1.730 + 1.731 + uint shift = r2->get_con(); 1.732 + shift &= BitsPerJavaInteger-1; // semantics of Java shifts 1.733 + // Shift by a multiple of 32 does nothing: 1.734 + if (shift == 0) return t1; 1.735 + 1.736 + // If the shift is a constant, shift the bounds of the type, 1.737 + // unless this could lead to an overflow. 1.738 + if (!r1->is_con()) { 1.739 + jint lo = r1->_lo, hi = r1->_hi; 1.740 + if (((lo << shift) >> shift) == lo && 1.741 + ((hi << shift) >> shift) == hi) { 1.742 + // No overflow. The range shifts up cleanly. 1.743 + return TypeInt::make((jint)lo << (jint)shift, 1.744 + (jint)hi << (jint)shift, 1.745 + MAX2(r1->_widen,r2->_widen)); 1.746 + } 1.747 + return TypeInt::INT; 1.748 + } 1.749 + 1.750 + return TypeInt::make( (jint)r1->get_con() << (jint)shift ); 1.751 +} 1.752 + 1.753 +//============================================================================= 1.754 +//------------------------------Identity--------------------------------------- 1.755 +Node *LShiftLNode::Identity( PhaseTransform *phase ) { 1.756 + const TypeInt *ti = phase->type( in(2) )->isa_int(); // shift count is an int 1.757 + return ( ti && ti->is_con() && ( ti->get_con() & ( BitsPerLong - 1 ) ) == 0 ) ? in(1) : this; 1.758 +} 1.759 + 1.760 +//------------------------------Ideal------------------------------------------ 1.761 +// If the right input is a constant, and the left input is an add of a 1.762 +// constant, flatten the tree: (X+con1)<<con0 ==> X<<con0 + con1<<con0 1.763 +Node *LShiftLNode::Ideal(PhaseGVN *phase, bool can_reshape) { 1.764 + const Type *t = phase->type( in(2) ); 1.765 + if( t == Type::TOP ) return NULL; // Right input is dead 1.766 + const TypeInt *t2 = t->isa_int(); 1.767 + if( !t2 || !t2->is_con() ) return NULL; // Right input is a constant 1.768 + const int con = t2->get_con() & ( BitsPerLong - 1 ); // masked shift count 1.769 + 1.770 + if ( con == 0 ) return NULL; // let Identity() handle 0 shift count 1.771 + 1.772 + // Left input is an add of a constant? 1.773 + Node *add1 = in(1); 1.774 + int add1_op = add1->Opcode(); 1.775 + if( add1_op == Op_AddL ) { // Left input is an add? 1.776 + // Avoid dead data cycles from dead loops 1.777 + assert( add1 != add1->in(1), "dead loop in LShiftLNode::Ideal" ); 1.778 + const TypeLong *t12 = phase->type(add1->in(2))->isa_long(); 1.779 + if( t12 && t12->is_con() ){ // Left input is an add of a con? 1.780 + // Compute X << con0 1.781 + Node *lsh = phase->transform( new (phase->C) LShiftLNode( add1->in(1), in(2) ) ); 1.782 + // Compute X<<con0 + (con1<<con0) 1.783 + return new (phase->C) AddLNode( lsh, phase->longcon(t12->get_con() << con)); 1.784 + } 1.785 + } 1.786 + 1.787 + // Check for "(x>>c0)<<c0" which just masks off low bits 1.788 + if( (add1_op == Op_RShiftL || add1_op == Op_URShiftL ) && 1.789 + add1->in(2) == in(2) ) 1.790 + // Convert to "(x & -(1<<c0))" 1.791 + return new (phase->C) AndLNode(add1->in(1),phase->longcon( -(CONST64(1)<<con))); 1.792 + 1.793 + // Check for "((x>>c0) & Y)<<c0" which just masks off more low bits 1.794 + if( add1_op == Op_AndL ) { 1.795 + Node *add2 = add1->in(1); 1.796 + int add2_op = add2->Opcode(); 1.797 + if( (add2_op == Op_RShiftL || add2_op == Op_URShiftL ) && 1.798 + add2->in(2) == in(2) ) { 1.799 + // Convert to "(x & (Y<<c0))" 1.800 + Node *y_sh = phase->transform( new (phase->C) LShiftLNode( add1->in(2), in(2) ) ); 1.801 + return new (phase->C) AndLNode( add2->in(1), y_sh ); 1.802 + } 1.803 + } 1.804 + 1.805 + // Check for ((x & ((CONST64(1)<<(64-c0))-1)) << c0) which ANDs off high bits 1.806 + // before shifting them away. 1.807 + const jlong bits_mask = ((jlong)CONST64(1) << (jlong)(BitsPerJavaLong - con)) - CONST64(1); 1.808 + if( add1_op == Op_AndL && 1.809 + phase->type(add1->in(2)) == TypeLong::make( bits_mask ) ) 1.810 + return new (phase->C) LShiftLNode( add1->in(1), in(2) ); 1.811 + 1.812 + return NULL; 1.813 +} 1.814 + 1.815 +//------------------------------Value------------------------------------------ 1.816 +// A LShiftLNode shifts its input2 left by input1 amount. 1.817 +const Type *LShiftLNode::Value( PhaseTransform *phase ) const { 1.818 + const Type *t1 = phase->type( in(1) ); 1.819 + const Type *t2 = phase->type( in(2) ); 1.820 + // Either input is TOP ==> the result is TOP 1.821 + if( t1 == Type::TOP ) return Type::TOP; 1.822 + if( t2 == Type::TOP ) return Type::TOP; 1.823 + 1.824 + // Left input is ZERO ==> the result is ZERO. 1.825 + if( t1 == TypeLong::ZERO ) return TypeLong::ZERO; 1.826 + // Shift by zero does nothing 1.827 + if( t2 == TypeInt::ZERO ) return t1; 1.828 + 1.829 + // Either input is BOTTOM ==> the result is BOTTOM 1.830 + if( (t1 == TypeLong::LONG) || (t2 == TypeInt::INT) || 1.831 + (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) ) 1.832 + return TypeLong::LONG; 1.833 + 1.834 + const TypeLong *r1 = t1->is_long(); // Handy access 1.835 + const TypeInt *r2 = t2->is_int(); // Handy access 1.836 + 1.837 + if (!r2->is_con()) 1.838 + return TypeLong::LONG; 1.839 + 1.840 + uint shift = r2->get_con(); 1.841 + shift &= BitsPerJavaLong - 1; // semantics of Java shifts 1.842 + // Shift by a multiple of 64 does nothing: 1.843 + if (shift == 0) return t1; 1.844 + 1.845 + // If the shift is a constant, shift the bounds of the type, 1.846 + // unless this could lead to an overflow. 1.847 + if (!r1->is_con()) { 1.848 + jlong lo = r1->_lo, hi = r1->_hi; 1.849 + if (((lo << shift) >> shift) == lo && 1.850 + ((hi << shift) >> shift) == hi) { 1.851 + // No overflow. The range shifts up cleanly. 1.852 + return TypeLong::make((jlong)lo << (jint)shift, 1.853 + (jlong)hi << (jint)shift, 1.854 + MAX2(r1->_widen,r2->_widen)); 1.855 + } 1.856 + return TypeLong::LONG; 1.857 + } 1.858 + 1.859 + return TypeLong::make( (jlong)r1->get_con() << (jint)shift ); 1.860 +} 1.861 + 1.862 +//============================================================================= 1.863 +//------------------------------Identity--------------------------------------- 1.864 +Node *RShiftINode::Identity( PhaseTransform *phase ) { 1.865 + const TypeInt *t2 = phase->type(in(2))->isa_int(); 1.866 + if( !t2 ) return this; 1.867 + if ( t2->is_con() && ( t2->get_con() & ( BitsPerInt - 1 ) ) == 0 ) 1.868 + return in(1); 1.869 + 1.870 + // Check for useless sign-masking 1.871 + if( in(1)->Opcode() == Op_LShiftI && 1.872 + in(1)->req() == 3 && 1.873 + in(1)->in(2) == in(2) && 1.874 + t2->is_con() ) { 1.875 + uint shift = t2->get_con(); 1.876 + shift &= BitsPerJavaInteger-1; // semantics of Java shifts 1.877 + // Compute masks for which this shifting doesn't change 1.878 + int lo = (-1 << (BitsPerJavaInteger - shift-1)); // FFFF8000 1.879 + int hi = ~lo; // 00007FFF 1.880 + const TypeInt *t11 = phase->type(in(1)->in(1))->isa_int(); 1.881 + if( !t11 ) return this; 1.882 + // Does actual value fit inside of mask? 1.883 + if( lo <= t11->_lo && t11->_hi <= hi ) 1.884 + return in(1)->in(1); // Then shifting is a nop 1.885 + } 1.886 + 1.887 + return this; 1.888 +} 1.889 + 1.890 +//------------------------------Ideal------------------------------------------ 1.891 +Node *RShiftINode::Ideal(PhaseGVN *phase, bool can_reshape) { 1.892 + // Inputs may be TOP if they are dead. 1.893 + const TypeInt *t1 = phase->type( in(1) )->isa_int(); 1.894 + if( !t1 ) return NULL; // Left input is an integer 1.895 + const TypeInt *t2 = phase->type( in(2) )->isa_int(); 1.896 + if( !t2 || !t2->is_con() ) return NULL; // Right input is a constant 1.897 + const TypeInt *t3; // type of in(1).in(2) 1.898 + int shift = t2->get_con(); 1.899 + shift &= BitsPerJavaInteger-1; // semantics of Java shifts 1.900 + 1.901 + if ( shift == 0 ) return NULL; // let Identity() handle 0 shift count 1.902 + 1.903 + // Check for (x & 0xFF000000) >> 24, whose mask can be made smaller. 1.904 + // Such expressions arise normally from shift chains like (byte)(x >> 24). 1.905 + const Node *mask = in(1); 1.906 + if( mask->Opcode() == Op_AndI && 1.907 + (t3 = phase->type(mask->in(2))->isa_int()) && 1.908 + t3->is_con() ) { 1.909 + Node *x = mask->in(1); 1.910 + jint maskbits = t3->get_con(); 1.911 + // Convert to "(x >> shift) & (mask >> shift)" 1.912 + Node *shr_nomask = phase->transform( new (phase->C) RShiftINode(mask->in(1), in(2)) ); 1.913 + return new (phase->C) AndINode(shr_nomask, phase->intcon( maskbits >> shift)); 1.914 + } 1.915 + 1.916 + // Check for "(short[i] <<16)>>16" which simply sign-extends 1.917 + const Node *shl = in(1); 1.918 + if( shl->Opcode() != Op_LShiftI ) return NULL; 1.919 + 1.920 + if( shift == 16 && 1.921 + (t3 = phase->type(shl->in(2))->isa_int()) && 1.922 + t3->is_con(16) ) { 1.923 + Node *ld = shl->in(1); 1.924 + if( ld->Opcode() == Op_LoadS ) { 1.925 + // Sign extension is just useless here. Return a RShiftI of zero instead 1.926 + // returning 'ld' directly. We cannot return an old Node directly as 1.927 + // that is the job of 'Identity' calls and Identity calls only work on 1.928 + // direct inputs ('ld' is an extra Node removed from 'this'). The 1.929 + // combined optimization requires Identity only return direct inputs. 1.930 + set_req(1, ld); 1.931 + set_req(2, phase->intcon(0)); 1.932 + return this; 1.933 + } 1.934 + else if( can_reshape && 1.935 + ld->Opcode() == Op_LoadUS && 1.936 + ld->outcnt() == 1 && ld->unique_out() == shl) 1.937 + // Replace zero-extension-load with sign-extension-load 1.938 + return new (phase->C) LoadSNode( ld->in(MemNode::Control), 1.939 + ld->in(MemNode::Memory), 1.940 + ld->in(MemNode::Address), 1.941 + ld->adr_type(), TypeInt::SHORT, 1.942 + MemNode::unordered); 1.943 + } 1.944 + 1.945 + // Check for "(byte[i] <<24)>>24" which simply sign-extends 1.946 + if( shift == 24 && 1.947 + (t3 = phase->type(shl->in(2))->isa_int()) && 1.948 + t3->is_con(24) ) { 1.949 + Node *ld = shl->in(1); 1.950 + if( ld->Opcode() == Op_LoadB ) { 1.951 + // Sign extension is just useless here 1.952 + set_req(1, ld); 1.953 + set_req(2, phase->intcon(0)); 1.954 + return this; 1.955 + } 1.956 + } 1.957 + 1.958 + return NULL; 1.959 +} 1.960 + 1.961 +//------------------------------Value------------------------------------------ 1.962 +// A RShiftINode shifts its input2 right by input1 amount. 1.963 +const Type *RShiftINode::Value( PhaseTransform *phase ) const { 1.964 + const Type *t1 = phase->type( in(1) ); 1.965 + const Type *t2 = phase->type( in(2) ); 1.966 + // Either input is TOP ==> the result is TOP 1.967 + if( t1 == Type::TOP ) return Type::TOP; 1.968 + if( t2 == Type::TOP ) return Type::TOP; 1.969 + 1.970 + // Left input is ZERO ==> the result is ZERO. 1.971 + if( t1 == TypeInt::ZERO ) return TypeInt::ZERO; 1.972 + // Shift by zero does nothing 1.973 + if( t2 == TypeInt::ZERO ) return t1; 1.974 + 1.975 + // Either input is BOTTOM ==> the result is BOTTOM 1.976 + if (t1 == Type::BOTTOM || t2 == Type::BOTTOM) 1.977 + return TypeInt::INT; 1.978 + 1.979 + if (t2 == TypeInt::INT) 1.980 + return TypeInt::INT; 1.981 + 1.982 + const TypeInt *r1 = t1->is_int(); // Handy access 1.983 + const TypeInt *r2 = t2->is_int(); // Handy access 1.984 + 1.985 + // If the shift is a constant, just shift the bounds of the type. 1.986 + // For example, if the shift is 31, we just propagate sign bits. 1.987 + if (r2->is_con()) { 1.988 + uint shift = r2->get_con(); 1.989 + shift &= BitsPerJavaInteger-1; // semantics of Java shifts 1.990 + // Shift by a multiple of 32 does nothing: 1.991 + if (shift == 0) return t1; 1.992 + // Calculate reasonably aggressive bounds for the result. 1.993 + // This is necessary if we are to correctly type things 1.994 + // like (x<<24>>24) == ((byte)x). 1.995 + jint lo = (jint)r1->_lo >> (jint)shift; 1.996 + jint hi = (jint)r1->_hi >> (jint)shift; 1.997 + assert(lo <= hi, "must have valid bounds"); 1.998 + const TypeInt* ti = TypeInt::make(lo, hi, MAX2(r1->_widen,r2->_widen)); 1.999 +#ifdef ASSERT 1.1000 + // Make sure we get the sign-capture idiom correct. 1.1001 + if (shift == BitsPerJavaInteger-1) { 1.1002 + if (r1->_lo >= 0) assert(ti == TypeInt::ZERO, ">>31 of + is 0"); 1.1003 + if (r1->_hi < 0) assert(ti == TypeInt::MINUS_1, ">>31 of - is -1"); 1.1004 + } 1.1005 +#endif 1.1006 + return ti; 1.1007 + } 1.1008 + 1.1009 + if( !r1->is_con() || !r2->is_con() ) 1.1010 + return TypeInt::INT; 1.1011 + 1.1012 + // Signed shift right 1.1013 + return TypeInt::make( r1->get_con() >> (r2->get_con()&31) ); 1.1014 +} 1.1015 + 1.1016 +//============================================================================= 1.1017 +//------------------------------Identity--------------------------------------- 1.1018 +Node *RShiftLNode::Identity( PhaseTransform *phase ) { 1.1019 + const TypeInt *ti = phase->type( in(2) )->isa_int(); // shift count is an int 1.1020 + return ( ti && ti->is_con() && ( ti->get_con() & ( BitsPerLong - 1 ) ) == 0 ) ? in(1) : this; 1.1021 +} 1.1022 + 1.1023 +//------------------------------Value------------------------------------------ 1.1024 +// A RShiftLNode shifts its input2 right by input1 amount. 1.1025 +const Type *RShiftLNode::Value( PhaseTransform *phase ) const { 1.1026 + const Type *t1 = phase->type( in(1) ); 1.1027 + const Type *t2 = phase->type( in(2) ); 1.1028 + // Either input is TOP ==> the result is TOP 1.1029 + if( t1 == Type::TOP ) return Type::TOP; 1.1030 + if( t2 == Type::TOP ) return Type::TOP; 1.1031 + 1.1032 + // Left input is ZERO ==> the result is ZERO. 1.1033 + if( t1 == TypeLong::ZERO ) return TypeLong::ZERO; 1.1034 + // Shift by zero does nothing 1.1035 + if( t2 == TypeInt::ZERO ) return t1; 1.1036 + 1.1037 + // Either input is BOTTOM ==> the result is BOTTOM 1.1038 + if (t1 == Type::BOTTOM || t2 == Type::BOTTOM) 1.1039 + return TypeLong::LONG; 1.1040 + 1.1041 + if (t2 == TypeInt::INT) 1.1042 + return TypeLong::LONG; 1.1043 + 1.1044 + const TypeLong *r1 = t1->is_long(); // Handy access 1.1045 + const TypeInt *r2 = t2->is_int (); // Handy access 1.1046 + 1.1047 + // If the shift is a constant, just shift the bounds of the type. 1.1048 + // For example, if the shift is 63, we just propagate sign bits. 1.1049 + if (r2->is_con()) { 1.1050 + uint shift = r2->get_con(); 1.1051 + shift &= (2*BitsPerJavaInteger)-1; // semantics of Java shifts 1.1052 + // Shift by a multiple of 64 does nothing: 1.1053 + if (shift == 0) return t1; 1.1054 + // Calculate reasonably aggressive bounds for the result. 1.1055 + // This is necessary if we are to correctly type things 1.1056 + // like (x<<24>>24) == ((byte)x). 1.1057 + jlong lo = (jlong)r1->_lo >> (jlong)shift; 1.1058 + jlong hi = (jlong)r1->_hi >> (jlong)shift; 1.1059 + assert(lo <= hi, "must have valid bounds"); 1.1060 + const TypeLong* tl = TypeLong::make(lo, hi, MAX2(r1->_widen,r2->_widen)); 1.1061 + #ifdef ASSERT 1.1062 + // Make sure we get the sign-capture idiom correct. 1.1063 + if (shift == (2*BitsPerJavaInteger)-1) { 1.1064 + if (r1->_lo >= 0) assert(tl == TypeLong::ZERO, ">>63 of + is 0"); 1.1065 + if (r1->_hi < 0) assert(tl == TypeLong::MINUS_1, ">>63 of - is -1"); 1.1066 + } 1.1067 + #endif 1.1068 + return tl; 1.1069 + } 1.1070 + 1.1071 + return TypeLong::LONG; // Give up 1.1072 +} 1.1073 + 1.1074 +//============================================================================= 1.1075 +//------------------------------Identity--------------------------------------- 1.1076 +Node *URShiftINode::Identity( PhaseTransform *phase ) { 1.1077 + const TypeInt *ti = phase->type( in(2) )->isa_int(); 1.1078 + if ( ti && ti->is_con() && ( ti->get_con() & ( BitsPerInt - 1 ) ) == 0 ) return in(1); 1.1079 + 1.1080 + // Check for "((x << LogBytesPerWord) + (wordSize-1)) >> LogBytesPerWord" which is just "x". 1.1081 + // Happens during new-array length computation. 1.1082 + // Safe if 'x' is in the range [0..(max_int>>LogBytesPerWord)] 1.1083 + Node *add = in(1); 1.1084 + if( add->Opcode() == Op_AddI ) { 1.1085 + const TypeInt *t2 = phase->type(add->in(2))->isa_int(); 1.1086 + if( t2 && t2->is_con(wordSize - 1) && 1.1087 + add->in(1)->Opcode() == Op_LShiftI ) { 1.1088 + // Check that shift_counts are LogBytesPerWord 1.1089 + Node *lshift_count = add->in(1)->in(2); 1.1090 + const TypeInt *t_lshift_count = phase->type(lshift_count)->isa_int(); 1.1091 + if( t_lshift_count && t_lshift_count->is_con(LogBytesPerWord) && 1.1092 + t_lshift_count == phase->type(in(2)) ) { 1.1093 + Node *x = add->in(1)->in(1); 1.1094 + const TypeInt *t_x = phase->type(x)->isa_int(); 1.1095 + if( t_x != NULL && 0 <= t_x->_lo && t_x->_hi <= (max_jint>>LogBytesPerWord) ) { 1.1096 + return x; 1.1097 + } 1.1098 + } 1.1099 + } 1.1100 + } 1.1101 + 1.1102 + return (phase->type(in(2))->higher_equal(TypeInt::ZERO)) ? in(1) : this; 1.1103 +} 1.1104 + 1.1105 +//------------------------------Ideal------------------------------------------ 1.1106 +Node *URShiftINode::Ideal(PhaseGVN *phase, bool can_reshape) { 1.1107 + const TypeInt *t2 = phase->type( in(2) )->isa_int(); 1.1108 + if( !t2 || !t2->is_con() ) return NULL; // Right input is a constant 1.1109 + const int con = t2->get_con() & 31; // Shift count is always masked 1.1110 + if ( con == 0 ) return NULL; // let Identity() handle a 0 shift count 1.1111 + // We'll be wanting the right-shift amount as a mask of that many bits 1.1112 + const int mask = right_n_bits(BitsPerJavaInteger - con); 1.1113 + 1.1114 + int in1_op = in(1)->Opcode(); 1.1115 + 1.1116 + // Check for ((x>>>a)>>>b) and replace with (x>>>(a+b)) when a+b < 32 1.1117 + if( in1_op == Op_URShiftI ) { 1.1118 + const TypeInt *t12 = phase->type( in(1)->in(2) )->isa_int(); 1.1119 + if( t12 && t12->is_con() ) { // Right input is a constant 1.1120 + assert( in(1) != in(1)->in(1), "dead loop in URShiftINode::Ideal" ); 1.1121 + const int con2 = t12->get_con() & 31; // Shift count is always masked 1.1122 + const int con3 = con+con2; 1.1123 + if( con3 < 32 ) // Only merge shifts if total is < 32 1.1124 + return new (phase->C) URShiftINode( in(1)->in(1), phase->intcon(con3) ); 1.1125 + } 1.1126 + } 1.1127 + 1.1128 + // Check for ((x << z) + Y) >>> z. Replace with x + con>>>z 1.1129 + // The idiom for rounding to a power of 2 is "(Q+(2^z-1)) >>> z". 1.1130 + // If Q is "X << z" the rounding is useless. Look for patterns like 1.1131 + // ((X<<Z) + Y) >>> Z and replace with (X + Y>>>Z) & Z-mask. 1.1132 + Node *add = in(1); 1.1133 + if( in1_op == Op_AddI ) { 1.1134 + Node *lshl = add->in(1); 1.1135 + if( lshl->Opcode() == Op_LShiftI && 1.1136 + phase->type(lshl->in(2)) == t2 ) { 1.1137 + Node *y_z = phase->transform( new (phase->C) URShiftINode(add->in(2),in(2)) ); 1.1138 + Node *sum = phase->transform( new (phase->C) AddINode( lshl->in(1), y_z ) ); 1.1139 + return new (phase->C) AndINode( sum, phase->intcon(mask) ); 1.1140 + } 1.1141 + } 1.1142 + 1.1143 + // Check for (x & mask) >>> z. Replace with (x >>> z) & (mask >>> z) 1.1144 + // This shortens the mask. Also, if we are extracting a high byte and 1.1145 + // storing it to a buffer, the mask will be removed completely. 1.1146 + Node *andi = in(1); 1.1147 + if( in1_op == Op_AndI ) { 1.1148 + const TypeInt *t3 = phase->type( andi->in(2) )->isa_int(); 1.1149 + if( t3 && t3->is_con() ) { // Right input is a constant 1.1150 + jint mask2 = t3->get_con(); 1.1151 + mask2 >>= con; // *signed* shift downward (high-order zeroes do not help) 1.1152 + Node *newshr = phase->transform( new (phase->C) URShiftINode(andi->in(1), in(2)) ); 1.1153 + return new (phase->C) AndINode(newshr, phase->intcon(mask2)); 1.1154 + // The negative values are easier to materialize than positive ones. 1.1155 + // A typical case from address arithmetic is ((x & ~15) >> 4). 1.1156 + // It's better to change that to ((x >> 4) & ~0) versus 1.1157 + // ((x >> 4) & 0x0FFFFFFF). The difference is greatest in LP64. 1.1158 + } 1.1159 + } 1.1160 + 1.1161 + // Check for "(X << z ) >>> z" which simply zero-extends 1.1162 + Node *shl = in(1); 1.1163 + if( in1_op == Op_LShiftI && 1.1164 + phase->type(shl->in(2)) == t2 ) 1.1165 + return new (phase->C) AndINode( shl->in(1), phase->intcon(mask) ); 1.1166 + 1.1167 + return NULL; 1.1168 +} 1.1169 + 1.1170 +//------------------------------Value------------------------------------------ 1.1171 +// A URShiftINode shifts its input2 right by input1 amount. 1.1172 +const Type *URShiftINode::Value( PhaseTransform *phase ) const { 1.1173 + // (This is a near clone of RShiftINode::Value.) 1.1174 + const Type *t1 = phase->type( in(1) ); 1.1175 + const Type *t2 = phase->type( in(2) ); 1.1176 + // Either input is TOP ==> the result is TOP 1.1177 + if( t1 == Type::TOP ) return Type::TOP; 1.1178 + if( t2 == Type::TOP ) return Type::TOP; 1.1179 + 1.1180 + // Left input is ZERO ==> the result is ZERO. 1.1181 + if( t1 == TypeInt::ZERO ) return TypeInt::ZERO; 1.1182 + // Shift by zero does nothing 1.1183 + if( t2 == TypeInt::ZERO ) return t1; 1.1184 + 1.1185 + // Either input is BOTTOM ==> the result is BOTTOM 1.1186 + if (t1 == Type::BOTTOM || t2 == Type::BOTTOM) 1.1187 + return TypeInt::INT; 1.1188 + 1.1189 + if (t2 == TypeInt::INT) 1.1190 + return TypeInt::INT; 1.1191 + 1.1192 + const TypeInt *r1 = t1->is_int(); // Handy access 1.1193 + const TypeInt *r2 = t2->is_int(); // Handy access 1.1194 + 1.1195 + if (r2->is_con()) { 1.1196 + uint shift = r2->get_con(); 1.1197 + shift &= BitsPerJavaInteger-1; // semantics of Java shifts 1.1198 + // Shift by a multiple of 32 does nothing: 1.1199 + if (shift == 0) return t1; 1.1200 + // Calculate reasonably aggressive bounds for the result. 1.1201 + jint lo = (juint)r1->_lo >> (juint)shift; 1.1202 + jint hi = (juint)r1->_hi >> (juint)shift; 1.1203 + if (r1->_hi >= 0 && r1->_lo < 0) { 1.1204 + // If the type has both negative and positive values, 1.1205 + // there are two separate sub-domains to worry about: 1.1206 + // The positive half and the negative half. 1.1207 + jint neg_lo = lo; 1.1208 + jint neg_hi = (juint)-1 >> (juint)shift; 1.1209 + jint pos_lo = (juint) 0 >> (juint)shift; 1.1210 + jint pos_hi = hi; 1.1211 + lo = MIN2(neg_lo, pos_lo); // == 0 1.1212 + hi = MAX2(neg_hi, pos_hi); // == -1 >>> shift; 1.1213 + } 1.1214 + assert(lo <= hi, "must have valid bounds"); 1.1215 + const TypeInt* ti = TypeInt::make(lo, hi, MAX2(r1->_widen,r2->_widen)); 1.1216 + #ifdef ASSERT 1.1217 + // Make sure we get the sign-capture idiom correct. 1.1218 + if (shift == BitsPerJavaInteger-1) { 1.1219 + if (r1->_lo >= 0) assert(ti == TypeInt::ZERO, ">>>31 of + is 0"); 1.1220 + if (r1->_hi < 0) assert(ti == TypeInt::ONE, ">>>31 of - is +1"); 1.1221 + } 1.1222 + #endif 1.1223 + return ti; 1.1224 + } 1.1225 + 1.1226 + // 1.1227 + // Do not support shifted oops in info for GC 1.1228 + // 1.1229 + // else if( t1->base() == Type::InstPtr ) { 1.1230 + // 1.1231 + // const TypeInstPtr *o = t1->is_instptr(); 1.1232 + // if( t1->singleton() ) 1.1233 + // return TypeInt::make( ((uint32)o->const_oop() + o->_offset) >> shift ); 1.1234 + // } 1.1235 + // else if( t1->base() == Type::KlassPtr ) { 1.1236 + // const TypeKlassPtr *o = t1->is_klassptr(); 1.1237 + // if( t1->singleton() ) 1.1238 + // return TypeInt::make( ((uint32)o->const_oop() + o->_offset) >> shift ); 1.1239 + // } 1.1240 + 1.1241 + return TypeInt::INT; 1.1242 +} 1.1243 + 1.1244 +//============================================================================= 1.1245 +//------------------------------Identity--------------------------------------- 1.1246 +Node *URShiftLNode::Identity( PhaseTransform *phase ) { 1.1247 + const TypeInt *ti = phase->type( in(2) )->isa_int(); // shift count is an int 1.1248 + return ( ti && ti->is_con() && ( ti->get_con() & ( BitsPerLong - 1 ) ) == 0 ) ? in(1) : this; 1.1249 +} 1.1250 + 1.1251 +//------------------------------Ideal------------------------------------------ 1.1252 +Node *URShiftLNode::Ideal(PhaseGVN *phase, bool can_reshape) { 1.1253 + const TypeInt *t2 = phase->type( in(2) )->isa_int(); 1.1254 + if( !t2 || !t2->is_con() ) return NULL; // Right input is a constant 1.1255 + const int con = t2->get_con() & ( BitsPerLong - 1 ); // Shift count is always masked 1.1256 + if ( con == 0 ) return NULL; // let Identity() handle a 0 shift count 1.1257 + // note: mask computation below does not work for 0 shift count 1.1258 + // We'll be wanting the right-shift amount as a mask of that many bits 1.1259 + const jlong mask = (((jlong)CONST64(1) << (jlong)(BitsPerJavaLong - con)) -1); 1.1260 + 1.1261 + // Check for ((x << z) + Y) >>> z. Replace with x + con>>>z 1.1262 + // The idiom for rounding to a power of 2 is "(Q+(2^z-1)) >>> z". 1.1263 + // If Q is "X << z" the rounding is useless. Look for patterns like 1.1264 + // ((X<<Z) + Y) >>> Z and replace with (X + Y>>>Z) & Z-mask. 1.1265 + Node *add = in(1); 1.1266 + if( add->Opcode() == Op_AddL ) { 1.1267 + Node *lshl = add->in(1); 1.1268 + if( lshl->Opcode() == Op_LShiftL && 1.1269 + phase->type(lshl->in(2)) == t2 ) { 1.1270 + Node *y_z = phase->transform( new (phase->C) URShiftLNode(add->in(2),in(2)) ); 1.1271 + Node *sum = phase->transform( new (phase->C) AddLNode( lshl->in(1), y_z ) ); 1.1272 + return new (phase->C) AndLNode( sum, phase->longcon(mask) ); 1.1273 + } 1.1274 + } 1.1275 + 1.1276 + // Check for (x & mask) >>> z. Replace with (x >>> z) & (mask >>> z) 1.1277 + // This shortens the mask. Also, if we are extracting a high byte and 1.1278 + // storing it to a buffer, the mask will be removed completely. 1.1279 + Node *andi = in(1); 1.1280 + if( andi->Opcode() == Op_AndL ) { 1.1281 + const TypeLong *t3 = phase->type( andi->in(2) )->isa_long(); 1.1282 + if( t3 && t3->is_con() ) { // Right input is a constant 1.1283 + jlong mask2 = t3->get_con(); 1.1284 + mask2 >>= con; // *signed* shift downward (high-order zeroes do not help) 1.1285 + Node *newshr = phase->transform( new (phase->C) URShiftLNode(andi->in(1), in(2)) ); 1.1286 + return new (phase->C) AndLNode(newshr, phase->longcon(mask2)); 1.1287 + } 1.1288 + } 1.1289 + 1.1290 + // Check for "(X << z ) >>> z" which simply zero-extends 1.1291 + Node *shl = in(1); 1.1292 + if( shl->Opcode() == Op_LShiftL && 1.1293 + phase->type(shl->in(2)) == t2 ) 1.1294 + return new (phase->C) AndLNode( shl->in(1), phase->longcon(mask) ); 1.1295 + 1.1296 + return NULL; 1.1297 +} 1.1298 + 1.1299 +//------------------------------Value------------------------------------------ 1.1300 +// A URShiftINode shifts its input2 right by input1 amount. 1.1301 +const Type *URShiftLNode::Value( PhaseTransform *phase ) const { 1.1302 + // (This is a near clone of RShiftLNode::Value.) 1.1303 + const Type *t1 = phase->type( in(1) ); 1.1304 + const Type *t2 = phase->type( in(2) ); 1.1305 + // Either input is TOP ==> the result is TOP 1.1306 + if( t1 == Type::TOP ) return Type::TOP; 1.1307 + if( t2 == Type::TOP ) return Type::TOP; 1.1308 + 1.1309 + // Left input is ZERO ==> the result is ZERO. 1.1310 + if( t1 == TypeLong::ZERO ) return TypeLong::ZERO; 1.1311 + // Shift by zero does nothing 1.1312 + if( t2 == TypeInt::ZERO ) return t1; 1.1313 + 1.1314 + // Either input is BOTTOM ==> the result is BOTTOM 1.1315 + if (t1 == Type::BOTTOM || t2 == Type::BOTTOM) 1.1316 + return TypeLong::LONG; 1.1317 + 1.1318 + if (t2 == TypeInt::INT) 1.1319 + return TypeLong::LONG; 1.1320 + 1.1321 + const TypeLong *r1 = t1->is_long(); // Handy access 1.1322 + const TypeInt *r2 = t2->is_int (); // Handy access 1.1323 + 1.1324 + if (r2->is_con()) { 1.1325 + uint shift = r2->get_con(); 1.1326 + shift &= BitsPerJavaLong - 1; // semantics of Java shifts 1.1327 + // Shift by a multiple of 64 does nothing: 1.1328 + if (shift == 0) return t1; 1.1329 + // Calculate reasonably aggressive bounds for the result. 1.1330 + jlong lo = (julong)r1->_lo >> (juint)shift; 1.1331 + jlong hi = (julong)r1->_hi >> (juint)shift; 1.1332 + if (r1->_hi >= 0 && r1->_lo < 0) { 1.1333 + // If the type has both negative and positive values, 1.1334 + // there are two separate sub-domains to worry about: 1.1335 + // The positive half and the negative half. 1.1336 + jlong neg_lo = lo; 1.1337 + jlong neg_hi = (julong)-1 >> (juint)shift; 1.1338 + jlong pos_lo = (julong) 0 >> (juint)shift; 1.1339 + jlong pos_hi = hi; 1.1340 + //lo = MIN2(neg_lo, pos_lo); // == 0 1.1341 + lo = neg_lo < pos_lo ? neg_lo : pos_lo; 1.1342 + //hi = MAX2(neg_hi, pos_hi); // == -1 >>> shift; 1.1343 + hi = neg_hi > pos_hi ? neg_hi : pos_hi; 1.1344 + } 1.1345 + assert(lo <= hi, "must have valid bounds"); 1.1346 + const TypeLong* tl = TypeLong::make(lo, hi, MAX2(r1->_widen,r2->_widen)); 1.1347 + #ifdef ASSERT 1.1348 + // Make sure we get the sign-capture idiom correct. 1.1349 + if (shift == BitsPerJavaLong - 1) { 1.1350 + if (r1->_lo >= 0) assert(tl == TypeLong::ZERO, ">>>63 of + is 0"); 1.1351 + if (r1->_hi < 0) assert(tl == TypeLong::ONE, ">>>63 of - is +1"); 1.1352 + } 1.1353 + #endif 1.1354 + return tl; 1.1355 + } 1.1356 + 1.1357 + return TypeLong::LONG; // Give up 1.1358 +}