327 //------------------------------Identity--------------------------------------- 328 // Fold (x-y)+y OR y+(x-y) into x 329 Node *AddINode::Identity( PhaseTransform *phase ) { 330 if( in(1)->Opcode() == Op_SubI && phase->eqv(in(1)->in(2),in(2)) ) { 331 return in(1)->in(1); 332 } 333 else if( in(2)->Opcode() == Op_SubI && phase->eqv(in(2)->in(2),in(1)) ) { 334 return in(2)->in(1); 335 } 336 return AddNode::Identity(phase); 337 } 338 339 340 //------------------------------add_ring--------------------------------------- 341 // Supplied function returns the sum of the inputs. Guaranteed never 342 // to be passed a TOP or BOTTOM type, these are filtered out by 343 // pre-check. 344 const Type *AddINode::add_ring( const Type *t0, const Type *t1 ) const { 345 const TypeInt *r0 = t0->is_int(); // Handy access 346 const TypeInt *r1 = t1->is_int(); 347 int lo = r0->_lo + r1->_lo; 348 int hi = r0->_hi + r1->_hi; 349 if( !(r0->is_con() && r1->is_con()) ) { 350 // Not both constants, compute approximate result 351 if( (r0->_lo & r1->_lo) < 0 && lo >= 0 ) { 352 lo = min_jint; hi = max_jint; // Underflow on the low side 353 } 354 if( (~(r0->_hi | r1->_hi)) < 0 && hi < 0 ) { 355 lo = min_jint; hi = max_jint; // Overflow on the high side 356 } 357 if( lo > hi ) { // Handle overflow 358 lo = min_jint; hi = max_jint; 359 } 360 } else { 361 // both constants, compute precise result using 'lo' and 'hi' 362 // Semantics define overflow and underflow for integer addition 363 // as expected. In particular: 0x80000000 + 0x80000000 --> 0x0 364 } 365 return TypeInt::make( lo, hi, MAX2(r0->_widen,r1->_widen) ); 366 } 367 368 445 //------------------------------Identity--------------------------------------- 446 // Fold (x-y)+y OR y+(x-y) into x 447 Node *AddLNode::Identity( PhaseTransform *phase ) { 448 if( in(1)->Opcode() == Op_SubL && phase->eqv(in(1)->in(2),in(2)) ) { 449 return in(1)->in(1); 450 } 451 else if( in(2)->Opcode() == Op_SubL && phase->eqv(in(2)->in(2),in(1)) ) { 452 return in(2)->in(1); 453 } 454 return AddNode::Identity(phase); 455 } 456 457 458 //------------------------------add_ring--------------------------------------- 459 // Supplied function returns the sum of the inputs. Guaranteed never 460 // to be passed a TOP or BOTTOM type, these are filtered out by 461 // pre-check. 462 const Type *AddLNode::add_ring( const Type *t0, const Type *t1 ) const { 463 const TypeLong *r0 = t0->is_long(); // Handy access 464 const TypeLong *r1 = t1->is_long(); 465 jlong lo = r0->_lo + r1->_lo; 466 jlong hi = r0->_hi + r1->_hi; 467 if( !(r0->is_con() && r1->is_con()) ) { 468 // Not both constants, compute approximate result 469 if( (r0->_lo & r1->_lo) < 0 && lo >= 0 ) { 470 lo =min_jlong; hi = max_jlong; // Underflow on the low side 471 } 472 if( (~(r0->_hi | r1->_hi)) < 0 && hi < 0 ) { 473 lo = min_jlong; hi = max_jlong; // Overflow on the high side 474 } 475 if( lo > hi ) { // Handle overflow 476 lo = min_jlong; hi = max_jlong; 477 } 478 } else { 479 // both constants, compute precise result using 'lo' and 'hi' 480 // Semantics define overflow and underflow for integer addition 481 // as expected. In particular: 0x80000000 + 0x80000000 --> 0x0 482 } 483 return TypeLong::make( lo, hi, MAX2(r0->_widen,r1->_widen) ); 484 } 485 486 | 327 //------------------------------Identity--------------------------------------- 328 // Fold (x-y)+y OR y+(x-y) into x 329 Node *AddINode::Identity( PhaseTransform *phase ) { 330 if( in(1)->Opcode() == Op_SubI && phase->eqv(in(1)->in(2),in(2)) ) { 331 return in(1)->in(1); 332 } 333 else if( in(2)->Opcode() == Op_SubI && phase->eqv(in(2)->in(2),in(1)) ) { 334 return in(2)->in(1); 335 } 336 return AddNode::Identity(phase); 337 } 338 339 340 //------------------------------add_ring--------------------------------------- 341 // Supplied function returns the sum of the inputs. Guaranteed never 342 // to be passed a TOP or BOTTOM type, these are filtered out by 343 // pre-check. 344 const Type *AddINode::add_ring( const Type *t0, const Type *t1 ) const { 345 const TypeInt *r0 = t0->is_int(); // Handy access 346 const TypeInt *r1 = t1->is_int(); 347 int lo = java_add(r0->_lo, r1->_lo); 348 int hi = java_add(r0->_hi, r1->_hi); 349 if( !(r0->is_con() && r1->is_con()) ) { 350 // Not both constants, compute approximate result 351 if( (r0->_lo & r1->_lo) < 0 && lo >= 0 ) { 352 lo = min_jint; hi = max_jint; // Underflow on the low side 353 } 354 if( (~(r0->_hi | r1->_hi)) < 0 && hi < 0 ) { 355 lo = min_jint; hi = max_jint; // Overflow on the high side 356 } 357 if( lo > hi ) { // Handle overflow 358 lo = min_jint; hi = max_jint; 359 } 360 } else { 361 // both constants, compute precise result using 'lo' and 'hi' 362 // Semantics define overflow and underflow for integer addition 363 // as expected. In particular: 0x80000000 + 0x80000000 --> 0x0 364 } 365 return TypeInt::make( lo, hi, MAX2(r0->_widen,r1->_widen) ); 366 } 367 368 445 //------------------------------Identity--------------------------------------- 446 // Fold (x-y)+y OR y+(x-y) into x 447 Node *AddLNode::Identity( PhaseTransform *phase ) { 448 if( in(1)->Opcode() == Op_SubL && phase->eqv(in(1)->in(2),in(2)) ) { 449 return in(1)->in(1); 450 } 451 else if( in(2)->Opcode() == Op_SubL && phase->eqv(in(2)->in(2),in(1)) ) { 452 return in(2)->in(1); 453 } 454 return AddNode::Identity(phase); 455 } 456 457 458 //------------------------------add_ring--------------------------------------- 459 // Supplied function returns the sum of the inputs. Guaranteed never 460 // to be passed a TOP or BOTTOM type, these are filtered out by 461 // pre-check. 462 const Type *AddLNode::add_ring( const Type *t0, const Type *t1 ) const { 463 const TypeLong *r0 = t0->is_long(); // Handy access 464 const TypeLong *r1 = t1->is_long(); 465 jlong lo = java_add(r0->_lo, r1->_lo); 466 jlong hi = java_add(r0->_hi, r1->_hi); 467 if( !(r0->is_con() && r1->is_con()) ) { 468 // Not both constants, compute approximate result 469 if( (r0->_lo & r1->_lo) < 0 && lo >= 0 ) { 470 lo =min_jlong; hi = max_jlong; // Underflow on the low side 471 } 472 if( (~(r0->_hi | r1->_hi)) < 0 && hi < 0 ) { 473 lo = min_jlong; hi = max_jlong; // Overflow on the high side 474 } 475 if( lo > hi ) { // Handle overflow 476 lo = min_jlong; hi = max_jlong; 477 } 478 } else { 479 // both constants, compute precise result using 'lo' and 'hi' 480 // Semantics define overflow and underflow for integer addition 481 // as expected. In particular: 0x80000000 + 0x80000000 --> 0x0 482 } 483 return TypeLong::make( lo, hi, MAX2(r0->_widen,r1->_widen) ); 484 } 485 486 |