C2 is currently not able to optimize checks like the following:
public static void test1(boolean inc) {
int i = 42;
if (inc) {
i += 100;
}
// i: 42..142
if (i != 42) {
// i: 43..142
if (i <= 42) {
throw new RuntimeException("Should not reach here");
}
}
}
Since i can never be <= 42 in the inner branch, all code could be removed.
public static void test1(boolean inc) {
int i = 42;
if (inc) {
i += 100;
}
// i: 42..142
if (i != 42) {
// i: 43..142
if (i <= 42) {
throw new RuntimeException("Should not reach here");
}
}
}
Since i can never be <= 42 in the inner branch, all code could be removed.
- relates to
-
JDK-8229855 C2 fails with assert(false) failed: bad AD file
- Resolved