< 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:

 660     const TypeLong* t1 = phase->type( in(1) )->isa_long();
 661     if (t1 != NULL && t1->_lo >= 0) {
 662       int bit_count = log2i_graceful(t1->_hi) + 1;
 663       jlong t1_support = jlong(max_julong >> (BitsPerJavaLong - bit_count));
 664       if ((t1_support & con) == t1_support)
 665         return usr;
 666     }
 667     uint lop = usr->Opcode();
 668     // Masking off the high bits of a unsigned-shift-right is not
 669     // needed either.
 670     if( lop == Op_URShiftL ) {
 671       const TypeInt *t12 = phase->type( usr->in(2) )->isa_int();
 672       if( t12 && t12->is_con() ) {  // Shift is by a constant
 673         int shift = t12->get_con();
 674         shift &= BitsPerJavaLong - 1;  // semantics of Java shifts
 675         jlong mask = max_julong >> shift;
 676         if( (mask&con) == mask )  // If AND is useless, skip it
 677           return usr;
 678       }
 679     }








 680   }
 681   return MulNode::Identity(phase);
 682 }
 683 
 684 //------------------------------Ideal------------------------------------------
 685 Node *AndLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
 686   // pattern similar to (v1 + (v2 << 2)) & 3 transformed to v1 & 3
 687   Node* progress = AndIL_add_shift_and_mask(phase, T_LONG);
 688   if (progress != NULL) {
 689     return progress;
 690   }
 691 
 692   // Special case constant AND mask
 693   const TypeLong *t2 = phase->type( in(2) )->isa_long();
 694   if( !t2 || !t2->is_con() ) return MulNode::Ideal(phase, can_reshape);
 695   const jlong mask = t2->get_con();
 696 
 697   Node* in1 = in(1);
 698   int op = in1->Opcode();
 699 

 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) != NULL &&
 204       in(1)->Opcode() == Op_CastP2X &&
 205       in(1)->in(1) != NULL &&
 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:

 672     const TypeLong* t1 = phase->type( in(1) )->isa_long();
 673     if (t1 != NULL && t1->_lo >= 0) {
 674       int bit_count = log2i_graceful(t1->_hi) + 1;
 675       jlong t1_support = jlong(max_julong >> (BitsPerJavaLong - bit_count));
 676       if ((t1_support & con) == t1_support)
 677         return usr;
 678     }
 679     uint lop = usr->Opcode();
 680     // Masking off the high bits of a unsigned-shift-right is not
 681     // needed either.
 682     if( lop == Op_URShiftL ) {
 683       const TypeInt *t12 = phase->type( usr->in(2) )->isa_int();
 684       if( t12 && t12->is_con() ) {  // Shift is by a constant
 685         int shift = t12->get_con();
 686         shift &= BitsPerJavaLong - 1;  // semantics of Java shifts
 687         jlong mask = max_julong >> shift;
 688         if( (mask&con) == mask )  // If AND is useless, skip it
 689           return usr;
 690       }
 691     }
 692 
 693     // Check if this is part of an inline type test
 694     if (con == markWord::inline_type_pattern && in(1)->is_Load() &&
 695         phase->type(in(1)->in(MemNode::Address))->is_inlinetypeptr() &&
 696         phase->type(in(1)->in(MemNode::Address))->is_ptr()->offset() == oopDesc::mark_offset_in_bytes()) {
 697       assert(EnableValhalla, "should only be used for inline types");
 698       return in(2); // Obj is known to be an inline type
 699     }
 700   }
 701   return MulNode::Identity(phase);
 702 }
 703 
 704 //------------------------------Ideal------------------------------------------
 705 Node *AndLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
 706   // pattern similar to (v1 + (v2 << 2)) & 3 transformed to v1 & 3
 707   Node* progress = AndIL_add_shift_and_mask(phase, T_LONG);
 708   if (progress != NULL) {
 709     return progress;
 710   }
 711 
 712   // Special case constant AND mask
 713   const TypeLong *t2 = phase->type( in(2) )->isa_long();
 714   if( !t2 || !t2->is_con() ) return MulNode::Ideal(phase, can_reshape);
 715   const jlong mask = t2->get_con();
 716 
 717   Node* in1 = in(1);
 718   int op = in1->Opcode();
 719 
< prev index next >