src/share/vm/opto/divnode.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/opto

src/share/vm/opto/divnode.cpp

Print this page




 497   if( t1 == Type::TOP ) return Type::TOP;
 498   if( t2 == Type::TOP ) return Type::TOP;
 499 
 500   // x/x == 1 since we always generate the dynamic divisor check for 0.
 501   if( phase->eqv( in(1), in(2) ) )
 502     return TypeInt::ONE;
 503 
 504   // Either input is BOTTOM ==> the result is the local BOTTOM
 505   const Type *bot = bottom_type();
 506   if( (t1 == bot) || (t2 == bot) ||
 507       (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) )
 508     return bot;
 509 
 510   // Divide the two numbers.  We approximate.
 511   // If divisor is a constant and not zero
 512   const TypeInt *i1 = t1->is_int();
 513   const TypeInt *i2 = t2->is_int();
 514   int widen = MAX2(i1->_widen, i2->_widen);
 515 
 516   if( i2->is_con() && i2->get_con() != 0 ) {
 517     int32 d = i2->get_con(); // Divisor
 518     jint lo, hi;
 519     if( d >= 0 ) {
 520       lo = i1->_lo/d;
 521       hi = i1->_hi/d;
 522     } else {
 523       if( d == -1 && i1->_lo == min_jint ) {
 524         // 'min_jint/-1' throws arithmetic exception during compilation
 525         lo = min_jint;
 526         // do not support holes, 'hi' must go to either min_jint or max_jint:
 527         // [min_jint, -10]/[-1,-1] ==> [min_jint] UNION [10,max_jint]
 528         hi = i1->_hi == min_jint ? min_jint : max_jint;
 529       } else {
 530         lo = i1->_hi/d;
 531         hi = i1->_lo/d;
 532       }
 533     }
 534     return TypeInt::make(lo, hi, widen);
 535   }
 536 
 537   // If the dividend is a constant
 538   if( i1->is_con() ) {
 539     int32 d = i1->get_con();
 540     if( d < 0 ) {
 541       if( d == min_jint ) {
 542         //  (-min_jint) == min_jint == (min_jint / -1)
 543         return TypeInt::make(min_jint, max_jint/2 + 1, widen);
 544       } else {
 545         return TypeInt::make(d, -d, widen);
 546       }
 547     }
 548     return TypeInt::make(-d, d, widen);
 549   }
 550 
 551   // Otherwise we give up all hope
 552   return TypeInt::INT;
 553 }
 554 
 555 
 556 //=============================================================================
 557 //------------------------------Identity---------------------------------------
 558 // If the divisor is 1, we are an identity on the dividend.
 559 Node *DivLNode::Identity( PhaseTransform *phase ) {




 497   if( t1 == Type::TOP ) return Type::TOP;
 498   if( t2 == Type::TOP ) return Type::TOP;
 499 
 500   // x/x == 1 since we always generate the dynamic divisor check for 0.
 501   if( phase->eqv( in(1), in(2) ) )
 502     return TypeInt::ONE;
 503 
 504   // Either input is BOTTOM ==> the result is the local BOTTOM
 505   const Type *bot = bottom_type();
 506   if( (t1 == bot) || (t2 == bot) ||
 507       (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) )
 508     return bot;
 509 
 510   // Divide the two numbers.  We approximate.
 511   // If divisor is a constant and not zero
 512   const TypeInt *i1 = t1->is_int();
 513   const TypeInt *i2 = t2->is_int();
 514   int widen = MAX2(i1->_widen, i2->_widen);
 515 
 516   if( i2->is_con() && i2->get_con() != 0 ) {
 517     int32_t d = i2->get_con(); // Divisor
 518     jint lo, hi;
 519     if( d >= 0 ) {
 520       lo = i1->_lo/d;
 521       hi = i1->_hi/d;
 522     } else {
 523       if( d == -1 && i1->_lo == min_jint ) {
 524         // 'min_jint/-1' throws arithmetic exception during compilation
 525         lo = min_jint;
 526         // do not support holes, 'hi' must go to either min_jint or max_jint:
 527         // [min_jint, -10]/[-1,-1] ==> [min_jint] UNION [10,max_jint]
 528         hi = i1->_hi == min_jint ? min_jint : max_jint;
 529       } else {
 530         lo = i1->_hi/d;
 531         hi = i1->_lo/d;
 532       }
 533     }
 534     return TypeInt::make(lo, hi, widen);
 535   }
 536 
 537   // If the dividend is a constant
 538   if( i1->is_con() ) {
 539     int32_t d = i1->get_con();
 540     if( d < 0 ) {
 541       if( d == min_jint ) {
 542         //  (-min_jint) == min_jint == (min_jint / -1)
 543         return TypeInt::make(min_jint, max_jint/2 + 1, widen);
 544       } else {
 545         return TypeInt::make(d, -d, widen);
 546       }
 547     }
 548     return TypeInt::make(-d, d, widen);
 549   }
 550 
 551   // Otherwise we give up all hope
 552   return TypeInt::INT;
 553 }
 554 
 555 
 556 //=============================================================================
 557 //------------------------------Identity---------------------------------------
 558 // If the divisor is 1, we are an identity on the dividend.
 559 Node *DivLNode::Identity( PhaseTransform *phase ) {


src/share/vm/opto/divnode.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File