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