< prev index next >
src/hotspot/share/opto/mulnode.cpp
Print this page
*** 197,221 ****
// Get low bit; check for being the only bit
Node *res = NULL;
unsigned int bit1 = abs_con & (0-abs_con); // Extract low bit
if (bit1 == abs_con) { // Found a power of 2?
! res = new LShiftINode(in(1), phase->intcon(log2_intptr(bit1)));
} else {
// Check for constant with 2 bits set
unsigned int bit2 = abs_con-bit1;
bit2 = bit2 & (0-bit2); // Extract 2nd bit
if (bit2 + bit1 == abs_con) { // Found all bits in con?
! Node *n1 = phase->transform( new LShiftINode(in(1), phase->intcon(log2_intptr(bit1))));
! Node *n2 = phase->transform( new LShiftINode(in(1), phase->intcon(log2_intptr(bit2))));
res = new AddINode(n2, n1);
} else if (is_power_of_2(abs_con+1)) {
// Sleezy: power-of-2 -1. Next time be generic.
unsigned int temp = abs_con + 1;
! Node *n1 = phase->transform(new LShiftINode(in(1), phase->intcon(log2_intptr(temp))));
res = new SubINode(n1, in(1));
} else {
return MulNode::Ideal(phase, can_reshape);
}
}
--- 197,221 ----
// Get low bit; check for being the only bit
Node *res = NULL;
unsigned int bit1 = abs_con & (0-abs_con); // Extract low bit
if (bit1 == abs_con) { // Found a power of 2?
! res = new LShiftINode(in(1), phase->intcon(log2_uint(bit1)));
} else {
// Check for constant with 2 bits set
unsigned int bit2 = abs_con-bit1;
bit2 = bit2 & (0-bit2); // Extract 2nd bit
if (bit2 + bit1 == abs_con) { // Found all bits in con?
! Node *n1 = phase->transform( new LShiftINode(in(1), phase->intcon(log2_uint(bit1))));
! Node *n2 = phase->transform( new LShiftINode(in(1), phase->intcon(log2_uint(bit2))));
res = new AddINode(n2, n1);
} else if (is_power_of_2(abs_con+1)) {
// Sleezy: power-of-2 -1. Next time be generic.
unsigned int temp = abs_con + 1;
! Node *n1 = phase->transform(new LShiftINode(in(1), phase->intcon(log2_uint(temp))));
res = new SubINode(n1, in(1));
} else {
return MulNode::Ideal(phase, can_reshape);
}
}
*** 443,453 ****
if (t2 && t2->is_con()) {
int con = t2->get_con();
// Masking off high bits which are always zero is useless.
const TypeInt* t1 = phase->type( in(1) )->isa_int();
if (t1 != NULL && t1->_lo >= 0) {
! jint t1_support = right_n_bits(1 + log2_intptr(t1->_hi));
if ((t1_support & con) == t1_support)
return in1;
}
// Masking off the high bits of a unsigned-shift-right is not
// needed either.
--- 443,453 ----
if (t2 && t2->is_con()) {
int con = t2->get_con();
// Masking off high bits which are always zero is useless.
const TypeInt* t1 = phase->type( in(1) )->isa_int();
if (t1 != NULL && t1->_lo >= 0) {
! jint t1_support = right_n_bits(1 + log2_jint(t1->_hi));
if ((t1_support & con) == t1_support)
return in1;
}
// Masking off the high bits of a unsigned-shift-right is not
// needed either.
< prev index next >