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

 688     const TypeLong* t1 = phase->type( in(1) )->isa_long();
 689     if (t1 != NULL && t1->_lo >= 0) {
 690       int bit_count = log2i_graceful(t1->_hi) + 1;
 691       jlong t1_support = jlong(max_julong >> (BitsPerJavaLong - bit_count));
 692       if ((t1_support & con) == t1_support)
 693         return usr;
 694     }
 695     uint lop = usr->Opcode();
 696     // Masking off the high bits of a unsigned-shift-right is not
 697     // needed either.
 698     if( lop == Op_URShiftL ) {
 699       const TypeInt *t12 = phase->type( usr->in(2) )->isa_int();
 700       if( t12 && t12->is_con() ) {  // Shift is by a constant
 701         int shift = t12->get_con();
 702         shift &= BitsPerJavaLong - 1;  // semantics of Java shifts
 703         jlong mask = max_julong >> shift;
 704         if( (mask&con) == mask )  // If AND is useless, skip it
 705           return usr;
 706       }
 707     }








 708   }
 709   return MulNode::Identity(phase);
 710 }
 711 
 712 //------------------------------Ideal------------------------------------------
 713 Node *AndLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
 714   // pattern similar to (v1 + (v2 << 2)) & 3 transformed to v1 & 3
 715   Node* progress = AndIL_add_shift_and_mask(phase, T_LONG);
 716   if (progress != NULL) {
 717     return progress;
 718   }
 719 
 720   // Special case constant AND mask
 721   const TypeLong *t2 = phase->type( in(2) )->isa_long();
 722   if( !t2 || !t2->is_con() ) return MulNode::Ideal(phase, can_reshape);
 723   const jlong mask = t2->get_con();
 724 
 725   Node* in1 = in(1);
 726   int op = in1->Opcode();
 727 

 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:

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