< prev index next >

src/hotspot/share/opto/mulnode.cpp

Print this page

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












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

 721     const TypeLong* t1 = phase->type( in(1) )->isa_long();
 722     if (t1 != nullptr && t1->_lo >= 0) {
 723       int bit_count = log2i_graceful(t1->_hi) + 1;
 724       jlong t1_support = jlong(max_julong >> (BitsPerJavaLong - bit_count));
 725       if ((t1_support & con) == t1_support)
 726         return usr;
 727     }
 728     uint lop = usr->Opcode();
 729     // Masking off the high bits of a unsigned-shift-right is not
 730     // needed either.
 731     if( lop == Op_URShiftL ) {
 732       const TypeInt *t12 = phase->type( usr->in(2) )->isa_int();
 733       if( t12 && t12->is_con() ) {  // Shift is by a constant
 734         int shift = t12->get_con();
 735         shift &= BitsPerJavaLong - 1;  // semantics of Java shifts
 736         jlong mask = max_julong >> shift;
 737         if( (mask&con) == mask )  // If AND is useless, skip it
 738           return usr;
 739       }
 740     }








 741   }
 742   return MulNode::Identity(phase);
 743 }
 744 
 745 //------------------------------Ideal------------------------------------------
 746 Node *AndLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
 747   // pattern similar to (v1 + (v2 << 2)) & 3 transformed to v1 & 3
 748   Node* progress = AndIL_add_shift_and_mask(phase, T_LONG);
 749   if (progress != nullptr) {
 750     return progress;
 751   }
 752 
 753   // Special case constant AND mask
 754   const TypeLong *t2 = phase->type( in(2) )->isa_long();
 755   if( !t2 || !t2->is_con() ) return MulNode::Ideal(phase, can_reshape);
 756   const jlong mask = t2->get_con();
 757 
 758   Node* in1 = in(1);
 759   int op = in1->Opcode();
 760 

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

 733     const TypeLong* t1 = phase->type( in(1) )->isa_long();
 734     if (t1 != nullptr && t1->_lo >= 0) {
 735       int bit_count = log2i_graceful(t1->_hi) + 1;
 736       jlong t1_support = jlong(max_julong >> (BitsPerJavaLong - bit_count));
 737       if ((t1_support & con) == t1_support)
 738         return usr;
 739     }
 740     uint lop = usr->Opcode();
 741     // Masking off the high bits of a unsigned-shift-right is not
 742     // needed either.
 743     if( lop == Op_URShiftL ) {
 744       const TypeInt *t12 = phase->type( usr->in(2) )->isa_int();
 745       if( t12 && t12->is_con() ) {  // Shift is by a constant
 746         int shift = t12->get_con();
 747         shift &= BitsPerJavaLong - 1;  // semantics of Java shifts
 748         jlong mask = max_julong >> shift;
 749         if( (mask&con) == mask )  // If AND is useless, skip it
 750           return usr;
 751       }
 752     }
 753 
 754     // Check if this is part of an inline type test
 755     if (con == markWord::inline_type_pattern && in(1)->is_Load() &&
 756         phase->type(in(1)->in(MemNode::Address))->is_inlinetypeptr() &&
 757         phase->type(in(1)->in(MemNode::Address))->is_ptr()->offset() == oopDesc::mark_offset_in_bytes()) {
 758       assert(EnableValhalla, "should only be used for inline types");
 759       return in(2); // Obj is known to be an inline type
 760     }
 761   }
 762   return MulNode::Identity(phase);
 763 }
 764 
 765 //------------------------------Ideal------------------------------------------
 766 Node *AndLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
 767   // pattern similar to (v1 + (v2 << 2)) & 3 transformed to v1 & 3
 768   Node* progress = AndIL_add_shift_and_mask(phase, T_LONG);
 769   if (progress != nullptr) {
 770     return progress;
 771   }
 772 
 773   // Special case constant AND mask
 774   const TypeLong *t2 = phase->type( in(2) )->isa_long();
 775   if( !t2 || !t2->is_con() ) return MulNode::Ideal(phase, can_reshape);
 776   const jlong mask = t2->get_con();
 777 
 778   Node* in1 = in(1);
 779   int op = in1->Opcode();
 780 
< prev index next >