< prev index next >

src/hotspot/share/opto/mulnode.cpp

Print this page

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













 202   // Either input is BOTTOM ==> the result is the local BOTTOM
 203   if( t1 == Type::BOTTOM || t2 == Type::BOTTOM )
 204     return bottom_type();
 205 
 206   return mul_ring(t1,t2);            // Local flavor of type multiplication
 207 }
 208 
 209 MulNode* MulNode::make(Node* in1, Node* in2, BasicType bt) {
 210   switch (bt) {
 211     case T_INT:
 212       return new MulINode(in1, in2);
 213     case T_LONG:
 214       return new MulLNode(in1, in2);
 215     default:
 216       fatal("Not implemented for %s", type2name(bt));
 217   }
 218   return nullptr;
 219 }
 220 
 221 MulNode* MulNode::make_and(Node* in1, Node* in2, BasicType bt) {

 819 
 820   // Masking off sign bits?  Dont make them!
 821   if (op == Op_RShiftL) {
 822     const TypeInt* t12 = phase->type(in1->in(2))->isa_int();
 823     if( t12 && t12->is_con() ) { // Shift is by a constant
 824       int shift = t12->get_con();
 825       shift &= BitsPerJavaLong - 1;  // semantics of Java shifts
 826       if (shift != 0) {
 827         const julong sign_bits_mask = ~(((julong)CONST64(1) << (julong)(BitsPerJavaLong - shift)) -1);
 828         // If the AND'ing of the 2 masks has no bits, then only original shifted
 829         // bits survive.  NO sign-extension bits survive the maskings.
 830         if( (sign_bits_mask & mask) == 0 ) {
 831           // Use zero-fill shift instead
 832           Node *zshift = phase->transform(new URShiftLNode(in1->in(1), in1->in(2)));
 833           return new AndLNode(zshift, in(2));
 834         }
 835       }
 836     }
 837   }
 838 









































 839   return MulNode::Ideal(phase, can_reshape);
 840 }
 841 
 842 LShiftNode* LShiftNode::make(Node* in1, Node* in2, BasicType bt) {
 843   switch (bt) {
 844     case T_INT:
 845       return new LShiftINode(in1, in2);
 846     case T_LONG:
 847       return new LShiftLNode(in1, in2);
 848     default:
 849       fatal("Not implemented for %s", type2name(bt));
 850   }
 851   return nullptr;
 852 }
 853 
 854 // Returns whether the shift amount is constant. If so, sets count.
 855 static bool const_shift_count(PhaseGVN* phase, const Node* shift_node, int* count) {
 856   const TypeInt* tcount = phase->type(shift_node->in(2))->isa_int();
 857   if (tcount != nullptr && tcount->is_con()) {
 858     *count = tcount->get_con();

 182   return progress;
 183 }
 184 
 185 //------------------------------Value-----------------------------------------
 186 const Type* MulNode::Value(PhaseGVN* phase) const {
 187   const Type *t1 = phase->type( in(1) );
 188   const Type *t2 = phase->type( in(2) );
 189   // Either input is TOP ==> the result is TOP
 190   if( t1 == Type::TOP ) return Type::TOP;
 191   if( t2 == Type::TOP ) return Type::TOP;
 192 
 193   // Either input is ZERO ==> the result is ZERO.
 194   // Not valid for floats or doubles since +0.0 * -0.0 --> +0.0
 195   int op = Opcode();
 196   if( op == Op_MulI || op == Op_AndI || op == Op_MulL || op == Op_AndL ) {
 197     const Type *zero = add_id();        // The multiplicative zero
 198     if( t1->higher_equal( zero ) ) return zero;
 199     if( t2->higher_equal( zero ) ) return zero;
 200   }
 201 
 202   // TODO 8350865 Still needed? Yes, I think this is from PhaseMacroExpand::expand_mh_intrinsic_return
 203   // Code pattern on return from a call that returns an __Value.  Can
 204   // be optimized away if the return value turns out to be an oop.
 205   if (op == Op_AndX &&
 206       in(1) != nullptr &&
 207       in(1)->Opcode() == Op_CastP2X &&
 208       in(1)->in(1) != nullptr &&
 209       phase->type(in(1)->in(1))->isa_oopptr() &&
 210       t2->isa_intptr_t()->_lo >= 0 &&
 211       t2->isa_intptr_t()->_hi <= MinObjAlignmentInBytesMask) {
 212     return add_id();
 213   }
 214 
 215   // Either input is BOTTOM ==> the result is the local BOTTOM
 216   if( t1 == Type::BOTTOM || t2 == Type::BOTTOM )
 217     return bottom_type();
 218 
 219   return mul_ring(t1,t2);            // Local flavor of type multiplication
 220 }
 221 
 222 MulNode* MulNode::make(Node* in1, Node* in2, BasicType bt) {
 223   switch (bt) {
 224     case T_INT:
 225       return new MulINode(in1, in2);
 226     case T_LONG:
 227       return new MulLNode(in1, in2);
 228     default:
 229       fatal("Not implemented for %s", type2name(bt));
 230   }
 231   return nullptr;
 232 }
 233 
 234 MulNode* MulNode::make_and(Node* in1, Node* in2, BasicType bt) {

 832 
 833   // Masking off sign bits?  Dont make them!
 834   if (op == Op_RShiftL) {
 835     const TypeInt* t12 = phase->type(in1->in(2))->isa_int();
 836     if( t12 && t12->is_con() ) { // Shift is by a constant
 837       int shift = t12->get_con();
 838       shift &= BitsPerJavaLong - 1;  // semantics of Java shifts
 839       if (shift != 0) {
 840         const julong sign_bits_mask = ~(((julong)CONST64(1) << (julong)(BitsPerJavaLong - shift)) -1);
 841         // If the AND'ing of the 2 masks has no bits, then only original shifted
 842         // bits survive.  NO sign-extension bits survive the maskings.
 843         if( (sign_bits_mask & mask) == 0 ) {
 844           // Use zero-fill shift instead
 845           Node *zshift = phase->transform(new URShiftLNode(in1->in(1), in1->in(2)));
 846           return new AndLNode(zshift, in(2));
 847         }
 848       }
 849     }
 850   }
 851 
 852   // Search for GraphKit::mark_word_test patterns and fold the test if the result is statically known
 853   Node* load1 = in(1);
 854   Node* load2 = nullptr;
 855   if (load1->is_Phi() && phase->type(load1)->isa_long()) {
 856     load1 = in(1)->in(1);
 857     load2 = in(1)->in(2);
 858   }
 859   if (load1 != nullptr && load1->is_Load() && phase->type(load1)->isa_long() &&
 860       (load2 == nullptr || (load2->is_Load() && phase->type(load2)->isa_long()))) {
 861     const TypePtr* adr_t1 = phase->type(load1->in(MemNode::Address))->isa_ptr();
 862     const TypePtr* adr_t2 = (load2 != nullptr) ? phase->type(load2->in(MemNode::Address))->isa_ptr() : nullptr;
 863     if (adr_t1 != nullptr && adr_t1->offset() == oopDesc::mark_offset_in_bytes() &&
 864         (load2 == nullptr || (adr_t2 != nullptr && adr_t2->offset() == in_bytes(Klass::prototype_header_offset())))) {
 865       if (mask == markWord::inline_type_pattern) {
 866         if (adr_t1->is_inlinetypeptr()) {
 867           set_req_X(1, in(2), phase);
 868           return this;
 869         } else if (!adr_t1->can_be_inline_type()) {
 870           set_req_X(1, phase->longcon(0), phase);
 871           return this;
 872         }
 873       } else if (mask == markWord::null_free_array_bit_in_place) {
 874         if (adr_t1->is_null_free()) {
 875           set_req_X(1, in(2), phase);
 876           return this;
 877         } else if (adr_t1->is_not_null_free()) {
 878           set_req_X(1, phase->longcon(0), phase);
 879           return this;
 880         }
 881       } else if (mask == markWord::flat_array_bit_in_place) {
 882         if (adr_t1->is_flat()) {
 883           set_req_X(1, in(2), phase);
 884           return this;
 885         } else if (adr_t1->is_not_flat()) {
 886           set_req_X(1, phase->longcon(0), phase);
 887           return this;
 888         }
 889       }
 890     }
 891   }
 892 
 893   return MulNode::Ideal(phase, can_reshape);
 894 }
 895 
 896 LShiftNode* LShiftNode::make(Node* in1, Node* in2, BasicType bt) {
 897   switch (bt) {
 898     case T_INT:
 899       return new LShiftINode(in1, in2);
 900     case T_LONG:
 901       return new LShiftLNode(in1, in2);
 902     default:
 903       fatal("Not implemented for %s", type2name(bt));
 904   }
 905   return nullptr;
 906 }
 907 
 908 // Returns whether the shift amount is constant. If so, sets count.
 909 static bool const_shift_count(PhaseGVN* phase, const Node* shift_node, int* count) {
 910   const TypeInt* tcount = phase->type(shift_node->in(2))->isa_int();
 911   if (tcount != nullptr && tcount->is_con()) {
 912     *count = tcount->get_con();
< prev index next >