< prev index next >

src/hotspot/share/opto/mulnode.cpp

Print this page

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












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

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








 690   }
 691   return MulNode::Identity(phase);
 692 }
 693 
 694 //------------------------------Ideal------------------------------------------
 695 Node *AndLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
 696   // pattern similar to (v1 + (v2 << 2)) & 3 transformed to v1 & 3
 697   Node* progress = AndIL_add_shift_and_mask(phase, T_LONG);
 698   if (progress != NULL) {
 699     return progress;
 700   }
 701 
 702   // Special case constant AND mask
 703   const TypeLong *t2 = phase->type( in(2) )->isa_long();
 704   if( !t2 || !t2->is_con() ) return MulNode::Ideal(phase, can_reshape);
 705   const jlong mask = t2->get_con();
 706 
 707   Node* in1 = in(1);
 708   int op = in1->Opcode();
 709 

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

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