< 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/opaquenode.hpp"
  38 #include "opto/opcodes.hpp"
  39 #include "opto/phaseX.hpp"
  40 #include "opto/subnode.hpp"
  41 #include "runtime/sharedRuntime.hpp"
  42 #include "utilities/reverse_bits.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.

 857     switch (in(1)->Opcode()) {
 858     case Op_CmpU3:              // Collapse a CmpU3/CmpI into a CmpU
 859       return new CmpUNode(in(1)->in(1),in(1)->in(2));
 860     case Op_CmpL3:              // Collapse a CmpL3/CmpI into a CmpL
 861       return new CmpLNode(in(1)->in(1),in(1)->in(2));
 862     case Op_CmpUL3:             // Collapse a CmpUL3/CmpI into a CmpUL
 863       return new CmpULNode(in(1)->in(1),in(1)->in(2));
 864     case Op_CmpF3:              // Collapse a CmpF3/CmpI into a CmpF
 865       return new CmpFNode(in(1)->in(1),in(1)->in(2));
 866     case Op_CmpD3:              // Collapse a CmpD3/CmpI into a CmpD
 867       return new CmpDNode(in(1)->in(1),in(1)->in(2));
 868     //case Op_SubI:
 869       // If (x - y) cannot overflow, then ((x - y) <?> 0)
 870       // can be turned into (x <?> y).
 871       // This is handled (with more general cases) by Ideal_sub_algebra.
 872     }
 873   }
 874   return nullptr;                  // No change
 875 }
 876 
 877 Node *CmpLNode::Ideal( PhaseGVN *phase, bool can_reshape ) {







 878   const TypeLong *t2 = phase->type(in(2))->isa_long();
 879   if (Opcode() == Op_CmpL && in(1)->Opcode() == Op_ConvI2L && t2 && t2->is_con()) {
 880     const jlong con = t2->get_con();
 881     if (con >= min_jint && con <= max_jint) {
 882       return new CmpINode(in(1)->in(1), phase->intcon((jint)con));
 883     }
 884   }
 885   return nullptr;
 886 }
 887 

























 888 //=============================================================================
 889 // Simplify a CmpL (compare 2 longs ) node, based on local information.
 890 // If both inputs are constants, compare them.
 891 const Type *CmpLNode::sub( const Type *t1, const Type *t2 ) const {
 892   const TypeLong *r0 = t1->is_long(); // Handy access
 893   const TypeLong *r1 = t2->is_long();
 894 
 895   if( r0->_hi < r1->_lo )       // Range is always low?
 896     return TypeInt::CC_LT;
 897   else if( r0->_lo > r1->_hi )  // Range is always high?
 898     return TypeInt::CC_GT;
 899 
 900   else if( r0->is_con() && r1->is_con() ) { // comparing constants?
 901     assert(r0->get_con() == r1->get_con(), "must be equal");
 902     return TypeInt::CC_EQ;      // Equal results.
 903   } else if( r0->_hi == r1->_lo ) // Range is never high?
 904     return TypeInt::CC_LE;
 905   else if( r0->_lo == r1->_hi ) // Range is never low?
 906     return TypeInt::CC_GE;
 907   return TypeInt::CC;           // else use worst case results

 993       if (MemNode::detect_ptr_independence(in1, alloc1, in2, alloc2, nullptr)) {
 994         return TypeInt::CC_GT;  // different pointers
 995       }
 996     }
 997     bool    xklass0 = p0 ? p0->klass_is_exact() : k0->klass_is_exact();
 998     bool    xklass1 = p1 ? p1->klass_is_exact() : k1->klass_is_exact();
 999     bool unrelated_classes = false;
1000 
1001     if ((p0 && p0->is_same_java_type_as(p1)) ||
1002         (k0 && k0->is_same_java_type_as(k1))) {
1003     } else if ((p0 && !p1->maybe_java_subtype_of(p0) && !p0->maybe_java_subtype_of(p1)) ||
1004                (k0 && !k1->maybe_java_subtype_of(k0) && !k0->maybe_java_subtype_of(k1))) {
1005       unrelated_classes = true;
1006     } else if ((p0 && !p1->maybe_java_subtype_of(p0)) ||
1007                (k0 && !k1->maybe_java_subtype_of(k0))) {
1008       unrelated_classes = xklass1;
1009     } else if ((p0 && !p0->maybe_java_subtype_of(p1)) ||
1010                (k0 && !k0->maybe_java_subtype_of(k1))) {
1011       unrelated_classes = xklass0;
1012     }
1013 















1014     if (unrelated_classes) {
1015       // The oops classes are known to be unrelated. If the joined PTRs of
1016       // two oops is not Null and not Bottom, then we are sure that one
1017       // of the two oops is non-null, and the comparison will always fail.
1018       TypePtr::PTR jp = r0->join_ptr(r1->_ptr);
1019       if (jp != TypePtr::Null && jp != TypePtr::BotPTR) {
1020         return TypeInt::CC_GT;
1021       }
1022     }
1023   }
1024 
1025   // Known constants can be compared exactly
1026   // Null can be distinguished from any NotNull pointers
1027   // Unknown inputs makes an unknown result
1028   if( r0->singleton() ) {
1029     intptr_t bits0 = r0->get_con();
1030     if( r1->singleton() )
1031       return bits0 == r1->get_con() ? TypeInt::CC_EQ : TypeInt::CC_GT;
1032     return ( r1->_ptr == TypePtr::NotNull && bits0==0 ) ? TypeInt::CC_GT : TypeInt::CC;
1033   } else if( r1->singleton() ) {

1078   if (!mirror_type) return nullptr;
1079 
1080   // x.getClass() == int.class can never be true (for all primitive types)
1081   // Return a ConP(null) node for this case.
1082   if (mirror_type->is_classless()) {
1083     return phase->makecon(TypePtr::NULL_PTR);
1084   }
1085 
1086   // return the ConP(Foo.klass)
1087   assert(mirror_type->is_klass(), "mirror_type should represent a Klass*");
1088   return phase->makecon(TypeKlassPtr::make(mirror_type->as_klass(), Type::trust_interfaces));
1089 }
1090 
1091 //------------------------------Ideal------------------------------------------
1092 // Normalize comparisons between Java mirror loads to compare the klass instead.
1093 //
1094 // Also check for the case of comparing an unknown klass loaded from the primary
1095 // super-type array vs a known klass with no subtypes.  This amounts to
1096 // checking to see an unknown klass subtypes a known klass with no subtypes;
1097 // this only happens on an exact match.  We can shorten this test by 1 load.
1098 Node *CmpPNode::Ideal( PhaseGVN *phase, bool can_reshape ) {







1099   // Normalize comparisons between Java mirrors into comparisons of the low-
1100   // level klass, where a dependent load could be shortened.
1101   //
1102   // The new pattern has a nice effect of matching the same pattern used in the
1103   // fast path of instanceof/checkcast/Class.isInstance(), which allows
1104   // redundant exact type check be optimized away by GVN.
1105   // For example, in
1106   //   if (x.getClass() == Foo.class) {
1107   //     Foo foo = (Foo) x;
1108   //     // ... use a ...
1109   //   }
1110   // a CmpPNode could be shared between if_acmpne and checkcast
1111   {
1112     Node* k1 = isa_java_mirror_load(phase, in(1));
1113     Node* k2 = isa_java_mirror_load(phase, in(2));
1114     Node* conk2 = isa_const_java_mirror(phase, in(2));
1115 
1116     if (k1 && (k2 || conk2)) {
1117       Node* lhs = k1;
1118       Node* rhs = (k2 != nullptr) ? k2 : conk2;

1150         superklass->is_abstract()) {
1151       // Make it come out always false:
1152       this->set_req(2, phase->makecon(TypePtr::NULL_PTR));
1153       return this;
1154     }
1155   }
1156 
1157   // Check for a LoadKlass from primary supertype array.
1158   // Any nested loadklass from loadklass+con must be from the p.s. array.
1159   if (ldk2->is_DecodeNKlass()) {
1160     // Keep ldk2 as DecodeN since it could be used in CmpP below.
1161     if (ldk2->in(1)->Opcode() != Op_LoadNKlass )
1162       return nullptr;
1163   } else if (ldk2->Opcode() != Op_LoadKlass)
1164     return nullptr;
1165 
1166   // Verify that we understand the situation
1167   if (con2 != (intptr_t) superklass->super_check_offset())
1168     return nullptr;                // Might be element-klass loading from array klass
1169 








1170   // If 'superklass' has no subklasses and is not an interface, then we are
1171   // assured that the only input which will pass the type check is
1172   // 'superklass' itself.
1173   //
1174   // We could be more liberal here, and allow the optimization on interfaces
1175   // which have a single implementor.  This would require us to increase the
1176   // expressiveness of the add_dependency() mechanism.
1177   // %%% Do this after we fix TypeOopPtr:  Deps are expressive enough now.
1178 
1179   // Object arrays must have their base element have no subtypes
1180   while (superklass->is_obj_array_klass()) {
1181     ciType* elem = superklass->as_obj_array_klass()->element_type();
1182     superklass = elem->as_klass();
1183   }
1184   if (superklass->is_instance_klass()) {
1185     ciInstanceKlass* ik = superklass->as_instance_klass();
1186     if (ik->has_subklass() || ik->is_interface())  return nullptr;
1187     // Add a dependency if there is a chance that a subclass will be added later.
1188     if (!ik->is_final()) {
1189       phase->C->dependencies()->assert_leaf_type(ik);

1293     if( t2_value_as_double == (double)t2_value_as_float ) {
1294       // Test value can be represented as a float
1295       // Eliminate the conversion to double and create new comparison
1296       Node *new_in1 = in(idx_f2d)->in(1);
1297       Node *new_in2 = phase->makecon( TypeF::make(t2_value_as_float) );
1298       if( idx_f2d != 1 ) {      // Must flip args to match original order
1299         Node *tmp = new_in1;
1300         new_in1 = new_in2;
1301         new_in2 = tmp;
1302       }
1303       CmpFNode *new_cmp = (Opcode() == Op_CmpD3)
1304         ? new CmpF3Node( new_in1, new_in2 )
1305         : new CmpFNode ( new_in1, new_in2 ) ;
1306       return new_cmp;           // Changed to CmpFNode
1307     }
1308     // Testing value required the precision of a double
1309   }
1310   return nullptr;                  // No change
1311 }
1312 





































1313 
1314 //=============================================================================
1315 //------------------------------cc2logical-------------------------------------
1316 // Convert a condition code type to a logical type
1317 const Type *BoolTest::cc2logical( const Type *CC ) const {
1318   if( CC == Type::TOP ) return Type::TOP;
1319   if( CC->base() != Type::Int ) return TypeInt::BOOL; // Bottom or worse
1320   const TypeInt *ti = CC->is_int();
1321   if( ti->is_con() ) {          // Only 1 kind of condition codes set?
1322     // Match low order 2 bits
1323     int tmp = ((ti->get_con()&3) == (_test&3)) ? 1 : 0;
1324     if( _test & 4 ) tmp = 1-tmp;     // Optionally complement result
1325     return TypeInt::make(tmp);       // Boolean result
1326   }
1327 
1328   if( CC == TypeInt::CC_GE ) {
1329     if( _test == ge ) return TypeInt::ONE;
1330     if( _test == lt ) return TypeInt::ZERO;
1331   }
1332   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/opaquenode.hpp"
  39 #include "opto/opcodes.hpp"
  40 #include "opto/phaseX.hpp"
  41 #include "opto/subnode.hpp"
  42 #include "runtime/sharedRuntime.hpp"
  43 #include "utilities/reverse_bits.hpp"
  44 
  45 // Portions of code courtesy of Clifford Click
  46 
  47 // Optimization - Graph Style
  48 
  49 #include "math.h"
  50 
  51 //=============================================================================
  52 //------------------------------Identity---------------------------------------
  53 // If right input is a constant 0, return the left input.

 858     switch (in(1)->Opcode()) {
 859     case Op_CmpU3:              // Collapse a CmpU3/CmpI into a CmpU
 860       return new CmpUNode(in(1)->in(1),in(1)->in(2));
 861     case Op_CmpL3:              // Collapse a CmpL3/CmpI into a CmpL
 862       return new CmpLNode(in(1)->in(1),in(1)->in(2));
 863     case Op_CmpUL3:             // Collapse a CmpUL3/CmpI into a CmpUL
 864       return new CmpULNode(in(1)->in(1),in(1)->in(2));
 865     case Op_CmpF3:              // Collapse a CmpF3/CmpI into a CmpF
 866       return new CmpFNode(in(1)->in(1),in(1)->in(2));
 867     case Op_CmpD3:              // Collapse a CmpD3/CmpI into a CmpD
 868       return new CmpDNode(in(1)->in(1),in(1)->in(2));
 869     //case Op_SubI:
 870       // If (x - y) cannot overflow, then ((x - y) <?> 0)
 871       // can be turned into (x <?> y).
 872       // This is handled (with more general cases) by Ideal_sub_algebra.
 873     }
 874   }
 875   return nullptr;                  // No change
 876 }
 877 
 878 //------------------------------Ideal------------------------------------------
 879 Node* CmpLNode::Ideal(PhaseGVN* phase, bool can_reshape) {
 880   Node* a = nullptr;
 881   Node* b = nullptr;
 882   if (is_double_null_check(phase, a, b) && (phase->type(a)->is_zero_type() || phase->type(b)->is_zero_type())) {
 883     // Degraded to a simple null check, use old acmp
 884     return new CmpPNode(a, b);
 885   }
 886   const TypeLong *t2 = phase->type(in(2))->isa_long();
 887   if (Opcode() == Op_CmpL && in(1)->Opcode() == Op_ConvI2L && t2 && t2->is_con()) {
 888     const jlong con = t2->get_con();
 889     if (con >= min_jint && con <= max_jint) {
 890       return new CmpINode(in(1)->in(1), phase->intcon((jint)con));
 891     }
 892   }
 893   return nullptr;
 894 }
 895 
 896 // Match double null check emitted by Compile::optimize_acmp()
 897 bool CmpLNode::is_double_null_check(PhaseGVN* phase, Node*& a, Node*& b) const {
 898   if (in(1)->Opcode() == Op_OrL &&
 899       in(1)->in(1)->Opcode() == Op_CastP2X &&
 900       in(1)->in(2)->Opcode() == Op_CastP2X &&
 901       in(2)->bottom_type()->is_zero_type()) {
 902     assert(EnableValhalla, "unexpected double null check");
 903     a = in(1)->in(1)->in(1);
 904     b = in(1)->in(2)->in(1);
 905     return true;
 906   }
 907   return false;
 908 }
 909 
 910 //------------------------------Value------------------------------------------
 911 const Type* CmpLNode::Value(PhaseGVN* phase) const {
 912   Node* a = nullptr;
 913   Node* b = nullptr;
 914   if (is_double_null_check(phase, a, b) && (!phase->type(a)->maybe_null() || !phase->type(b)->maybe_null())) {
 915     // One operand is never nullptr, emit constant false
 916     return TypeInt::CC_GT;
 917   }
 918   return SubNode::Value(phase);
 919 }
 920 
 921 //=============================================================================
 922 // Simplify a CmpL (compare 2 longs ) node, based on local information.
 923 // If both inputs are constants, compare them.
 924 const Type *CmpLNode::sub( const Type *t1, const Type *t2 ) const {
 925   const TypeLong *r0 = t1->is_long(); // Handy access
 926   const TypeLong *r1 = t2->is_long();
 927 
 928   if( r0->_hi < r1->_lo )       // Range is always low?
 929     return TypeInt::CC_LT;
 930   else if( r0->_lo > r1->_hi )  // Range is always high?
 931     return TypeInt::CC_GT;
 932 
 933   else if( r0->is_con() && r1->is_con() ) { // comparing constants?
 934     assert(r0->get_con() == r1->get_con(), "must be equal");
 935     return TypeInt::CC_EQ;      // Equal results.
 936   } else if( r0->_hi == r1->_lo ) // Range is never high?
 937     return TypeInt::CC_LE;
 938   else if( r0->_lo == r1->_hi ) // Range is never low?
 939     return TypeInt::CC_GE;
 940   return TypeInt::CC;           // else use worst case results

1026       if (MemNode::detect_ptr_independence(in1, alloc1, in2, alloc2, nullptr)) {
1027         return TypeInt::CC_GT;  // different pointers
1028       }
1029     }
1030     bool    xklass0 = p0 ? p0->klass_is_exact() : k0->klass_is_exact();
1031     bool    xklass1 = p1 ? p1->klass_is_exact() : k1->klass_is_exact();
1032     bool unrelated_classes = false;
1033 
1034     if ((p0 && p0->is_same_java_type_as(p1)) ||
1035         (k0 && k0->is_same_java_type_as(k1))) {
1036     } else if ((p0 && !p1->maybe_java_subtype_of(p0) && !p0->maybe_java_subtype_of(p1)) ||
1037                (k0 && !k1->maybe_java_subtype_of(k0) && !k0->maybe_java_subtype_of(k1))) {
1038       unrelated_classes = true;
1039     } else if ((p0 && !p1->maybe_java_subtype_of(p0)) ||
1040                (k0 && !k1->maybe_java_subtype_of(k0))) {
1041       unrelated_classes = xklass1;
1042     } else if ((p0 && !p0->maybe_java_subtype_of(p1)) ||
1043                (k0 && !k0->maybe_java_subtype_of(k1))) {
1044       unrelated_classes = xklass0;
1045     }
1046     if (!unrelated_classes) {
1047       // Handle inline type arrays
1048       if ((r0->flat_array() && r1->not_flat_array()) ||
1049           (r1->flat_array() && r0->not_flat_array())) {
1050         // One type is in flat arrays but the other type is not. Must be unrelated.
1051         unrelated_classes = true;
1052       } else if ((r0->is_not_flat() && r1->is_flat()) ||
1053                  (r1->is_not_flat() && r0->is_flat())) {
1054         // One type is a non-flat array and the other type is a flat array. Must be unrelated.
1055         unrelated_classes = true;
1056       } else if ((r0->is_not_null_free() && r1->is_null_free()) ||
1057                  (r1->is_not_null_free() && r0->is_null_free())) {
1058         // One type is a nullable array and the other type is a null-free array. Must be unrelated.
1059         unrelated_classes = true;
1060       }
1061     }
1062     if (unrelated_classes) {
1063       // The oops classes are known to be unrelated. If the joined PTRs of
1064       // two oops is not Null and not Bottom, then we are sure that one
1065       // of the two oops is non-null, and the comparison will always fail.
1066       TypePtr::PTR jp = r0->join_ptr(r1->_ptr);
1067       if (jp != TypePtr::Null && jp != TypePtr::BotPTR) {
1068         return TypeInt::CC_GT;
1069       }
1070     }
1071   }
1072 
1073   // Known constants can be compared exactly
1074   // Null can be distinguished from any NotNull pointers
1075   // Unknown inputs makes an unknown result
1076   if( r0->singleton() ) {
1077     intptr_t bits0 = r0->get_con();
1078     if( r1->singleton() )
1079       return bits0 == r1->get_con() ? TypeInt::CC_EQ : TypeInt::CC_GT;
1080     return ( r1->_ptr == TypePtr::NotNull && bits0==0 ) ? TypeInt::CC_GT : TypeInt::CC;
1081   } else if( r1->singleton() ) {

1126   if (!mirror_type) return nullptr;
1127 
1128   // x.getClass() == int.class can never be true (for all primitive types)
1129   // Return a ConP(null) node for this case.
1130   if (mirror_type->is_classless()) {
1131     return phase->makecon(TypePtr::NULL_PTR);
1132   }
1133 
1134   // return the ConP(Foo.klass)
1135   assert(mirror_type->is_klass(), "mirror_type should represent a Klass*");
1136   return phase->makecon(TypeKlassPtr::make(mirror_type->as_klass(), Type::trust_interfaces));
1137 }
1138 
1139 //------------------------------Ideal------------------------------------------
1140 // Normalize comparisons between Java mirror loads to compare the klass instead.
1141 //
1142 // Also check for the case of comparing an unknown klass loaded from the primary
1143 // super-type array vs a known klass with no subtypes.  This amounts to
1144 // checking to see an unknown klass subtypes a known klass with no subtypes;
1145 // this only happens on an exact match.  We can shorten this test by 1 load.
1146 Node* CmpPNode::Ideal(PhaseGVN *phase, bool can_reshape) {
1147   // TODO 8284443 in(1) could be cast?
1148   if (in(1)->is_InlineType() && phase->type(in(2))->is_zero_type()) {
1149     // Null checking a scalarized but nullable inline type. Check the IsInit
1150     // input instead of the oop input to avoid keeping buffer allocations alive.
1151     return new CmpINode(in(1)->as_InlineType()->get_is_init(), phase->intcon(0));
1152   }
1153 
1154   // Normalize comparisons between Java mirrors into comparisons of the low-
1155   // level klass, where a dependent load could be shortened.
1156   //
1157   // The new pattern has a nice effect of matching the same pattern used in the
1158   // fast path of instanceof/checkcast/Class.isInstance(), which allows
1159   // redundant exact type check be optimized away by GVN.
1160   // For example, in
1161   //   if (x.getClass() == Foo.class) {
1162   //     Foo foo = (Foo) x;
1163   //     // ... use a ...
1164   //   }
1165   // a CmpPNode could be shared between if_acmpne and checkcast
1166   {
1167     Node* k1 = isa_java_mirror_load(phase, in(1));
1168     Node* k2 = isa_java_mirror_load(phase, in(2));
1169     Node* conk2 = isa_const_java_mirror(phase, in(2));
1170 
1171     if (k1 && (k2 || conk2)) {
1172       Node* lhs = k1;
1173       Node* rhs = (k2 != nullptr) ? k2 : conk2;

1205         superklass->is_abstract()) {
1206       // Make it come out always false:
1207       this->set_req(2, phase->makecon(TypePtr::NULL_PTR));
1208       return this;
1209     }
1210   }
1211 
1212   // Check for a LoadKlass from primary supertype array.
1213   // Any nested loadklass from loadklass+con must be from the p.s. array.
1214   if (ldk2->is_DecodeNKlass()) {
1215     // Keep ldk2 as DecodeN since it could be used in CmpP below.
1216     if (ldk2->in(1)->Opcode() != Op_LoadNKlass )
1217       return nullptr;
1218   } else if (ldk2->Opcode() != Op_LoadKlass)
1219     return nullptr;
1220 
1221   // Verify that we understand the situation
1222   if (con2 != (intptr_t) superklass->super_check_offset())
1223     return nullptr;                // Might be element-klass loading from array klass
1224 
1225   // Do not fold the subtype check to an array klass pointer comparison for [V? arrays.
1226   // [QMyValue is a subtype of [LMyValue but the klass for [QMyValue is not equal to
1227   // the klass for [LMyValue. Do not bypass the klass load from the primary supertype array.
1228   if (superklass->is_obj_array_klass() && !superklass->as_array_klass()->is_elem_null_free() &&
1229       superklass->as_array_klass()->element_klass()->is_inlinetype()) {
1230     return nullptr;
1231   }
1232 
1233   // If 'superklass' has no subklasses and is not an interface, then we are
1234   // assured that the only input which will pass the type check is
1235   // 'superklass' itself.
1236   //
1237   // We could be more liberal here, and allow the optimization on interfaces
1238   // which have a single implementor.  This would require us to increase the
1239   // expressiveness of the add_dependency() mechanism.
1240   // %%% Do this after we fix TypeOopPtr:  Deps are expressive enough now.
1241 
1242   // Object arrays must have their base element have no subtypes
1243   while (superklass->is_obj_array_klass()) {
1244     ciType* elem = superklass->as_obj_array_klass()->element_type();
1245     superklass = elem->as_klass();
1246   }
1247   if (superklass->is_instance_klass()) {
1248     ciInstanceKlass* ik = superklass->as_instance_klass();
1249     if (ik->has_subklass() || ik->is_interface())  return nullptr;
1250     // Add a dependency if there is a chance that a subclass will be added later.
1251     if (!ik->is_final()) {
1252       phase->C->dependencies()->assert_leaf_type(ik);

1356     if( t2_value_as_double == (double)t2_value_as_float ) {
1357       // Test value can be represented as a float
1358       // Eliminate the conversion to double and create new comparison
1359       Node *new_in1 = in(idx_f2d)->in(1);
1360       Node *new_in2 = phase->makecon( TypeF::make(t2_value_as_float) );
1361       if( idx_f2d != 1 ) {      // Must flip args to match original order
1362         Node *tmp = new_in1;
1363         new_in1 = new_in2;
1364         new_in2 = tmp;
1365       }
1366       CmpFNode *new_cmp = (Opcode() == Op_CmpD3)
1367         ? new CmpF3Node( new_in1, new_in2 )
1368         : new CmpFNode ( new_in1, new_in2 ) ;
1369       return new_cmp;           // Changed to CmpFNode
1370     }
1371     // Testing value required the precision of a double
1372   }
1373   return nullptr;                  // No change
1374 }
1375 
1376 //=============================================================================
1377 //------------------------------Value------------------------------------------
1378 const Type* FlatArrayCheckNode::Value(PhaseGVN* phase) const {
1379   bool all_not_flat = true;
1380   for (uint i = ArrayOrKlass; i < req(); ++i) {
1381     const Type* t = phase->type(in(i));
1382     if (t == Type::TOP) {
1383       return Type::TOP;
1384     }
1385     if (t->is_ptr()->is_flat()) {
1386       // One of the input arrays is flat, check always passes
1387       return TypeInt::CC_EQ;
1388     } else if (!t->is_ptr()->is_not_flat()) {
1389       // One of the input arrays might be flat
1390       all_not_flat = false;
1391     }
1392   }
1393   if (all_not_flat) {
1394     // None of the input arrays can be flat, check always fails
1395     return TypeInt::CC_GT;
1396   }
1397   return TypeInt::CC;
1398 }
1399 
1400 //------------------------------Ideal------------------------------------------
1401 Node* FlatArrayCheckNode::Ideal(PhaseGVN* phase, bool can_reshape) {
1402   bool changed = false;
1403   // Remove inputs that are known to be non-flat
1404   for (uint i = ArrayOrKlass; i < req(); ++i) {
1405     const Type* t = phase->type(in(i));
1406     if (t->isa_ptr() && t->is_ptr()->is_not_flat()) {
1407       del_req(i--);
1408       changed = true;
1409     }
1410   }
1411   return changed ? this : nullptr;
1412 }
1413 
1414 //=============================================================================
1415 //------------------------------cc2logical-------------------------------------
1416 // Convert a condition code type to a logical type
1417 const Type *BoolTest::cc2logical( const Type *CC ) const {
1418   if( CC == Type::TOP ) return Type::TOP;
1419   if( CC->base() != Type::Int ) return TypeInt::BOOL; // Bottom or worse
1420   const TypeInt *ti = CC->is_int();
1421   if( ti->is_con() ) {          // Only 1 kind of condition codes set?
1422     // Match low order 2 bits
1423     int tmp = ((ti->get_con()&3) == (_test&3)) ? 1 : 0;
1424     if( _test & 4 ) tmp = 1-tmp;     // Optionally complement result
1425     return TypeInt::make(tmp);       // Boolean result
1426   }
1427 
1428   if( CC == TypeInt::CC_GE ) {
1429     if( _test == ge ) return TypeInt::ONE;
1430     if( _test == lt ) return TypeInt::ZERO;
1431   }
1432   if( CC == TypeInt::CC_LE ) {
< prev index next >