< prev index next >

src/hotspot/share/opto/subnode.cpp

Print this page

  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "compiler/compileLog.hpp"
  27 #include "gc/shared/barrierSet.hpp"
  28 #include "gc/shared/c2/barrierSetC2.hpp"
  29 #include "memory/allocation.inline.hpp"
  30 #include "opto/addnode.hpp"
  31 #include "opto/callnode.hpp"
  32 #include "opto/cfgnode.hpp"

  33 #include "opto/loopnode.hpp"
  34 #include "opto/matcher.hpp"
  35 #include "opto/movenode.hpp"
  36 #include "opto/mulnode.hpp"
  37 #include "opto/opcodes.hpp"
  38 #include "opto/phaseX.hpp"
  39 #include "opto/subnode.hpp"
  40 #include "runtime/sharedRuntime.hpp"
  41 #include "utilities/moveBits.hpp"
  42 
  43 // Portions of code courtesy of Clifford Click
  44 
  45 // Optimization - Graph Style
  46 
  47 #include "math.h"
  48 
  49 //=============================================================================
  50 //------------------------------Identity---------------------------------------
  51 // If right input is a constant 0, return the left input.
  52 Node* SubNode::Identity(PhaseGVN* phase) {

 819     switch (in(1)->Opcode()) {
 820     case Op_CmpU3:              // Collapse a CmpU3/CmpI into a CmpU
 821       return new CmpUNode(in(1)->in(1),in(1)->in(2));
 822     case Op_CmpL3:              // Collapse a CmpL3/CmpI into a CmpL
 823       return new CmpLNode(in(1)->in(1),in(1)->in(2));
 824     case Op_CmpUL3:             // Collapse a CmpUL3/CmpI into a CmpUL
 825       return new CmpULNode(in(1)->in(1),in(1)->in(2));
 826     case Op_CmpF3:              // Collapse a CmpF3/CmpI into a CmpF
 827       return new CmpFNode(in(1)->in(1),in(1)->in(2));
 828     case Op_CmpD3:              // Collapse a CmpD3/CmpI into a CmpD
 829       return new CmpDNode(in(1)->in(1),in(1)->in(2));
 830     //case Op_SubI:
 831       // If (x - y) cannot overflow, then ((x - y) <?> 0)
 832       // can be turned into (x <?> y).
 833       // This is handled (with more general cases) by Ideal_sub_algebra.
 834     }
 835   }
 836   return NULL;                  // No change
 837 }
 838 
 839 Node *CmpLNode::Ideal( PhaseGVN *phase, bool can_reshape ) {







 840   const TypeLong *t2 = phase->type(in(2))->isa_long();
 841   if (Opcode() == Op_CmpL && in(1)->Opcode() == Op_ConvI2L && t2 && t2->is_con()) {
 842     const jlong con = t2->get_con();
 843     if (con >= min_jint && con <= max_jint) {
 844       return new CmpINode(in(1)->in(1), phase->intcon((jint)con));
 845     }
 846   }
 847   return NULL;
 848 }
 849 

























 850 //=============================================================================
 851 // Simplify a CmpL (compare 2 longs ) node, based on local information.
 852 // If both inputs are constants, compare them.
 853 const Type *CmpLNode::sub( const Type *t1, const Type *t2 ) const {
 854   const TypeLong *r0 = t1->is_long(); // Handy access
 855   const TypeLong *r1 = t2->is_long();
 856 
 857   if( r0->_hi < r1->_lo )       // Range is always low?
 858     return TypeInt::CC_LT;
 859   else if( r0->_lo > r1->_hi )  // Range is always high?
 860     return TypeInt::CC_GT;
 861 
 862   else if( r0->is_con() && r1->is_con() ) { // comparing constants?
 863     assert(r0->get_con() == r1->get_con(), "must be equal");
 864     return TypeInt::CC_EQ;      // Equal results.
 865   } else if( r0->_hi == r1->_lo ) // Range is never high?
 866     return TypeInt::CC_LE;
 867   else if( r0->_lo == r1->_hi ) // Range is never low?
 868     return TypeInt::CC_GE;
 869   return TypeInt::CC;           // else use worst case results

 955       if (MemNode::detect_ptr_independence(in1, alloc1, in2, alloc2, NULL)) {
 956         return TypeInt::CC_GT;  // different pointers
 957       }
 958     }
 959     bool    xklass0 = p0 ? p0->klass_is_exact() : k0->klass_is_exact();
 960     bool    xklass1 = p1 ? p1->klass_is_exact() : k1->klass_is_exact();
 961     bool unrelated_classes = false;
 962 
 963     if ((p0 && p0->is_same_java_type_as(p1)) ||
 964         (k0 && k0->is_same_java_type_as(k1))) {
 965     } else if ((p0 && !p1->maybe_java_subtype_of(p0) && !p0->maybe_java_subtype_of(p1)) ||
 966                (k0 && !k1->maybe_java_subtype_of(k0) && !k0->maybe_java_subtype_of(k1))) {
 967       unrelated_classes = true;
 968     } else if ((p0 && !p1->maybe_java_subtype_of(p0)) ||
 969                (k0 && !k1->maybe_java_subtype_of(k0))) {
 970       unrelated_classes = xklass1;
 971     } else if ((p0 && !p0->maybe_java_subtype_of(p1)) ||
 972                (k0 && !k0->maybe_java_subtype_of(k1))) {
 973       unrelated_classes = xklass0;
 974     }
 975 















 976     if (unrelated_classes) {
 977       // The oops classes are known to be unrelated. If the joined PTRs of
 978       // two oops is not Null and not Bottom, then we are sure that one
 979       // of the two oops is non-null, and the comparison will always fail.
 980       TypePtr::PTR jp = r0->join_ptr(r1->_ptr);
 981       if (jp != TypePtr::Null && jp != TypePtr::BotPTR) {
 982         return TypeInt::CC_GT;
 983       }
 984     }
 985   }
 986 
 987   // Known constants can be compared exactly
 988   // Null can be distinguished from any NotNull pointers
 989   // Unknown inputs makes an unknown result
 990   if( r0->singleton() ) {
 991     intptr_t bits0 = r0->get_con();
 992     if( r1->singleton() )
 993       return bits0 == r1->get_con() ? TypeInt::CC_EQ : TypeInt::CC_GT;
 994     return ( r1->_ptr == TypePtr::NotNull && bits0==0 ) ? TypeInt::CC_GT : TypeInt::CC;
 995   } else if( r1->singleton() ) {

1040   if (!mirror_type) return NULL;
1041 
1042   // x.getClass() == int.class can never be true (for all primitive types)
1043   // Return a ConP(NULL) node for this case.
1044   if (mirror_type->is_classless()) {
1045     return phase->makecon(TypePtr::NULL_PTR);
1046   }
1047 
1048   // return the ConP(Foo.klass)
1049   assert(mirror_type->is_klass(), "mirror_type should represent a Klass*");
1050   return phase->makecon(TypeKlassPtr::make(mirror_type->as_klass()));
1051 }
1052 
1053 //------------------------------Ideal------------------------------------------
1054 // Normalize comparisons between Java mirror loads to compare the klass instead.
1055 //
1056 // Also check for the case of comparing an unknown klass loaded from the primary
1057 // super-type array vs a known klass with no subtypes.  This amounts to
1058 // checking to see an unknown klass subtypes a known klass with no subtypes;
1059 // this only happens on an exact match.  We can shorten this test by 1 load.
1060 Node *CmpPNode::Ideal( PhaseGVN *phase, bool can_reshape ) {







1061   // Normalize comparisons between Java mirrors into comparisons of the low-
1062   // level klass, where a dependent load could be shortened.
1063   //
1064   // The new pattern has a nice effect of matching the same pattern used in the
1065   // fast path of instanceof/checkcast/Class.isInstance(), which allows
1066   // redundant exact type check be optimized away by GVN.
1067   // For example, in
1068   //   if (x.getClass() == Foo.class) {
1069   //     Foo foo = (Foo) x;
1070   //     // ... use a ...
1071   //   }
1072   // a CmpPNode could be shared between if_acmpne and checkcast
1073   {
1074     Node* k1 = isa_java_mirror_load(phase, in(1));
1075     Node* k2 = isa_java_mirror_load(phase, in(2));
1076     Node* conk2 = isa_const_java_mirror(phase, in(2));
1077 
1078     if (k1 && (k2 || conk2)) {
1079       Node* lhs = k1;
1080       Node* rhs = (k2 != NULL) ? k2 : conk2;

1112         superklass->is_abstract()) {
1113       // Make it come out always false:
1114       this->set_req(2, phase->makecon(TypePtr::NULL_PTR));
1115       return this;
1116     }
1117   }
1118 
1119   // Check for a LoadKlass from primary supertype array.
1120   // Any nested loadklass from loadklass+con must be from the p.s. array.
1121   if (ldk2->is_DecodeNKlass()) {
1122     // Keep ldk2 as DecodeN since it could be used in CmpP below.
1123     if (ldk2->in(1)->Opcode() != Op_LoadNKlass )
1124       return NULL;
1125   } else if (ldk2->Opcode() != Op_LoadKlass)
1126     return NULL;
1127 
1128   // Verify that we understand the situation
1129   if (con2 != (intptr_t) superklass->super_check_offset())
1130     return NULL;                // Might be element-klass loading from array klass
1131 








1132   // If 'superklass' has no subklasses and is not an interface, then we are
1133   // assured that the only input which will pass the type check is
1134   // 'superklass' itself.
1135   //
1136   // We could be more liberal here, and allow the optimization on interfaces
1137   // which have a single implementor.  This would require us to increase the
1138   // expressiveness of the add_dependency() mechanism.
1139   // %%% Do this after we fix TypeOopPtr:  Deps are expressive enough now.
1140 
1141   // Object arrays must have their base element have no subtypes
1142   while (superklass->is_obj_array_klass()) {
1143     ciType* elem = superklass->as_obj_array_klass()->element_type();
1144     superklass = elem->as_klass();
1145   }
1146   if (superklass->is_instance_klass()) {
1147     ciInstanceKlass* ik = superklass->as_instance_klass();
1148     if (ik->has_subklass() || ik->is_interface())  return NULL;
1149     // Add a dependency if there is a chance that a subclass will be added later.
1150     if (!ik->is_final()) {
1151       phase->C->dependencies()->assert_leaf_type(ik);

1255     if( t2_value_as_double == (double)t2_value_as_float ) {
1256       // Test value can be represented as a float
1257       // Eliminate the conversion to double and create new comparison
1258       Node *new_in1 = in(idx_f2d)->in(1);
1259       Node *new_in2 = phase->makecon( TypeF::make(t2_value_as_float) );
1260       if( idx_f2d != 1 ) {      // Must flip args to match original order
1261         Node *tmp = new_in1;
1262         new_in1 = new_in2;
1263         new_in2 = tmp;
1264       }
1265       CmpFNode *new_cmp = (Opcode() == Op_CmpD3)
1266         ? new CmpF3Node( new_in1, new_in2 )
1267         : new CmpFNode ( new_in1, new_in2 ) ;
1268       return new_cmp;           // Changed to CmpFNode
1269     }
1270     // Testing value required the precision of a double
1271   }
1272   return NULL;                  // No change
1273 }
1274 





































1275 
1276 //=============================================================================
1277 //------------------------------cc2logical-------------------------------------
1278 // Convert a condition code type to a logical type
1279 const Type *BoolTest::cc2logical( const Type *CC ) const {
1280   if( CC == Type::TOP ) return Type::TOP;
1281   if( CC->base() != Type::Int ) return TypeInt::BOOL; // Bottom or worse
1282   const TypeInt *ti = CC->is_int();
1283   if( ti->is_con() ) {          // Only 1 kind of condition codes set?
1284     // Match low order 2 bits
1285     int tmp = ((ti->get_con()&3) == (_test&3)) ? 1 : 0;
1286     if( _test & 4 ) tmp = 1-tmp;     // Optionally complement result
1287     return TypeInt::make(tmp);       // Boolean result
1288   }
1289 
1290   if( CC == TypeInt::CC_GE ) {
1291     if( _test == ge ) return TypeInt::ONE;
1292     if( _test == lt ) return TypeInt::ZERO;
1293   }
1294   if( CC == TypeInt::CC_LE ) {

  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "compiler/compileLog.hpp"
  27 #include "gc/shared/barrierSet.hpp"
  28 #include "gc/shared/c2/barrierSetC2.hpp"
  29 #include "memory/allocation.inline.hpp"
  30 #include "opto/addnode.hpp"
  31 #include "opto/callnode.hpp"
  32 #include "opto/cfgnode.hpp"
  33 #include "opto/inlinetypenode.hpp"
  34 #include "opto/loopnode.hpp"
  35 #include "opto/matcher.hpp"
  36 #include "opto/movenode.hpp"
  37 #include "opto/mulnode.hpp"
  38 #include "opto/opcodes.hpp"
  39 #include "opto/phaseX.hpp"
  40 #include "opto/subnode.hpp"
  41 #include "runtime/sharedRuntime.hpp"
  42 #include "utilities/moveBits.hpp"
  43 
  44 // Portions of code courtesy of Clifford Click
  45 
  46 // Optimization - Graph Style
  47 
  48 #include "math.h"
  49 
  50 //=============================================================================
  51 //------------------------------Identity---------------------------------------
  52 // If right input is a constant 0, return the left input.
  53 Node* SubNode::Identity(PhaseGVN* phase) {

 820     switch (in(1)->Opcode()) {
 821     case Op_CmpU3:              // Collapse a CmpU3/CmpI into a CmpU
 822       return new CmpUNode(in(1)->in(1),in(1)->in(2));
 823     case Op_CmpL3:              // Collapse a CmpL3/CmpI into a CmpL
 824       return new CmpLNode(in(1)->in(1),in(1)->in(2));
 825     case Op_CmpUL3:             // Collapse a CmpUL3/CmpI into a CmpUL
 826       return new CmpULNode(in(1)->in(1),in(1)->in(2));
 827     case Op_CmpF3:              // Collapse a CmpF3/CmpI into a CmpF
 828       return new CmpFNode(in(1)->in(1),in(1)->in(2));
 829     case Op_CmpD3:              // Collapse a CmpD3/CmpI into a CmpD
 830       return new CmpDNode(in(1)->in(1),in(1)->in(2));
 831     //case Op_SubI:
 832       // If (x - y) cannot overflow, then ((x - y) <?> 0)
 833       // can be turned into (x <?> y).
 834       // This is handled (with more general cases) by Ideal_sub_algebra.
 835     }
 836   }
 837   return NULL;                  // No change
 838 }
 839 
 840 //------------------------------Ideal------------------------------------------
 841 Node* CmpLNode::Ideal(PhaseGVN* phase, bool can_reshape) {
 842   Node* a = NULL;
 843   Node* b = NULL;
 844   if (is_double_null_check(phase, a, b) && (phase->type(a)->is_zero_type() || phase->type(b)->is_zero_type())) {
 845     // Degraded to a simple null check, use old acmp
 846     return new CmpPNode(a, b);
 847   }
 848   const TypeLong *t2 = phase->type(in(2))->isa_long();
 849   if (Opcode() == Op_CmpL && in(1)->Opcode() == Op_ConvI2L && t2 && t2->is_con()) {
 850     const jlong con = t2->get_con();
 851     if (con >= min_jint && con <= max_jint) {
 852       return new CmpINode(in(1)->in(1), phase->intcon((jint)con));
 853     }
 854   }
 855   return NULL;
 856 }
 857 
 858 // Match double null check emitted by Compile::optimize_acmp()
 859 bool CmpLNode::is_double_null_check(PhaseGVN* phase, Node*& a, Node*& b) const {
 860   if (in(1)->Opcode() == Op_OrL &&
 861       in(1)->in(1)->Opcode() == Op_CastP2X &&
 862       in(1)->in(2)->Opcode() == Op_CastP2X &&
 863       in(2)->bottom_type()->is_zero_type()) {
 864     assert(EnableValhalla, "unexpected double null check");
 865     a = in(1)->in(1)->in(1);
 866     b = in(1)->in(2)->in(1);
 867     return true;
 868   }
 869   return false;
 870 }
 871 
 872 //------------------------------Value------------------------------------------
 873 const Type* CmpLNode::Value(PhaseGVN* phase) const {
 874   Node* a = NULL;
 875   Node* b = NULL;
 876   if (is_double_null_check(phase, a, b) && (!phase->type(a)->maybe_null() || !phase->type(b)->maybe_null())) {
 877     // One operand is never NULL, emit constant false
 878     return TypeInt::CC_GT;
 879   }
 880   return SubNode::Value(phase);
 881 }
 882 
 883 //=============================================================================
 884 // Simplify a CmpL (compare 2 longs ) node, based on local information.
 885 // If both inputs are constants, compare them.
 886 const Type *CmpLNode::sub( const Type *t1, const Type *t2 ) const {
 887   const TypeLong *r0 = t1->is_long(); // Handy access
 888   const TypeLong *r1 = t2->is_long();
 889 
 890   if( r0->_hi < r1->_lo )       // Range is always low?
 891     return TypeInt::CC_LT;
 892   else if( r0->_lo > r1->_hi )  // Range is always high?
 893     return TypeInt::CC_GT;
 894 
 895   else if( r0->is_con() && r1->is_con() ) { // comparing constants?
 896     assert(r0->get_con() == r1->get_con(), "must be equal");
 897     return TypeInt::CC_EQ;      // Equal results.
 898   } else if( r0->_hi == r1->_lo ) // Range is never high?
 899     return TypeInt::CC_LE;
 900   else if( r0->_lo == r1->_hi ) // Range is never low?
 901     return TypeInt::CC_GE;
 902   return TypeInt::CC;           // else use worst case results

 988       if (MemNode::detect_ptr_independence(in1, alloc1, in2, alloc2, NULL)) {
 989         return TypeInt::CC_GT;  // different pointers
 990       }
 991     }
 992     bool    xklass0 = p0 ? p0->klass_is_exact() : k0->klass_is_exact();
 993     bool    xklass1 = p1 ? p1->klass_is_exact() : k1->klass_is_exact();
 994     bool unrelated_classes = false;
 995 
 996     if ((p0 && p0->is_same_java_type_as(p1)) ||
 997         (k0 && k0->is_same_java_type_as(k1))) {
 998     } else if ((p0 && !p1->maybe_java_subtype_of(p0) && !p0->maybe_java_subtype_of(p1)) ||
 999                (k0 && !k1->maybe_java_subtype_of(k0) && !k0->maybe_java_subtype_of(k1))) {
1000       unrelated_classes = true;
1001     } else if ((p0 && !p1->maybe_java_subtype_of(p0)) ||
1002                (k0 && !k1->maybe_java_subtype_of(k0))) {
1003       unrelated_classes = xklass1;
1004     } else if ((p0 && !p0->maybe_java_subtype_of(p1)) ||
1005                (k0 && !k0->maybe_java_subtype_of(k1))) {
1006       unrelated_classes = xklass0;
1007     }
1008     if (!unrelated_classes) {
1009       // Handle inline type arrays
1010       if ((r0->flatten_array() && r1->not_flatten_array()) ||
1011           (r1->flatten_array() && r0->not_flatten_array())) {
1012         // One type is flattened in arrays but the other type is not. Must be unrelated.
1013         unrelated_classes = true;
1014       } else if ((r0->is_not_flat() && r1->is_flat()) ||
1015                  (r1->is_not_flat() && r0->is_flat())) {
1016         // One type is a non-flattened array and the other type is a flattened array. Must be unrelated.
1017         unrelated_classes = true;
1018       } else if ((r0->is_not_null_free() && r1->is_null_free()) ||
1019                  (r1->is_not_null_free() && r0->is_null_free())) {
1020         // One type is a nullable array and the other type is a null-free array. Must be unrelated.
1021         unrelated_classes = true;
1022       }
1023     }
1024     if (unrelated_classes) {
1025       // The oops classes are known to be unrelated. If the joined PTRs of
1026       // two oops is not Null and not Bottom, then we are sure that one
1027       // of the two oops is non-null, and the comparison will always fail.
1028       TypePtr::PTR jp = r0->join_ptr(r1->_ptr);
1029       if (jp != TypePtr::Null && jp != TypePtr::BotPTR) {
1030         return TypeInt::CC_GT;
1031       }
1032     }
1033   }
1034 
1035   // Known constants can be compared exactly
1036   // Null can be distinguished from any NotNull pointers
1037   // Unknown inputs makes an unknown result
1038   if( r0->singleton() ) {
1039     intptr_t bits0 = r0->get_con();
1040     if( r1->singleton() )
1041       return bits0 == r1->get_con() ? TypeInt::CC_EQ : TypeInt::CC_GT;
1042     return ( r1->_ptr == TypePtr::NotNull && bits0==0 ) ? TypeInt::CC_GT : TypeInt::CC;
1043   } else if( r1->singleton() ) {

1088   if (!mirror_type) return NULL;
1089 
1090   // x.getClass() == int.class can never be true (for all primitive types)
1091   // Return a ConP(NULL) node for this case.
1092   if (mirror_type->is_classless()) {
1093     return phase->makecon(TypePtr::NULL_PTR);
1094   }
1095 
1096   // return the ConP(Foo.klass)
1097   assert(mirror_type->is_klass(), "mirror_type should represent a Klass*");
1098   return phase->makecon(TypeKlassPtr::make(mirror_type->as_klass()));
1099 }
1100 
1101 //------------------------------Ideal------------------------------------------
1102 // Normalize comparisons between Java mirror loads to compare the klass instead.
1103 //
1104 // Also check for the case of comparing an unknown klass loaded from the primary
1105 // super-type array vs a known klass with no subtypes.  This amounts to
1106 // checking to see an unknown klass subtypes a known klass with no subtypes;
1107 // this only happens on an exact match.  We can shorten this test by 1 load.
1108 Node* CmpPNode::Ideal(PhaseGVN *phase, bool can_reshape) {
1109   // TODO 8284443 in(1) could be cast?
1110   if (in(1)->is_InlineTypePtr() && phase->type(in(2))->is_zero_type()) {
1111     // Null checking a scalarized but nullable inline type. Check the IsInit
1112     // input instead of the oop input to avoid keeping buffer allocations alive.
1113     return new CmpINode(in(1)->as_InlineTypePtr()->get_is_init(), phase->intcon(0));
1114   }
1115 
1116   // Normalize comparisons between Java mirrors into comparisons of the low-
1117   // level klass, where a dependent load could be shortened.
1118   //
1119   // The new pattern has a nice effect of matching the same pattern used in the
1120   // fast path of instanceof/checkcast/Class.isInstance(), which allows
1121   // redundant exact type check be optimized away by GVN.
1122   // For example, in
1123   //   if (x.getClass() == Foo.class) {
1124   //     Foo foo = (Foo) x;
1125   //     // ... use a ...
1126   //   }
1127   // a CmpPNode could be shared between if_acmpne and checkcast
1128   {
1129     Node* k1 = isa_java_mirror_load(phase, in(1));
1130     Node* k2 = isa_java_mirror_load(phase, in(2));
1131     Node* conk2 = isa_const_java_mirror(phase, in(2));
1132 
1133     if (k1 && (k2 || conk2)) {
1134       Node* lhs = k1;
1135       Node* rhs = (k2 != NULL) ? k2 : conk2;

1167         superklass->is_abstract()) {
1168       // Make it come out always false:
1169       this->set_req(2, phase->makecon(TypePtr::NULL_PTR));
1170       return this;
1171     }
1172   }
1173 
1174   // Check for a LoadKlass from primary supertype array.
1175   // Any nested loadklass from loadklass+con must be from the p.s. array.
1176   if (ldk2->is_DecodeNKlass()) {
1177     // Keep ldk2 as DecodeN since it could be used in CmpP below.
1178     if (ldk2->in(1)->Opcode() != Op_LoadNKlass )
1179       return NULL;
1180   } else if (ldk2->Opcode() != Op_LoadKlass)
1181     return NULL;
1182 
1183   // Verify that we understand the situation
1184   if (con2 != (intptr_t) superklass->super_check_offset())
1185     return NULL;                // Might be element-klass loading from array klass
1186 
1187   // Do not fold the subtype check to an array klass pointer comparison for [V? arrays.
1188   // [QMyValue is a subtype of [LMyValue but the klass for [QMyValue is not equal to
1189   // the klass for [LMyValue. Do not bypass the klass load from the primary supertype array.
1190   if (superklass->is_obj_array_klass() && !superklass->as_array_klass()->is_elem_null_free() &&
1191       superklass->as_array_klass()->element_klass()->is_inlinetype()) {
1192     return NULL;
1193   }
1194 
1195   // If 'superklass' has no subklasses and is not an interface, then we are
1196   // assured that the only input which will pass the type check is
1197   // 'superklass' itself.
1198   //
1199   // We could be more liberal here, and allow the optimization on interfaces
1200   // which have a single implementor.  This would require us to increase the
1201   // expressiveness of the add_dependency() mechanism.
1202   // %%% Do this after we fix TypeOopPtr:  Deps are expressive enough now.
1203 
1204   // Object arrays must have their base element have no subtypes
1205   while (superklass->is_obj_array_klass()) {
1206     ciType* elem = superklass->as_obj_array_klass()->element_type();
1207     superklass = elem->as_klass();
1208   }
1209   if (superklass->is_instance_klass()) {
1210     ciInstanceKlass* ik = superklass->as_instance_klass();
1211     if (ik->has_subklass() || ik->is_interface())  return NULL;
1212     // Add a dependency if there is a chance that a subclass will be added later.
1213     if (!ik->is_final()) {
1214       phase->C->dependencies()->assert_leaf_type(ik);

1318     if( t2_value_as_double == (double)t2_value_as_float ) {
1319       // Test value can be represented as a float
1320       // Eliminate the conversion to double and create new comparison
1321       Node *new_in1 = in(idx_f2d)->in(1);
1322       Node *new_in2 = phase->makecon( TypeF::make(t2_value_as_float) );
1323       if( idx_f2d != 1 ) {      // Must flip args to match original order
1324         Node *tmp = new_in1;
1325         new_in1 = new_in2;
1326         new_in2 = tmp;
1327       }
1328       CmpFNode *new_cmp = (Opcode() == Op_CmpD3)
1329         ? new CmpF3Node( new_in1, new_in2 )
1330         : new CmpFNode ( new_in1, new_in2 ) ;
1331       return new_cmp;           // Changed to CmpFNode
1332     }
1333     // Testing value required the precision of a double
1334   }
1335   return NULL;                  // No change
1336 }
1337 
1338 //=============================================================================
1339 //------------------------------Value------------------------------------------
1340 const Type* FlatArrayCheckNode::Value(PhaseGVN* phase) const {
1341   bool all_not_flat = true;
1342   for (uint i = ArrayOrKlass; i < req(); ++i) {
1343     const Type* t = phase->type(in(i));
1344     if (t == Type::TOP) {
1345       return Type::TOP;
1346     }
1347     if (t->is_ptr()->is_flat()) {
1348       // One of the input arrays is flat, check always passes
1349       return TypeInt::CC_EQ;
1350     } else if (!t->is_ptr()->is_not_flat()) {
1351       // One of the input arrays might be flat
1352       all_not_flat = false;
1353     }
1354   }
1355   if (all_not_flat) {
1356     // None of the input arrays can be flat, check always fails
1357     return TypeInt::CC_GT;
1358   }
1359   return TypeInt::CC;
1360 }
1361 
1362 //------------------------------Ideal------------------------------------------
1363 Node* FlatArrayCheckNode::Ideal(PhaseGVN* phase, bool can_reshape) {
1364   bool changed = false;
1365   // Remove inputs that are known to be non-flat
1366   for (uint i = ArrayOrKlass; i < req(); ++i) {
1367     const Type* t = phase->type(in(i));
1368     if (t->isa_ptr() && t->is_ptr()->is_not_flat()) {
1369       del_req(i--);
1370       changed = true;
1371     }
1372   }
1373   return changed ? this : NULL;
1374 }
1375 
1376 //=============================================================================
1377 //------------------------------cc2logical-------------------------------------
1378 // Convert a condition code type to a logical type
1379 const Type *BoolTest::cc2logical( const Type *CC ) const {
1380   if( CC == Type::TOP ) return Type::TOP;
1381   if( CC->base() != Type::Int ) return TypeInt::BOOL; // Bottom or worse
1382   const TypeInt *ti = CC->is_int();
1383   if( ti->is_con() ) {          // Only 1 kind of condition codes set?
1384     // Match low order 2 bits
1385     int tmp = ((ti->get_con()&3) == (_test&3)) ? 1 : 0;
1386     if( _test & 4 ) tmp = 1-tmp;     // Optionally complement result
1387     return TypeInt::make(tmp);       // Boolean result
1388   }
1389 
1390   if( CC == TypeInt::CC_GE ) {
1391     if( _test == ge ) return TypeInt::ONE;
1392     if( _test == lt ) return TypeInt::ZERO;
1393   }
1394   if( CC == TypeInt::CC_LE ) {
< prev index next >