src/share/vm/opto/subnode.cpp

changeset 8797
37ba410ffd43
parent 8435
64bd5b63923c
child 8856
ac27a9c85bea
child 9610
f43f77de876a
equal deleted inserted replaced
8796:b1f3fbe39975 8797:37ba410ffd43
705 else if( r0->_lo == r1->_hi ) // Range is never low? 705 else if( r0->_lo == r1->_hi ) // Range is never low?
706 return TypeInt::CC_GE; 706 return TypeInt::CC_GE;
707 return TypeInt::CC; // else use worst case results 707 return TypeInt::CC; // else use worst case results
708 } 708 }
709 709
710
711 // Simplify a CmpUL (compare 2 unsigned longs) node, based on local information.
712 // If both inputs are constants, compare them.
713 const Type* CmpULNode::sub(const Type* t1, const Type* t2) const {
714 assert(!t1->isa_ptr(), "obsolete usage of CmpUL");
715
716 // comparing two unsigned longs
717 const TypeLong* r0 = t1->is_long(); // Handy access
718 const TypeLong* r1 = t2->is_long();
719
720 // Current installed version
721 // Compare ranges for non-overlap
722 julong lo0 = r0->_lo;
723 julong hi0 = r0->_hi;
724 julong lo1 = r1->_lo;
725 julong hi1 = r1->_hi;
726
727 // If either one has both negative and positive values,
728 // it therefore contains both 0 and -1, and since [0..-1] is the
729 // full unsigned range, the type must act as an unsigned bottom.
730 bool bot0 = ((jlong)(lo0 ^ hi0) < 0);
731 bool bot1 = ((jlong)(lo1 ^ hi1) < 0);
732
733 if (bot0 || bot1) {
734 // All unsigned values are LE -1 and GE 0.
735 if (lo0 == 0 && hi0 == 0) {
736 return TypeInt::CC_LE; // 0 <= bot
737 } else if ((jlong)lo0 == -1 && (jlong)hi0 == -1) {
738 return TypeInt::CC_GE; // -1 >= bot
739 } else if (lo1 == 0 && hi1 == 0) {
740 return TypeInt::CC_GE; // bot >= 0
741 } else if ((jlong)lo1 == -1 && (jlong)hi1 == -1) {
742 return TypeInt::CC_LE; // bot <= -1
743 }
744 } else {
745 // We can use ranges of the form [lo..hi] if signs are the same.
746 assert(lo0 <= hi0 && lo1 <= hi1, "unsigned ranges are valid");
747 // results are reversed, '-' > '+' for unsigned compare
748 if (hi0 < lo1) {
749 return TypeInt::CC_LT; // smaller
750 } else if (lo0 > hi1) {
751 return TypeInt::CC_GT; // greater
752 } else if (hi0 == lo1 && lo0 == hi1) {
753 return TypeInt::CC_EQ; // Equal results
754 } else if (lo0 >= hi1) {
755 return TypeInt::CC_GE;
756 } else if (hi0 <= lo1) {
757 return TypeInt::CC_LE;
758 }
759 }
760
761 return TypeInt::CC; // else use worst case results
762 }
763
710 //============================================================================= 764 //=============================================================================
711 //------------------------------sub-------------------------------------------- 765 //------------------------------sub--------------------------------------------
712 // Simplify an CmpP (compare 2 pointers) node, based on local information. 766 // Simplify an CmpP (compare 2 pointers) node, based on local information.
713 // If both inputs are constants, compare them. 767 // If both inputs are constants, compare them.
714 const Type *CmpPNode::sub( const Type *t1, const Type *t2 ) const { 768 const Type *CmpPNode::sub( const Type *t1, const Type *t2 ) const {

mercurial