< 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 
  42 // Portions of code courtesy of Clifford Click
  43 
  44 // Optimization - Graph Style
  45 
  46 #include "math.h"
  47 
  48 //=============================================================================
  49 //------------------------------Identity---------------------------------------
  50 // If right input is a constant 0, return the left input.
  51 Node* SubNode::Identity(PhaseGVN* phase) {
  52   assert(in(1) != this, "Must already have called Value");

 847 
 848 //------------------------------Idealize---------------------------------------
 849 Node *CmpINode::Ideal( PhaseGVN *phase, bool can_reshape ) {
 850   if (phase->type(in(2))->higher_equal(TypeInt::ZERO)) {
 851     switch (in(1)->Opcode()) {
 852     case Op_CmpL3:              // Collapse a CmpL3/CmpI into a CmpL
 853       return new CmpLNode(in(1)->in(1),in(1)->in(2));
 854     case Op_CmpF3:              // Collapse a CmpF3/CmpI into a CmpF
 855       return new CmpFNode(in(1)->in(1),in(1)->in(2));
 856     case Op_CmpD3:              // Collapse a CmpD3/CmpI into a CmpD
 857       return new CmpDNode(in(1)->in(1),in(1)->in(2));
 858     //case Op_SubI:
 859       // If (x - y) cannot overflow, then ((x - y) <?> 0)
 860       // can be turned into (x <?> y).
 861       // This is handled (with more general cases) by Ideal_sub_algebra.
 862     }
 863   }
 864   return NULL;                  // No change
 865 }
 866 
 867 Node *CmpLNode::Ideal( PhaseGVN *phase, bool can_reshape ) {







 868   const TypeLong *t2 = phase->type(in(2))->isa_long();
 869   if (Opcode() == Op_CmpL && in(1)->Opcode() == Op_ConvI2L && t2 && t2->is_con()) {
 870     const jlong con = t2->get_con();
 871     if (con >= min_jint && con <= max_jint) {
 872       return new CmpINode(in(1)->in(1), phase->intcon((jint)con));
 873     }
 874   }
 875   return NULL;
 876 }
 877 

























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

1016         klass1->is_loaded() && !klass1->is_interface() &&
1017         (!klass0->is_obj_array_klass() ||
1018          !klass0->as_obj_array_klass()->base_element_klass()->is_interface()) &&
1019         (!klass1->is_obj_array_klass() ||
1020          !klass1->as_obj_array_klass()->base_element_klass()->is_interface())) {
1021       bool unrelated_classes = false;
1022       // See if neither subclasses the other, or if the class on top
1023       // is precise.  In either of these cases, the compare is known
1024       // to fail if at least one of the pointers is provably not null.
1025       if (klass0->equals(klass1)) {  // if types are unequal but klasses are equal
1026         // Do nothing; we know nothing for imprecise types
1027       } else if (klass0->is_subtype_of(klass1)) {
1028         // If klass1's type is PRECISE, then classes are unrelated.
1029         unrelated_classes = xklass1;
1030       } else if (klass1->is_subtype_of(klass0)) {
1031         // If klass0's type is PRECISE, then classes are unrelated.
1032         unrelated_classes = xklass0;
1033       } else {                  // Neither subtypes the other
1034         unrelated_classes = true;
1035       }
















1036       if (unrelated_classes) {
1037         // The oops classes are known to be unrelated. If the joined PTRs of
1038         // two oops is not Null and not Bottom, then we are sure that one
1039         // of the two oops is non-null, and the comparison will always fail.
1040         TypePtr::PTR jp = r0->join_ptr(r1->_ptr);
1041         if (jp != TypePtr::Null && jp != TypePtr::BotPTR) {
1042           return TypeInt::CC_GT;
1043         }
1044       }
1045     }
1046   }
1047 
1048   // Known constants can be compared exactly
1049   // Null can be distinguished from any NotNull pointers
1050   // Unknown inputs makes an unknown result
1051   if( r0->singleton() ) {
1052     intptr_t bits0 = r0->get_con();
1053     if( r1->singleton() )
1054       return bits0 == r1->get_con() ? TypeInt::CC_EQ : TypeInt::CC_GT;
1055     return ( r1->_ptr == TypePtr::NotNull && bits0==0 ) ? TypeInt::CC_GT : TypeInt::CC;

1101   if (!mirror_type) return NULL;
1102 
1103   // x.getClass() == int.class can never be true (for all primitive types)
1104   // Return a ConP(NULL) node for this case.
1105   if (mirror_type->is_classless()) {
1106     return phase->makecon(TypePtr::NULL_PTR);
1107   }
1108 
1109   // return the ConP(Foo.klass)
1110   assert(mirror_type->is_klass(), "mirror_type should represent a Klass*");
1111   return phase->makecon(TypeKlassPtr::make(mirror_type->as_klass()));
1112 }
1113 
1114 //------------------------------Ideal------------------------------------------
1115 // Normalize comparisons between Java mirror loads to compare the klass instead.
1116 //
1117 // Also check for the case of comparing an unknown klass loaded from the primary
1118 // super-type array vs a known klass with no subtypes.  This amounts to
1119 // checking to see an unknown klass subtypes a known klass with no subtypes;
1120 // this only happens on an exact match.  We can shorten this test by 1 load.
1121 Node *CmpPNode::Ideal( PhaseGVN *phase, bool can_reshape ) {







1122   // Normalize comparisons between Java mirrors into comparisons of the low-
1123   // level klass, where a dependent load could be shortened.
1124   //
1125   // The new pattern has a nice effect of matching the same pattern used in the
1126   // fast path of instanceof/checkcast/Class.isInstance(), which allows
1127   // redundant exact type check be optimized away by GVN.
1128   // For example, in
1129   //   if (x.getClass() == Foo.class) {
1130   //     Foo foo = (Foo) x;
1131   //     // ... use a ...
1132   //   }
1133   // a CmpPNode could be shared between if_acmpne and checkcast
1134   {
1135     Node* k1 = isa_java_mirror_load(phase, in(1));
1136     Node* k2 = isa_java_mirror_load(phase, in(2));
1137     Node* conk2 = isa_const_java_mirror(phase, in(2));
1138 
1139     if (k1 && (k2 || conk2)) {
1140       Node* lhs = k1;
1141       Node* rhs = (k2 != NULL) ? k2 : conk2;

1173         superklass->is_abstract()) {
1174       // Make it come out always false:
1175       this->set_req(2, phase->makecon(TypePtr::NULL_PTR));
1176       return this;
1177     }
1178   }
1179 
1180   // Check for a LoadKlass from primary supertype array.
1181   // Any nested loadklass from loadklass+con must be from the p.s. array.
1182   if (ldk2->is_DecodeNKlass()) {
1183     // Keep ldk2 as DecodeN since it could be used in CmpP below.
1184     if (ldk2->in(1)->Opcode() != Op_LoadNKlass )
1185       return NULL;
1186   } else if (ldk2->Opcode() != Op_LoadKlass)
1187     return NULL;
1188 
1189   // Verify that we understand the situation
1190   if (con2 != (intptr_t) superklass->super_check_offset())
1191     return NULL;                // Might be element-klass loading from array klass
1192 








1193   // If 'superklass' has no subklasses and is not an interface, then we are
1194   // assured that the only input which will pass the type check is
1195   // 'superklass' itself.
1196   //
1197   // We could be more liberal here, and allow the optimization on interfaces
1198   // which have a single implementor.  This would require us to increase the
1199   // expressiveness of the add_dependency() mechanism.
1200   // %%% Do this after we fix TypeOopPtr:  Deps are expressive enough now.
1201 
1202   // Object arrays must have their base element have no subtypes
1203   while (superklass->is_obj_array_klass()) {
1204     ciType* elem = superklass->as_obj_array_klass()->element_type();
1205     superklass = elem->as_klass();
1206   }
1207   if (superklass->is_instance_klass()) {
1208     ciInstanceKlass* ik = superklass->as_instance_klass();
1209     if (ik->has_subklass() || ik->is_interface())  return NULL;
1210     // Add a dependency if there is a chance that a subclass will be added later.
1211     if (!ik->is_final()) {
1212       phase->C->dependencies()->assert_leaf_type(ik);

1316     if( t2_value_as_double == (double)t2_value_as_float ) {
1317       // Test value can be represented as a float
1318       // Eliminate the conversion to double and create new comparison
1319       Node *new_in1 = in(idx_f2d)->in(1);
1320       Node *new_in2 = phase->makecon( TypeF::make(t2_value_as_float) );
1321       if( idx_f2d != 1 ) {      // Must flip args to match original order
1322         Node *tmp = new_in1;
1323         new_in1 = new_in2;
1324         new_in2 = tmp;
1325       }
1326       CmpFNode *new_cmp = (Opcode() == Op_CmpD3)
1327         ? new CmpF3Node( new_in1, new_in2 )
1328         : new CmpFNode ( new_in1, new_in2 ) ;
1329       return new_cmp;           // Changed to CmpFNode
1330     }
1331     // Testing value required the precision of a double
1332   }
1333   return NULL;                  // No change
1334 }
1335 





































1336 
1337 //=============================================================================
1338 //------------------------------cc2logical-------------------------------------
1339 // Convert a condition code type to a logical type
1340 const Type *BoolTest::cc2logical( const Type *CC ) const {
1341   if( CC == Type::TOP ) return Type::TOP;
1342   if( CC->base() != Type::Int ) return TypeInt::BOOL; // Bottom or worse
1343   const TypeInt *ti = CC->is_int();
1344   if( ti->is_con() ) {          // Only 1 kind of condition codes set?
1345     // Match low order 2 bits
1346     int tmp = ((ti->get_con()&3) == (_test&3)) ? 1 : 0;
1347     if( _test & 4 ) tmp = 1-tmp;     // Optionally complement result
1348     return TypeInt::make(tmp);       // Boolean result
1349   }
1350 
1351   if( CC == TypeInt::CC_GE ) {
1352     if( _test == ge ) return TypeInt::ONE;
1353     if( _test == lt ) return TypeInt::ZERO;
1354   }
1355   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 
  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) {
  53   assert(in(1) != this, "Must already have called Value");

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

1049         klass1->is_loaded() && !klass1->is_interface() &&
1050         (!klass0->is_obj_array_klass() ||
1051          !klass0->as_obj_array_klass()->base_element_klass()->is_interface()) &&
1052         (!klass1->is_obj_array_klass() ||
1053          !klass1->as_obj_array_klass()->base_element_klass()->is_interface())) {
1054       bool unrelated_classes = false;
1055       // See if neither subclasses the other, or if the class on top
1056       // is precise.  In either of these cases, the compare is known
1057       // to fail if at least one of the pointers is provably not null.
1058       if (klass0->equals(klass1)) {  // if types are unequal but klasses are equal
1059         // Do nothing; we know nothing for imprecise types
1060       } else if (klass0->is_subtype_of(klass1)) {
1061         // If klass1's type is PRECISE, then classes are unrelated.
1062         unrelated_classes = xklass1;
1063       } else if (klass1->is_subtype_of(klass0)) {
1064         // If klass0's type is PRECISE, then classes are unrelated.
1065         unrelated_classes = xklass0;
1066       } else {                  // Neither subtypes the other
1067         unrelated_classes = true;
1068       }
1069       if (!unrelated_classes) {
1070         // Handle inline type arrays
1071         if ((r0->flatten_array() && (!r1->can_be_inline_type() || (klass1->is_inlinetype() && !klass1->flatten_array()))) ||
1072             (r1->flatten_array() && (!r0->can_be_inline_type() || (klass0->is_inlinetype() && !klass0->flatten_array())))) {
1073           // One type is flattened in arrays but the other type is not. Must be unrelated.
1074           unrelated_classes = true;
1075         } else if ((r0->is_not_flat() && klass1->is_flat_array_klass()) ||
1076                    (r1->is_not_flat() && klass0->is_flat_array_klass())) {
1077           // One type is a non-flattened array and the other type is a flattened array. Must be unrelated.
1078           unrelated_classes = true;
1079         } else if ((r0->is_not_null_free() && klass1->is_array_klass() && klass1->as_array_klass()->is_elem_null_free()) ||
1080                    (r1->is_not_null_free() && klass0->is_array_klass() && klass0->as_array_klass()->is_elem_null_free())) {
1081           // One type is a non-null-free array and the other type is a null-free array. Must be unrelated.
1082           unrelated_classes = true;
1083         }
1084       }
1085       if (unrelated_classes) {
1086         // The oops classes are known to be unrelated. If the joined PTRs of
1087         // two oops is not Null and not Bottom, then we are sure that one
1088         // of the two oops is non-null, and the comparison will always fail.
1089         TypePtr::PTR jp = r0->join_ptr(r1->_ptr);
1090         if (jp != TypePtr::Null && jp != TypePtr::BotPTR) {
1091           return TypeInt::CC_GT;
1092         }
1093       }
1094     }
1095   }
1096 
1097   // Known constants can be compared exactly
1098   // Null can be distinguished from any NotNull pointers
1099   // Unknown inputs makes an unknown result
1100   if( r0->singleton() ) {
1101     intptr_t bits0 = r0->get_con();
1102     if( r1->singleton() )
1103       return bits0 == r1->get_con() ? TypeInt::CC_EQ : TypeInt::CC_GT;
1104     return ( r1->_ptr == TypePtr::NotNull && bits0==0 ) ? TypeInt::CC_GT : TypeInt::CC;

1150   if (!mirror_type) return NULL;
1151 
1152   // x.getClass() == int.class can never be true (for all primitive types)
1153   // Return a ConP(NULL) node for this case.
1154   if (mirror_type->is_classless()) {
1155     return phase->makecon(TypePtr::NULL_PTR);
1156   }
1157 
1158   // return the ConP(Foo.klass)
1159   assert(mirror_type->is_klass(), "mirror_type should represent a Klass*");
1160   return phase->makecon(TypeKlassPtr::make(mirror_type->as_klass()));
1161 }
1162 
1163 //------------------------------Ideal------------------------------------------
1164 // Normalize comparisons between Java mirror loads to compare the klass instead.
1165 //
1166 // Also check for the case of comparing an unknown klass loaded from the primary
1167 // super-type array vs a known klass with no subtypes.  This amounts to
1168 // checking to see an unknown klass subtypes a known klass with no subtypes;
1169 // this only happens on an exact match.  We can shorten this test by 1 load.
1170 Node* CmpPNode::Ideal(PhaseGVN *phase, bool can_reshape) {
1171   // TODO 8284443 in(1) could be cast?
1172   if (in(1)->is_InlineTypePtr() && phase->type(in(2))->is_zero_type()) {
1173     // Null checking a scalarized but nullable inline type. Check the IsInit
1174     // input instead of the oop input to avoid keeping buffer allocations alive.
1175     return new CmpINode(in(1)->as_InlineTypePtr()->get_is_init(), phase->intcon(0));
1176   }
1177 
1178   // Normalize comparisons between Java mirrors into comparisons of the low-
1179   // level klass, where a dependent load could be shortened.
1180   //
1181   // The new pattern has a nice effect of matching the same pattern used in the
1182   // fast path of instanceof/checkcast/Class.isInstance(), which allows
1183   // redundant exact type check be optimized away by GVN.
1184   // For example, in
1185   //   if (x.getClass() == Foo.class) {
1186   //     Foo foo = (Foo) x;
1187   //     // ... use a ...
1188   //   }
1189   // a CmpPNode could be shared between if_acmpne and checkcast
1190   {
1191     Node* k1 = isa_java_mirror_load(phase, in(1));
1192     Node* k2 = isa_java_mirror_load(phase, in(2));
1193     Node* conk2 = isa_const_java_mirror(phase, in(2));
1194 
1195     if (k1 && (k2 || conk2)) {
1196       Node* lhs = k1;
1197       Node* rhs = (k2 != NULL) ? k2 : conk2;

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

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