601 // If both inputs are constants, compare them.
602 const Type *CmpLNode::sub( const Type *t1, const Type *t2 ) const {
603 const TypeLong *r0 = t1->is_long(); // Handy access
604 const TypeLong *r1 = t2->is_long();
605
606 if( r0->_hi < r1->_lo ) // Range is always low?
607 return TypeInt::CC_LT;
608 else if( r0->_lo > r1->_hi ) // Range is always high?
609 return TypeInt::CC_GT;
610
611 else if( r0->is_con() && r1->is_con() ) { // comparing constants?
612 assert(r0->get_con() == r1->get_con(), "must be equal");
613 return TypeInt::CC_EQ; // Equal results.
614 } else if( r0->_hi == r1->_lo ) // Range is never high?
615 return TypeInt::CC_LE;
616 else if( r0->_lo == r1->_hi ) // Range is never low?
617 return TypeInt::CC_GE;
618 return TypeInt::CC; // else use worst case results
619 }
620
621 //=============================================================================
622 //------------------------------sub--------------------------------------------
623 // Simplify an CmpP (compare 2 pointers) node, based on local information.
624 // If both inputs are constants, compare them.
625 const Type *CmpPNode::sub( const Type *t1, const Type *t2 ) const {
626 const TypePtr *r0 = t1->is_ptr(); // Handy access
627 const TypePtr *r1 = t2->is_ptr();
628
629 // Undefined inputs makes for an undefined result
630 if( TypePtr::above_centerline(r0->_ptr) ||
631 TypePtr::above_centerline(r1->_ptr) )
632 return Type::TOP;
633
634 if (r0 == r1 && r0->singleton()) {
635 // Equal pointer constants (klasses, nulls, etc.)
636 return TypeInt::CC_EQ;
637 }
638
639 // See if it is 2 unrelated classes.
640 const TypeOopPtr* p0 = r0->isa_oopptr();
|
601 // If both inputs are constants, compare them.
602 const Type *CmpLNode::sub( const Type *t1, const Type *t2 ) const {
603 const TypeLong *r0 = t1->is_long(); // Handy access
604 const TypeLong *r1 = t2->is_long();
605
606 if( r0->_hi < r1->_lo ) // Range is always low?
607 return TypeInt::CC_LT;
608 else if( r0->_lo > r1->_hi ) // Range is always high?
609 return TypeInt::CC_GT;
610
611 else if( r0->is_con() && r1->is_con() ) { // comparing constants?
612 assert(r0->get_con() == r1->get_con(), "must be equal");
613 return TypeInt::CC_EQ; // Equal results.
614 } else if( r0->_hi == r1->_lo ) // Range is never high?
615 return TypeInt::CC_LE;
616 else if( r0->_lo == r1->_hi ) // Range is never low?
617 return TypeInt::CC_GE;
618 return TypeInt::CC; // else use worst case results
619 }
620
621
622 // Simplify a CmpUL (compare 2 unsigned longs) node, based on local information.
623 // If both inputs are constants, compare them.
624 const Type* CmpULNode::sub(const Type* t1, const Type* t2) const {
625 assert(!t1->isa_ptr(), "obsolete usage of CmpUL");
626
627 // comparing two unsigned longs
628 const TypeLong* r0 = t1->is_long(); // Handy access
629 const TypeLong* r1 = t2->is_long();
630
631 // Current installed version
632 // Compare ranges for non-overlap
633 julong lo0 = r0->_lo;
634 julong hi0 = r0->_hi;
635 julong lo1 = r1->_lo;
636 julong hi1 = r1->_hi;
637
638 // If either one has both negative and positive values,
639 // it therefore contains both 0 and -1, and since [0..-1] is the
640 // full unsigned range, the type must act as an unsigned bottom.
641 bool bot0 = ((jlong)(lo0 ^ hi0) < 0);
642 bool bot1 = ((jlong)(lo1 ^ hi1) < 0);
643
644 if (bot0 || bot1) {
645 // All unsigned values are LE -1 and GE 0.
646 if (lo0 == 0 && hi0 == 0) {
647 return TypeInt::CC_LE; // 0 <= bot
648 } else if ((jlong)lo0 == -1 && (jlong)hi0 == -1) {
649 return TypeInt::CC_GE; // -1 >= bot
650 } else if (lo1 == 0 && hi1 == 0) {
651 return TypeInt::CC_GE; // bot >= 0
652 } else if ((jlong)lo1 == -1 && (jlong)hi1 == -1) {
653 return TypeInt::CC_LE; // bot <= -1
654 }
655 } else {
656 // We can use ranges of the form [lo..hi] if signs are the same.
657 assert(lo0 <= hi0 && lo1 <= hi1, "unsigned ranges are valid");
658 // results are reversed, '-' > '+' for unsigned compare
659 if (hi0 < lo1) {
660 return TypeInt::CC_LT; // smaller
661 } else if (lo0 > hi1) {
662 return TypeInt::CC_GT; // greater
663 } else if (hi0 == lo1 && lo0 == hi1) {
664 return TypeInt::CC_EQ; // Equal results
665 } else if (lo0 >= hi1) {
666 return TypeInt::CC_GE;
667 } else if (hi0 <= lo1) {
668 return TypeInt::CC_LE;
669 }
670 }
671
672 return TypeInt::CC; // else use worst case results
673 }
674
675 //=============================================================================
676 //------------------------------sub--------------------------------------------
677 // Simplify an CmpP (compare 2 pointers) node, based on local information.
678 // If both inputs are constants, compare them.
679 const Type *CmpPNode::sub( const Type *t1, const Type *t2 ) const {
680 const TypePtr *r0 = t1->is_ptr(); // Handy access
681 const TypePtr *r1 = t2->is_ptr();
682
683 // Undefined inputs makes for an undefined result
684 if( TypePtr::above_centerline(r0->_ptr) ||
685 TypePtr::above_centerline(r1->_ptr) )
686 return Type::TOP;
687
688 if (r0 == r1 && r0->singleton()) {
689 // Equal pointer constants (klasses, nulls, etc.)
690 return TypeInt::CC_EQ;
691 }
692
693 // See if it is 2 unrelated classes.
694 const TypeOopPtr* p0 = r0->isa_oopptr();
|