< prev index next >

src/hotspot/share/opto/mulnode.cpp

Print this page




 138   return progress;
 139 }
 140 
 141 //------------------------------Value-----------------------------------------
 142 const Type* MulNode::Value(PhaseGVN* phase) const {
 143   const Type *t1 = phase->type( in(1) );
 144   const Type *t2 = phase->type( in(2) );
 145   // Either input is TOP ==> the result is TOP
 146   if( t1 == Type::TOP ) return Type::TOP;
 147   if( t2 == Type::TOP ) return Type::TOP;
 148 
 149   // Either input is ZERO ==> the result is ZERO.
 150   // Not valid for floats or doubles since +0.0 * -0.0 --> +0.0
 151   int op = Opcode();
 152   if( op == Op_MulI || op == Op_AndI || op == Op_MulL || op == Op_AndL ) {
 153     const Type *zero = add_id();        // The multiplicative zero
 154     if( t1->higher_equal( zero ) ) return zero;
 155     if( t2->higher_equal( zero ) ) return zero;
 156   }
 157 












 158   // Either input is BOTTOM ==> the result is the local BOTTOM
 159   if( t1 == Type::BOTTOM || t2 == Type::BOTTOM )
 160     return bottom_type();
 161 
 162 #if defined(IA32)
 163   // Can't trust native compilers to properly fold strict double
 164   // multiplication with round-to-zero on this platform.
 165   if (op == Op_MulD && phase->C->method()->is_strict()) {
 166     return TypeD::DOUBLE;
 167   }
 168 #endif
 169 
 170   return mul_ring(t1,t2);            // Local flavor of type multiplication
 171 }
 172 
 173 //=============================================================================
 174 //------------------------------Ideal------------------------------------------
 175 // Check for power-of-2 multiply, then try the regular MulNode::Ideal
 176 Node *MulINode::Ideal(PhaseGVN *phase, bool can_reshape) {
 177   // Swap constant to right


 565     jlong con = t2->get_con();
 566     // Masking off high bits which are always zero is useless.
 567     const TypeLong* t1 = phase->type( in(1) )->isa_long();
 568     if (t1 != NULL && t1->_lo >= 0) {
 569       int bit_count = log2_long(t1->_hi) + 1;
 570       jlong t1_support = jlong(max_julong >> (BitsPerJavaLong - bit_count));
 571       if ((t1_support & con) == t1_support)
 572         return usr;
 573     }
 574     uint lop = usr->Opcode();
 575     // Masking off the high bits of a unsigned-shift-right is not
 576     // needed either.
 577     if( lop == Op_URShiftL ) {
 578       const TypeInt *t12 = phase->type( usr->in(2) )->isa_int();
 579       if( t12 && t12->is_con() ) {  // Shift is by a constant
 580         int shift = t12->get_con();
 581         shift &= BitsPerJavaLong - 1;  // semantics of Java shifts
 582         jlong mask = max_julong >> shift;
 583         if( (mask&con) == mask )  // If AND is useless, skip it
 584           return usr;







 585       }
 586     }
 587   }
 588   return MulNode::Identity(phase);
 589 }
 590 
 591 //------------------------------Ideal------------------------------------------
 592 Node *AndLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
 593   // Special case constant AND mask
 594   const TypeLong *t2 = phase->type( in(2) )->isa_long();
 595   if( !t2 || !t2->is_con() ) return MulNode::Ideal(phase, can_reshape);
 596   const jlong mask = t2->get_con();
 597 
 598   Node* in1 = in(1);
 599   uint op = in1->Opcode();
 600 
 601   // Are we masking a long that was converted from an int with a mask
 602   // that fits in 32-bits?  Commute them and use an AndINode.  Don't
 603   // convert masks which would cause a sign extension of the integer
 604   // value.  This check includes UI2L masks (0x00000000FFFFFFFF) which




 138   return progress;
 139 }
 140 
 141 //------------------------------Value-----------------------------------------
 142 const Type* MulNode::Value(PhaseGVN* phase) const {
 143   const Type *t1 = phase->type( in(1) );
 144   const Type *t2 = phase->type( in(2) );
 145   // Either input is TOP ==> the result is TOP
 146   if( t1 == Type::TOP ) return Type::TOP;
 147   if( t2 == Type::TOP ) return Type::TOP;
 148 
 149   // Either input is ZERO ==> the result is ZERO.
 150   // Not valid for floats or doubles since +0.0 * -0.0 --> +0.0
 151   int op = Opcode();
 152   if( op == Op_MulI || op == Op_AndI || op == Op_MulL || op == Op_AndL ) {
 153     const Type *zero = add_id();        // The multiplicative zero
 154     if( t1->higher_equal( zero ) ) return zero;
 155     if( t2->higher_equal( zero ) ) return zero;
 156   }
 157 
 158   // Code pattern on return from a call that returns an __Value.  Can
 159   // be optimized away if the return value turns out to be an oop.
 160   if (op == Op_AndX &&
 161       in(1) != NULL &&
 162       in(1)->Opcode() == Op_CastP2X &&
 163       in(1)->in(1) != NULL &&
 164       phase->type(in(1)->in(1))->isa_oopptr() &&
 165       t2->isa_intptr_t()->_lo >= 0 &&
 166       t2->isa_intptr_t()->_hi <= MinObjAlignmentInBytesMask) {
 167     return add_id();
 168   }
 169 
 170   // Either input is BOTTOM ==> the result is the local BOTTOM
 171   if( t1 == Type::BOTTOM || t2 == Type::BOTTOM )
 172     return bottom_type();
 173 
 174 #if defined(IA32)
 175   // Can't trust native compilers to properly fold strict double
 176   // multiplication with round-to-zero on this platform.
 177   if (op == Op_MulD && phase->C->method()->is_strict()) {
 178     return TypeD::DOUBLE;
 179   }
 180 #endif
 181 
 182   return mul_ring(t1,t2);            // Local flavor of type multiplication
 183 }
 184 
 185 //=============================================================================
 186 //------------------------------Ideal------------------------------------------
 187 // Check for power-of-2 multiply, then try the regular MulNode::Ideal
 188 Node *MulINode::Ideal(PhaseGVN *phase, bool can_reshape) {
 189   // Swap constant to right


 577     jlong con = t2->get_con();
 578     // Masking off high bits which are always zero is useless.
 579     const TypeLong* t1 = phase->type( in(1) )->isa_long();
 580     if (t1 != NULL && t1->_lo >= 0) {
 581       int bit_count = log2_long(t1->_hi) + 1;
 582       jlong t1_support = jlong(max_julong >> (BitsPerJavaLong - bit_count));
 583       if ((t1_support & con) == t1_support)
 584         return usr;
 585     }
 586     uint lop = usr->Opcode();
 587     // Masking off the high bits of a unsigned-shift-right is not
 588     // needed either.
 589     if( lop == Op_URShiftL ) {
 590       const TypeInt *t12 = phase->type( usr->in(2) )->isa_int();
 591       if( t12 && t12->is_con() ) {  // Shift is by a constant
 592         int shift = t12->get_con();
 593         shift &= BitsPerJavaLong - 1;  // semantics of Java shifts
 594         jlong mask = max_julong >> shift;
 595         if( (mask&con) == mask )  // If AND is useless, skip it
 596           return usr;
 597       }
 598     }
 599 
 600     if (con == markOopDesc::always_locked_pattern) {
 601       assert(EnableValhalla, "should only be used for value types");
 602       if (in(1)->is_Load() && phase->type(in(1)->in(MemNode::Address))->is_valuetypeptr()) {
 603         return in(2); // Obj is known to be a value type
 604       }
 605     }
 606   }
 607   return MulNode::Identity(phase);
 608 }
 609 
 610 //------------------------------Ideal------------------------------------------
 611 Node *AndLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
 612   // Special case constant AND mask
 613   const TypeLong *t2 = phase->type( in(2) )->isa_long();
 614   if( !t2 || !t2->is_con() ) return MulNode::Ideal(phase, can_reshape);
 615   const jlong mask = t2->get_con();
 616 
 617   Node* in1 = in(1);
 618   uint op = in1->Opcode();
 619 
 620   // Are we masking a long that was converted from an int with a mask
 621   // that fits in 32-bits?  Commute them and use an AndINode.  Don't
 622   // convert masks which would cause a sign extension of the integer
 623   // value.  This check includes UI2L masks (0x00000000FFFFFFFF) which


< prev index next >