-
Bug
-
Resolution: Fixed
-
P1
-
17, 18
-
b16
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8321733 | 17.0.11-oracle | Mimoun Ghordou | P1 | Closed | Fixed | b01 |
JDK-8322181 | 17.0.11 | Goetz Lindenmaier | P1 | Resolved | Fixed | b01 |
Attached Fuzzer test caught a serious regression after JDK-8273454. Note how the result is different in C2:
$ ~/trunks/jdk/build/linux-x86_64-server-fastdebug/images/jdk/bin/java -Xint Test | grep Test.instanceCount | uniq
Test.instanceCount Test.iFld Test.byFld = -2635249129509180159,2,0
~/trunks/jdk/build/linux-x86_64-server-fastdebug/images/jdk/bin/java -XX:TieredStopAtLevel=1 Test | grep Test.instanceCount | uniq
Test.instanceCount Test.iFld Test.byFld = -2635249129509180159,2,0
$ ~/trunks/jdk/build/linux-x86_64-server-fastdebug/images/jdk/bin/java -XX:-TieredCompilation Test | grep Test.instanceCount | uniq
Test.instanceCount Test.iFld Test.byFld = 2635249177264977449,2,0
Minimized test case:
public class Test {
public static int f;
public static void main(String... strArr) {
for (int c = 0; c < 2; c++) {
f += c;
f *= -1;
}
f &= f;
System.out.println("final = " + f);
}
}
$ ~/trunks/jdk/build/linux-x86_64-server-fastdebug/images/jdk/bin/java -Xint Test
final = -1
$ ~/trunks/jdk/build/linux-x86_64-server-fastdebug/images/jdk/bin/java -Xcomp -XX:-TieredCompilation Test
final = 1
I suspect the trouble is here:
Node *AndINode::Ideal(PhaseGVN *phase, bool can_reshape) {
// Special case constant AND mask
const TypeInt *t2 = phase->type( in(2) )->isa_int();
if( !t2 || !t2->is_con() ) return MulNode::Ideal(phase, can_reshape); // <--- calls new code through here
So while ((-x) * (-y)) == (x * y) is always true indeed, ((-x) & (-y)) == (x & y) is not!
$ ~/trunks/jdk/build/linux-x86_64-server-fastdebug/images/jdk/bin/java -Xint Test | grep Test.instanceCount | uniq
Test.instanceCount Test.iFld Test.byFld = -2635249129509180159,2,0
~/trunks/jdk/build/linux-x86_64-server-fastdebug/images/jdk/bin/java -XX:TieredStopAtLevel=1 Test | grep Test.instanceCount | uniq
Test.instanceCount Test.iFld Test.byFld = -2635249129509180159,2,0
$ ~/trunks/jdk/build/linux-x86_64-server-fastdebug/images/jdk/bin/java -XX:-TieredCompilation Test | grep Test.instanceCount | uniq
Test.instanceCount Test.iFld Test.byFld = 2635249177264977449,2,0
Minimized test case:
public class Test {
public static int f;
public static void main(String... strArr) {
for (int c = 0; c < 2; c++) {
f += c;
f *= -1;
}
f &= f;
System.out.println("final = " + f);
}
}
$ ~/trunks/jdk/build/linux-x86_64-server-fastdebug/images/jdk/bin/java -Xint Test
final = -1
$ ~/trunks/jdk/build/linux-x86_64-server-fastdebug/images/jdk/bin/java -Xcomp -XX:-TieredCompilation Test
final = 1
I suspect the trouble is here:
Node *AndINode::Ideal(PhaseGVN *phase, bool can_reshape) {
// Special case constant AND mask
const TypeInt *t2 = phase->type( in(2) )->isa_int();
if( !t2 || !t2->is_con() ) return MulNode::Ideal(phase, can_reshape); // <--- calls new code through here
So while ((-x) * (-y)) == (x * y) is always true indeed, ((-x) & (-y)) == (x & y) is not!
- backported by
-
JDK-8322181 C2: Incorrect computation after JDK-8273454
-
- Resolved
-
-
JDK-8321733 C2: Incorrect computation after JDK-8273454
-
- Closed
-
- relates to
-
JDK-8273454 C2: Transform (-a)*(-b) into a*b
-
- Resolved
-
- links to
-
Commit openjdk/jdk17u-dev/873148e5
-
Commit openjdk/jdk/c77ebe88
-
Review openjdk/jdk17u-dev/2035
-
Review openjdk/jdk/5612
(2 links to)