921 } else if (NOT_LP64(root->y()->as_Convert() != NULL) LP64_ONLY(false)) { 922 // Skipping i2l works only on 32bit because of the implicit l2i that the unsafe performs. 923 // 64bit needs a real sign-extending conversion. 924 Convert* convert = root->y()->as_Convert(); 925 if (convert->op() == Bytecodes::_i2l) { 926 assert(convert->value()->type() == intType, "should be an int"); 927 // pick base and index, setting scale at 1 928 *base = root->x(); 929 *index = convert->value(); 930 *log2_scale = 0; 931 match_found = true; 932 } 933 } 934 // The default solution 935 if (!match_found) { 936 *base = root->x(); 937 *index = root->y(); 938 *log2_scale = 0; 939 } 940 941 // If the value is pinned then it will be always be computed so 942 // there's no profit to reshaping the expression. 943 return !root->is_pinned(); 944 } 945 946 947 void Canonicalizer::do_UnsafeRawOp(UnsafeRawOp* x) { 948 Instruction* base = NULL; 949 Instruction* index = NULL; 950 int log2_scale; 951 952 if (match(x, &base, &index, &log2_scale)) { 953 x->set_base(base); 954 x->set_index(index); 955 x->set_log2_scale(log2_scale); 956 if (PrintUnsafeOptimization) { 957 tty->print_cr("Canonicalizer: UnsafeRawOp id %d: base = id %d, index = id %d, log2_scale = %d", 958 x->id(), x->base()->id(), x->index()->id(), x->log2_scale()); 959 } 960 } | 921 } else if (NOT_LP64(root->y()->as_Convert() != NULL) LP64_ONLY(false)) { 922 // Skipping i2l works only on 32bit because of the implicit l2i that the unsafe performs. 923 // 64bit needs a real sign-extending conversion. 924 Convert* convert = root->y()->as_Convert(); 925 if (convert->op() == Bytecodes::_i2l) { 926 assert(convert->value()->type() == intType, "should be an int"); 927 // pick base and index, setting scale at 1 928 *base = root->x(); 929 *index = convert->value(); 930 *log2_scale = 0; 931 match_found = true; 932 } 933 } 934 // The default solution 935 if (!match_found) { 936 *base = root->x(); 937 *index = root->y(); 938 *log2_scale = 0; 939 } 940 941 // AARCH64 cannot handle shifts which are not either 0, or log2 of the type size 942 #ifdef AARCH64 943 if (*log2_scale != 0 && 944 (1 << *log2_scale) != type2aelembytes(x->basic_type(), true)) 945 return false; 946 #endif 947 948 // If the value is pinned then it will be always be computed so 949 // there's no profit to reshaping the expression. 950 return !root->is_pinned(); 951 } 952 953 954 void Canonicalizer::do_UnsafeRawOp(UnsafeRawOp* x) { 955 Instruction* base = NULL; 956 Instruction* index = NULL; 957 int log2_scale; 958 959 if (match(x, &base, &index, &log2_scale)) { 960 x->set_base(base); 961 x->set_index(index); 962 x->set_log2_scale(log2_scale); 963 if (PrintUnsafeOptimization) { 964 tty->print_cr("Canonicalizer: UnsafeRawOp id %d: base = id %d, index = id %d, log2_scale = %d", 965 x->id(), x->base()->id(), x->index()->id(), x->log2_scale()); 966 } 967 } |