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
444 //------------------------------Identity---------------------------------------
445 // Fold (x-y)+y OR y+(x-y) into x
446 Node *AddLNode::Identity( PhaseTransform *phase ) {
447 if( in(1)->Opcode() == Op_SubL && phase->eqv(in(1)->in(2),in(2)) ) {
448 return in(1)->in(1);
449 }
450 else if( in(2)->Opcode() == Op_SubL && phase->eqv(in(2)->in(2),in(1)) ) {
451 return in(2)->in(1);
452 }
453 return AddNode::Identity(phase);
454 }
455
456
457 //------------------------------add_ring---------------------------------------
458 // Supplied function returns the sum of the inputs. Guaranteed never
459 // to be passed a TOP or BOTTOM type, these are filtered out by
460 // pre-check.
461 const Type *AddLNode::add_ring( const Type *t0, const Type *t1 ) const {
462 const TypeLong *r0 = t0->is_long(); // Handy access
463 const TypeLong *r1 = t1->is_long();
464 jlong lo = r0->_lo + r1->_lo;
465 jlong hi = r0->_hi + r1->_hi;
466 if( !(r0->is_con() && r1->is_con()) ) {
467 // Not both constants, compute approximate result
468 if( (r0->_lo & r1->_lo) < 0 && lo >= 0 ) {
469 lo =min_jlong; hi = max_jlong; // Underflow on the low side
470 }
471 if( (~(r0->_hi | r1->_hi)) < 0 && hi < 0 ) {
472 lo = min_jlong; hi = max_jlong; // Overflow on the high side
473 }
474 if( lo > hi ) { // Handle overflow
475 lo = min_jlong; hi = max_jlong;
476 }
477 } else {
478 // both constants, compute precise result using 'lo' and 'hi'
479 // Semantics define overflow and underflow for integer addition
480 // as expected. In particular: 0x80000000 + 0x80000000 --> 0x0
481 }
482 return TypeLong::make( lo, hi, MAX2(r0->_widen,r1->_widen) );
483 }
484
485
|
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
444 //------------------------------Identity---------------------------------------
445 // Fold (x-y)+y OR y+(x-y) into x
446 Node *AddLNode::Identity( PhaseTransform *phase ) {
447 if( in(1)->Opcode() == Op_SubL && phase->eqv(in(1)->in(2),in(2)) ) {
448 return in(1)->in(1);
449 }
450 else if( in(2)->Opcode() == Op_SubL && phase->eqv(in(2)->in(2),in(1)) ) {
451 return in(2)->in(1);
452 }
453 return AddNode::Identity(phase);
454 }
455
456
457 //------------------------------add_ring---------------------------------------
458 // Supplied function returns the sum of the inputs. Guaranteed never
459 // to be passed a TOP or BOTTOM type, these are filtered out by
460 // pre-check.
461 const Type *AddLNode::add_ring( const Type *t0, const Type *t1 ) const {
462 const TypeLong *r0 = t0->is_long(); // Handy access
463 const TypeLong *r1 = t1->is_long();
464 jlong lo = java_add(r0->_lo, r1->_lo);
465 jlong hi = java_add(r0->_hi, r1->_hi);
466 if( !(r0->is_con() && r1->is_con()) ) {
467 // Not both constants, compute approximate result
468 if( (r0->_lo & r1->_lo) < 0 && lo >= 0 ) {
469 lo =min_jlong; hi = max_jlong; // Underflow on the low side
470 }
471 if( (~(r0->_hi | r1->_hi)) < 0 && hi < 0 ) {
472 lo = min_jlong; hi = max_jlong; // Overflow on the high side
473 }
474 if( lo > hi ) { // Handle overflow
475 lo = min_jlong; hi = max_jlong;
476 }
477 } else {
478 // both constants, compute precise result using 'lo' and 'hi'
479 // Semantics define overflow and underflow for integer addition
480 // as expected. In particular: 0x80000000 + 0x80000000 --> 0x0
481 }
482 return TypeLong::make( lo, hi, MAX2(r0->_widen,r1->_widen) );
483 }
484
485
|