< prev index next >

src/hotspot/share/opto/mulnode.cpp

Print this page

 181   return progress;
 182 }
 183 
 184 //------------------------------Value-----------------------------------------
 185 const Type* MulNode::Value(PhaseGVN* phase) const {
 186   const Type *t1 = phase->type( in(1) );
 187   const Type *t2 = phase->type( in(2) );
 188   // Either input is TOP ==> the result is TOP
 189   if( t1 == Type::TOP ) return Type::TOP;
 190   if( t2 == Type::TOP ) return Type::TOP;
 191 
 192   // Either input is ZERO ==> the result is ZERO.
 193   // Not valid for floats or doubles since +0.0 * -0.0 --> +0.0
 194   int op = Opcode();
 195   if( op == Op_MulI || op == Op_AndI || op == Op_MulL || op == Op_AndL ) {
 196     const Type *zero = add_id();        // The multiplicative zero
 197     if( t1->higher_equal( zero ) ) return zero;
 198     if( t2->higher_equal( zero ) ) return zero;
 199   }
 200 












 201   // Either input is BOTTOM ==> the result is the local BOTTOM
 202   if( t1 == Type::BOTTOM || t2 == Type::BOTTOM )
 203     return bottom_type();
 204 
 205 #if defined(IA32)
 206   // Can't trust native compilers to properly fold strict double
 207   // multiplication with round-to-zero on this platform.
 208   if (op == Op_MulD) {
 209     return TypeD::DOUBLE;
 210   }
 211 #endif
 212 
 213   return mul_ring(t1,t2);            // Local flavor of type multiplication
 214 }
 215 
 216 MulNode* MulNode::make(Node* in1, Node* in2, BasicType bt) {
 217   switch (bt) {
 218     case T_INT:
 219       return new MulINode(in1, in2);
 220     case T_LONG:

 906     return new ConvI2LNode(andi);
 907   }
 908 
 909   // Masking off sign bits?  Dont make them!
 910   if (op == Op_RShiftL) {
 911     const TypeInt* t12 = phase->type(in1->in(2))->isa_int();
 912     if( t12 && t12->is_con() ) { // Shift is by a constant
 913       int shift = t12->get_con();
 914       shift &= BitsPerJavaLong - 1;  // semantics of Java shifts
 915       const julong sign_bits_mask = ~(((julong)CONST64(1) << (julong)(BitsPerJavaLong - shift)) -1);
 916       // If the AND'ing of the 2 masks has no bits, then only original shifted
 917       // bits survive.  NO sign-extension bits survive the maskings.
 918       if( (sign_bits_mask & mask) == 0 ) {
 919         // Use zero-fill shift instead
 920         Node *zshift = phase->transform(new URShiftLNode(in1->in(1), in1->in(2)));
 921         return new AndLNode(zshift, in(2));
 922       }
 923     }
 924   }
 925 









































 926   return MulNode::Ideal(phase, can_reshape);
 927 }
 928 
 929 LShiftNode* LShiftNode::make(Node* in1, Node* in2, BasicType bt) {
 930   switch (bt) {
 931     case T_INT:
 932       return new LShiftINode(in1, in2);
 933     case T_LONG:
 934       return new LShiftLNode(in1, in2);
 935     default:
 936       fatal("Not implemented for %s", type2name(bt));
 937   }
 938   return nullptr;
 939 }
 940 
 941 //=============================================================================
 942 
 943 static bool const_shift_count(PhaseGVN* phase, Node* shiftNode, int* count) {
 944   const TypeInt* tcount = phase->type(shiftNode->in(2))->isa_int();
 945   if (tcount != nullptr && tcount->is_con()) {

 181   return progress;
 182 }
 183 
 184 //------------------------------Value-----------------------------------------
 185 const Type* MulNode::Value(PhaseGVN* phase) const {
 186   const Type *t1 = phase->type( in(1) );
 187   const Type *t2 = phase->type( in(2) );
 188   // Either input is TOP ==> the result is TOP
 189   if( t1 == Type::TOP ) return Type::TOP;
 190   if( t2 == Type::TOP ) return Type::TOP;
 191 
 192   // Either input is ZERO ==> the result is ZERO.
 193   // Not valid for floats or doubles since +0.0 * -0.0 --> +0.0
 194   int op = Opcode();
 195   if( op == Op_MulI || op == Op_AndI || op == Op_MulL || op == Op_AndL ) {
 196     const Type *zero = add_id();        // The multiplicative zero
 197     if( t1->higher_equal( zero ) ) return zero;
 198     if( t2->higher_equal( zero ) ) return zero;
 199   }
 200 
 201   // Code pattern on return from a call that returns an __Value.  Can
 202   // be optimized away if the return value turns out to be an oop.
 203   if (op == Op_AndX &&
 204       in(1) != nullptr &&
 205       in(1)->Opcode() == Op_CastP2X &&
 206       in(1)->in(1) != nullptr &&
 207       phase->type(in(1)->in(1))->isa_oopptr() &&
 208       t2->isa_intptr_t()->_lo >= 0 &&
 209       t2->isa_intptr_t()->_hi <= MinObjAlignmentInBytesMask) {
 210     return add_id();
 211   }
 212 
 213   // Either input is BOTTOM ==> the result is the local BOTTOM
 214   if( t1 == Type::BOTTOM || t2 == Type::BOTTOM )
 215     return bottom_type();
 216 
 217 #if defined(IA32)
 218   // Can't trust native compilers to properly fold strict double
 219   // multiplication with round-to-zero on this platform.
 220   if (op == Op_MulD) {
 221     return TypeD::DOUBLE;
 222   }
 223 #endif
 224 
 225   return mul_ring(t1,t2);            // Local flavor of type multiplication
 226 }
 227 
 228 MulNode* MulNode::make(Node* in1, Node* in2, BasicType bt) {
 229   switch (bt) {
 230     case T_INT:
 231       return new MulINode(in1, in2);
 232     case T_LONG:

 918     return new ConvI2LNode(andi);
 919   }
 920 
 921   // Masking off sign bits?  Dont make them!
 922   if (op == Op_RShiftL) {
 923     const TypeInt* t12 = phase->type(in1->in(2))->isa_int();
 924     if( t12 && t12->is_con() ) { // Shift is by a constant
 925       int shift = t12->get_con();
 926       shift &= BitsPerJavaLong - 1;  // semantics of Java shifts
 927       const julong sign_bits_mask = ~(((julong)CONST64(1) << (julong)(BitsPerJavaLong - shift)) -1);
 928       // If the AND'ing of the 2 masks has no bits, then only original shifted
 929       // bits survive.  NO sign-extension bits survive the maskings.
 930       if( (sign_bits_mask & mask) == 0 ) {
 931         // Use zero-fill shift instead
 932         Node *zshift = phase->transform(new URShiftLNode(in1->in(1), in1->in(2)));
 933         return new AndLNode(zshift, in(2));
 934       }
 935     }
 936   }
 937 
 938   // Search for GraphKit::mark_word_test patterns and fold the test if the result is statically known
 939   Node* load1 = in(1);
 940   Node* load2 = nullptr;
 941   if (load1->is_Phi() && phase->type(load1)->isa_long()) {
 942     load1 = in(1)->in(1);
 943     load2 = in(1)->in(2);
 944   }
 945   if (load1 != nullptr && load1->is_Load() && phase->type(load1)->isa_long() &&
 946       (load2 == nullptr || (load2->is_Load() && phase->type(load2)->isa_long()))) {
 947     const TypePtr* adr_t1 = phase->type(load1->in(MemNode::Address))->isa_ptr();
 948     const TypePtr* adr_t2 = (load2 != nullptr) ? phase->type(load2->in(MemNode::Address))->isa_ptr() : nullptr;
 949     if (adr_t1 != nullptr && adr_t1->offset() == oopDesc::mark_offset_in_bytes() &&
 950         (load2 == nullptr || (adr_t2 != nullptr && adr_t2->offset() == in_bytes(Klass::prototype_header_offset())))) {
 951       if (mask == markWord::inline_type_pattern) {
 952         if (adr_t1->is_inlinetypeptr()) {
 953           set_req_X(1, in(2), phase);
 954           return this;
 955         } else if (!adr_t1->can_be_inline_type()) {
 956           set_req_X(1, phase->longcon(0), phase);
 957           return this;
 958         }
 959       } else if (mask == markWord::null_free_array_bit_in_place) {
 960         if (adr_t1->is_null_free()) {
 961           set_req_X(1, in(2), phase);
 962           return this;
 963         } else if (adr_t1->is_not_null_free()) {
 964           set_req_X(1, phase->longcon(0), phase);
 965           return this;
 966         }
 967       } else if (mask == markWord::flat_array_bit_in_place) {
 968         if (adr_t1->is_flat()) {
 969           set_req_X(1, in(2), phase);
 970           return this;
 971         } else if (adr_t1->is_not_flat()) {
 972           set_req_X(1, phase->longcon(0), phase);
 973           return this;
 974         }
 975       }
 976     }
 977   }
 978 
 979   return MulNode::Ideal(phase, can_reshape);
 980 }
 981 
 982 LShiftNode* LShiftNode::make(Node* in1, Node* in2, BasicType bt) {
 983   switch (bt) {
 984     case T_INT:
 985       return new LShiftINode(in1, in2);
 986     case T_LONG:
 987       return new LShiftLNode(in1, in2);
 988     default:
 989       fatal("Not implemented for %s", type2name(bt));
 990   }
 991   return nullptr;
 992 }
 993 
 994 //=============================================================================
 995 
 996 static bool const_shift_count(PhaseGVN* phase, Node* shiftNode, int* count) {
 997   const TypeInt* tcount = phase->type(shiftNode->in(2))->isa_int();
 998   if (tcount != nullptr && tcount->is_con()) {
< prev index next >