819
820 // Masking off sign bits? Dont make them!
821 if (op == Op_RShiftL) {
822 const TypeInt* t12 = phase->type(in1->in(2))->isa_int();
823 if( t12 && t12->is_con() ) { // Shift is by a constant
824 int shift = t12->get_con();
825 shift &= BitsPerJavaLong - 1; // semantics of Java shifts
826 if (shift != 0) {
827 const julong sign_bits_mask = ~(((julong)CONST64(1) << (julong)(BitsPerJavaLong - shift)) -1);
828 // If the AND'ing of the 2 masks has no bits, then only original shifted
829 // bits survive. NO sign-extension bits survive the maskings.
830 if( (sign_bits_mask & mask) == 0 ) {
831 // Use zero-fill shift instead
832 Node *zshift = phase->transform(new URShiftLNode(in1->in(1), in1->in(2)));
833 return new AndLNode(zshift, in(2));
834 }
835 }
836 }
837 }
838
839 return MulNode::Ideal(phase, can_reshape);
840 }
841
842 LShiftNode* LShiftNode::make(Node* in1, Node* in2, BasicType bt) {
843 switch (bt) {
844 case T_INT:
845 return new LShiftINode(in1, in2);
846 case T_LONG:
847 return new LShiftLNode(in1, in2);
848 default:
849 fatal("Not implemented for %s", type2name(bt));
850 }
851 return nullptr;
852 }
853
854 // Returns whether the shift amount is constant or effectively constant (low bits known).
855 //
856 // Parameters:
857 // masked_shift - always initialized to 0; if the function returns true, it indicates
858 // the masked shift amount.
|
819
820 // Masking off sign bits? Dont make them!
821 if (op == Op_RShiftL) {
822 const TypeInt* t12 = phase->type(in1->in(2))->isa_int();
823 if( t12 && t12->is_con() ) { // Shift is by a constant
824 int shift = t12->get_con();
825 shift &= BitsPerJavaLong - 1; // semantics of Java shifts
826 if (shift != 0) {
827 const julong sign_bits_mask = ~(((julong)CONST64(1) << (julong)(BitsPerJavaLong - shift)) -1);
828 // If the AND'ing of the 2 masks has no bits, then only original shifted
829 // bits survive. NO sign-extension bits survive the maskings.
830 if( (sign_bits_mask & mask) == 0 ) {
831 // Use zero-fill shift instead
832 Node *zshift = phase->transform(new URShiftLNode(in1->in(1), in1->in(2)));
833 return new AndLNode(zshift, in(2));
834 }
835 }
836 }
837 }
838
839 // Search for GraphKit::mark_word_test patterns and fold the test if the result is statically known
840 Node* load1 = in(1);
841 Node* load2 = nullptr;
842 if (load1->is_Phi() && phase->type(load1)->isa_long()) {
843 load1 = in(1)->in(1);
844 load2 = in(1)->in(2);
845 }
846 if (load1 != nullptr && load1->is_Load() && phase->type(load1)->isa_long() &&
847 (load2 == nullptr || (load2->is_Load() && phase->type(load2)->isa_long()))) {
848 const TypePtr* adr_t1 = phase->type(load1->in(MemNode::Address))->isa_ptr();
849 const TypePtr* adr_t2 = (load2 != nullptr) ? phase->type(load2->in(MemNode::Address))->isa_ptr() : nullptr;
850 if (adr_t1 != nullptr && adr_t1->offset() == oopDesc::mark_offset_in_bytes() &&
851 (load2 == nullptr || (adr_t2 != nullptr && adr_t2->offset() == in_bytes(Klass::prototype_header_offset())))) {
852 if (mask == markWord::inline_type_pattern) {
853 if (adr_t1->is_inlinetypeptr()) {
854 set_req_X(1, in(2), phase);
855 return this;
856 } else if (!adr_t1->can_be_inline_type()) {
857 set_req_X(1, phase->longcon(0), phase);
858 return this;
859 }
860 } else if (mask == markWord::null_free_array_bit_in_place) {
861 if (adr_t1->is_null_free()) {
862 set_req_X(1, in(2), phase);
863 return this;
864 } else if (adr_t1->is_not_null_free()) {
865 set_req_X(1, phase->longcon(0), phase);
866 return this;
867 }
868 } else if (mask == markWord::flat_array_bit_in_place) {
869 if (adr_t1->is_flat()) {
870 set_req_X(1, in(2), phase);
871 return this;
872 } else if (adr_t1->is_not_flat()) {
873 set_req_X(1, phase->longcon(0), phase);
874 return this;
875 }
876 }
877 }
878 }
879
880 return MulNode::Ideal(phase, can_reshape);
881 }
882
883 LShiftNode* LShiftNode::make(Node* in1, Node* in2, BasicType bt) {
884 switch (bt) {
885 case T_INT:
886 return new LShiftINode(in1, in2);
887 case T_LONG:
888 return new LShiftLNode(in1, in2);
889 default:
890 fatal("Not implemented for %s", type2name(bt));
891 }
892 return nullptr;
893 }
894
895 // Returns whether the shift amount is constant or effectively constant (low bits known).
896 //
897 // Parameters:
898 // masked_shift - always initialized to 0; if the function returns true, it indicates
899 // the masked shift amount.
|