< prev index next >
src/share/vm/opto/mulnode.cpp
Print this page
rev 8934 : 8214189: test/hotspot/jtreg/compiler/intrinsics/mathexact/MulExactLConstantTest.java fails on Windows x64 when run with -XX:-TieredCompilation
Reviewed-by: kvn
*** 283,315 ****
if (con == CONST64(0)) return NULL; // By zero is handled by Value call
if (con == CONST64(1)) return NULL; // By one is handled by Identity call
// Check for negative constant; if so negate the final result
bool sign_flip = false;
! unsigned long abs_con = uabs(con);
! if (abs_con != (unsigned long)con) {
sign_flip = true;
}
// Get low bit; check for being the only bit
Node *res = NULL;
! unsigned long bit1 = abs_con & (0-abs_con); // Extract low bit
if (bit1 == abs_con) { // Found a power of 2?
res = new (phase->C) LShiftLNode(in(1), phase->intcon(log2_long(bit1)));
} else {
// Check for constant with 2 bits set
! unsigned long 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 (phase->C) LShiftLNode(in(1), phase->intcon(log2_long(bit1))));
Node *n2 = phase->transform(new (phase->C) LShiftLNode(in(1), phase->intcon(log2_long(bit2))));
res = new (phase->C) AddLNode(n2, n1);
} else if (is_power_of_2_long(abs_con+1)) {
// Sleezy: power-of-2 -1. Next time be generic.
! unsigned long temp = abs_con + 1;
Node *n1 = phase->transform( new (phase->C) LShiftLNode(in(1), phase->intcon(log2_long(temp))));
res = new (phase->C) SubLNode(n1, in(1));
} else {
return MulNode::Ideal(phase, can_reshape);
}
--- 283,315 ----
if (con == CONST64(0)) return NULL; // By zero is handled by Value call
if (con == CONST64(1)) return NULL; // By one is handled by Identity call
// Check for negative constant; if so negate the final result
bool sign_flip = false;
! julong abs_con = uabs(con);
! if (abs_con != (julong)con) {
sign_flip = true;
}
// Get low bit; check for being the only bit
Node *res = NULL;
! julong bit1 = abs_con & (0-abs_con); // Extract low bit
if (bit1 == abs_con) { // Found a power of 2?
res = new (phase->C) LShiftLNode(in(1), phase->intcon(log2_long(bit1)));
} else {
// Check for constant with 2 bits set
! julong 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 (phase->C) LShiftLNode(in(1), phase->intcon(log2_long(bit1))));
Node *n2 = phase->transform(new (phase->C) LShiftLNode(in(1), phase->intcon(log2_long(bit2))));
res = new (phase->C) AddLNode(n2, n1);
} else if (is_power_of_2_long(abs_con+1)) {
// Sleezy: power-of-2 -1. Next time be generic.
! julong temp = abs_con + 1;
Node *n1 = phase->transform( new (phase->C) LShiftLNode(in(1), phase->intcon(log2_long(temp))));
res = new (phase->C) SubLNode(n1, in(1));
} else {
return MulNode::Ideal(phase, can_reshape);
}
< prev index next >