< prev index next >

src/hotspot/share/opto/mulnode.cpp

Print this page

 609 }
 610 
 611 MulHiLoLNode* MulHiLoLNode::make(Node* mul_hi) {
 612   assert(mul_hi->Opcode() == Op_MulHiL, "expected MulHiL");
 613 
 614   MulHiLoLNode* mul_hi_lo = new MulHiLoLNode(mul_hi->in(0), mul_hi->in(1), mul_hi->in(2));
 615   [[maybe_unused]] Node* lo_proj = new ProjNode(mul_hi_lo, MulHiLoLNode::first_proj_num);
 616   [[maybe_unused]] Node* hi_proj = new ProjNode(mul_hi_lo, MulHiLoLNode::second_proj_num);
 617   return mul_hi_lo;
 618 }
 619 
 620 UMulHiLoLNode* UMulHiLoLNode::make(Node* umul_hi) {
 621   assert(umul_hi->Opcode() == Op_UMulHiL, "expected UMulHiL");
 622 
 623   UMulHiLoLNode* umul_hi_lo = new UMulHiLoLNode(umul_hi->in(0), umul_hi->in(1), umul_hi->in(2));
 624   [[maybe_unused]] Node* lo_proj = new ProjNode(umul_hi_lo, MulHiLoLNode::first_proj_num);
 625   [[maybe_unused]] Node* hi_proj = new ProjNode(umul_hi_lo, MulHiLoLNode::second_proj_num);
 626   return umul_hi_lo;
 627 }
 628 
 629 Node* MulHiLoLNode::match(const ProjNode* proj, const Matcher* match) {
 630   uint ideal_reg = proj->ideal_reg();
 631   RegMask rm;
 632   if (proj->_con == first_proj_num) {
 633     rm.assignFrom(match->firstL_proj_mask());
 634   } else {
 635     assert(proj->_con == second_proj_num, "must be lo or hi projection");
 636     rm.assignFrom(match->secondL_proj_mask());
 637   }
 638   return new MachProjNode(this, proj->_con, rm, ideal_reg);
 639 }
 640 
 641 // A common routine used by UMulHiLNode and MulHiLNode
 642 const Type* MulHiValue(const Type *t1, const Type *t2, const Type *bot) {
 643   // Either input is TOP ==> the result is TOP
 644   if( t1 == Type::TOP ) return Type::TOP;
 645   if( t2 == Type::TOP ) return Type::TOP;
 646 
 647   // Either input is BOTTOM ==> the result is the local BOTTOM
 648   if( (t1 == bot) || (t2 == bot) ||
 649       (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) )

 851 
 852   // Masking off sign bits?  Dont make them!
 853   if (op == Op_RShiftL) {
 854     const TypeInt* t12 = phase->type(in1->in(2))->isa_int();
 855     if( t12 && t12->is_con() ) { // Shift is by a constant
 856       int shift = t12->get_con();
 857       shift &= BitsPerJavaLong - 1;  // semantics of Java shifts
 858       if (shift != 0) {
 859         const julong sign_bits_mask = ~(((julong)CONST64(1) << (julong)(BitsPerJavaLong - shift)) -1);
 860         // If the AND'ing of the 2 masks has no bits, then only original shifted
 861         // bits survive.  NO sign-extension bits survive the maskings.
 862         if( (sign_bits_mask & mask) == 0 ) {
 863           // Use zero-fill shift instead
 864           Node *zshift = phase->transform(new URShiftLNode(in1->in(1), in1->in(2)));
 865           return new AndLNode(zshift, in(2));
 866         }
 867       }
 868     }
 869   }
 870 









































 871   return MulNode::Ideal(phase, can_reshape);
 872 }
 873 
 874 LShiftNode* LShiftNode::make(Node* in1, Node* in2, BasicType bt) {
 875   switch (bt) {
 876     case T_INT:
 877       return new LShiftINode(in1, in2);
 878     case T_LONG:
 879       return new LShiftLNode(in1, in2);
 880     default:
 881       fatal("Not implemented for %s", type2name(bt));
 882   }
 883   return nullptr;
 884 }
 885 
 886 // Returns whether the shift amount is constant or effectively constant (low bits known).
 887 //
 888 // Parameters:
 889 //   masked_shift - always initialized to 0; if the function returns true, it indicates
 890 //                  the masked shift amount.

 609 }
 610 
 611 MulHiLoLNode* MulHiLoLNode::make(Node* mul_hi) {
 612   assert(mul_hi->Opcode() == Op_MulHiL, "expected MulHiL");
 613 
 614   MulHiLoLNode* mul_hi_lo = new MulHiLoLNode(mul_hi->in(0), mul_hi->in(1), mul_hi->in(2));
 615   [[maybe_unused]] Node* lo_proj = new ProjNode(mul_hi_lo, MulHiLoLNode::first_proj_num);
 616   [[maybe_unused]] Node* hi_proj = new ProjNode(mul_hi_lo, MulHiLoLNode::second_proj_num);
 617   return mul_hi_lo;
 618 }
 619 
 620 UMulHiLoLNode* UMulHiLoLNode::make(Node* umul_hi) {
 621   assert(umul_hi->Opcode() == Op_UMulHiL, "expected UMulHiL");
 622 
 623   UMulHiLoLNode* umul_hi_lo = new UMulHiLoLNode(umul_hi->in(0), umul_hi->in(1), umul_hi->in(2));
 624   [[maybe_unused]] Node* lo_proj = new ProjNode(umul_hi_lo, MulHiLoLNode::first_proj_num);
 625   [[maybe_unused]] Node* hi_proj = new ProjNode(umul_hi_lo, MulHiLoLNode::second_proj_num);
 626   return umul_hi_lo;
 627 }
 628 
 629 Node* MulHiLoLNode::match(const ProjNode* proj, const Matcher* match, const RegMask*) {
 630   uint ideal_reg = proj->ideal_reg();
 631   RegMask rm;
 632   if (proj->_con == first_proj_num) {
 633     rm.assignFrom(match->firstL_proj_mask());
 634   } else {
 635     assert(proj->_con == second_proj_num, "must be lo or hi projection");
 636     rm.assignFrom(match->secondL_proj_mask());
 637   }
 638   return new MachProjNode(this, proj->_con, rm, ideal_reg);
 639 }
 640 
 641 // A common routine used by UMulHiLNode and MulHiLNode
 642 const Type* MulHiValue(const Type *t1, const Type *t2, const Type *bot) {
 643   // Either input is TOP ==> the result is TOP
 644   if( t1 == Type::TOP ) return Type::TOP;
 645   if( t2 == Type::TOP ) return Type::TOP;
 646 
 647   // Either input is BOTTOM ==> the result is the local BOTTOM
 648   if( (t1 == bot) || (t2 == bot) ||
 649       (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) )

 851 
 852   // Masking off sign bits?  Dont make them!
 853   if (op == Op_RShiftL) {
 854     const TypeInt* t12 = phase->type(in1->in(2))->isa_int();
 855     if( t12 && t12->is_con() ) { // Shift is by a constant
 856       int shift = t12->get_con();
 857       shift &= BitsPerJavaLong - 1;  // semantics of Java shifts
 858       if (shift != 0) {
 859         const julong sign_bits_mask = ~(((julong)CONST64(1) << (julong)(BitsPerJavaLong - shift)) -1);
 860         // If the AND'ing of the 2 masks has no bits, then only original shifted
 861         // bits survive.  NO sign-extension bits survive the maskings.
 862         if( (sign_bits_mask & mask) == 0 ) {
 863           // Use zero-fill shift instead
 864           Node *zshift = phase->transform(new URShiftLNode(in1->in(1), in1->in(2)));
 865           return new AndLNode(zshift, in(2));
 866         }
 867       }
 868     }
 869   }
 870 
 871   // Search for GraphKit::mark_word_test patterns and fold the test if the result is statically known
 872   Node* load1 = in(1);
 873   Node* load2 = nullptr;
 874   if (load1->is_Phi() && phase->type(load1)->isa_long()) {
 875     load1 = in(1)->in(1);
 876     load2 = in(1)->in(2);
 877   }
 878   if (load1 != nullptr && load1->is_Load() && phase->type(load1)->isa_long() &&
 879       (load2 == nullptr || (load2->is_Load() && phase->type(load2)->isa_long()))) {
 880     const TypePtr* adr_t1 = phase->type(load1->in(MemNode::Address))->isa_ptr();
 881     const TypePtr* adr_t2 = (load2 != nullptr) ? phase->type(load2->in(MemNode::Address))->isa_ptr() : nullptr;
 882     if (adr_t1 != nullptr && adr_t1->offset() == oopDesc::mark_offset_in_bytes() &&
 883         (load2 == nullptr || (adr_t2 != nullptr && adr_t2->offset() == in_bytes(Klass::prototype_header_offset())))) {
 884       if (mask == markWord::inline_type_pattern) {
 885         if (adr_t1->is_inlinetypeptr()) {
 886           set_req_X(1, in(2), phase);
 887           return this;
 888         } else if (!adr_t1->can_be_inline_type()) {
 889           set_req_X(1, phase->longcon(0), phase);
 890           return this;
 891         }
 892       } else if (mask == markWord::null_free_array_bit_in_place) {
 893         if (adr_t1->is_null_free()) {
 894           set_req_X(1, in(2), phase);
 895           return this;
 896         } else if (adr_t1->is_not_null_free()) {
 897           set_req_X(1, phase->longcon(0), phase);
 898           return this;
 899         }
 900       } else if (mask == markWord::flat_array_bit_in_place) {
 901         if (adr_t1->is_flat()) {
 902           set_req_X(1, in(2), phase);
 903           return this;
 904         } else if (adr_t1->is_not_flat()) {
 905           set_req_X(1, phase->longcon(0), phase);
 906           return this;
 907         }
 908       }
 909     }
 910   }
 911 
 912   return MulNode::Ideal(phase, can_reshape);
 913 }
 914 
 915 LShiftNode* LShiftNode::make(Node* in1, Node* in2, BasicType bt) {
 916   switch (bt) {
 917     case T_INT:
 918       return new LShiftINode(in1, in2);
 919     case T_LONG:
 920       return new LShiftLNode(in1, in2);
 921     default:
 922       fatal("Not implemented for %s", type2name(bt));
 923   }
 924   return nullptr;
 925 }
 926 
 927 // Returns whether the shift amount is constant or effectively constant (low bits known).
 928 //
 929 // Parameters:
 930 //   masked_shift - always initialized to 0; if the function returns true, it indicates
 931 //                  the masked shift amount.
< prev index next >