[15] RFR(S): 8236721: C2 should better optimize not-equal integer comparisons
Tobias Hartmann
tobias.hartmann at oracle.com
Thu Jan 9 13:22:24 UTC 2020
Hi,
please review the following patch:
https://bugs.openjdk.java.net/browse/JDK-8236721
http://cr.openjdk.java.net/~thartmann/8236721/webrev.00/
While working on JDK-8229855 [1], I've noticed that C2 is not able to fold not-equal integer
comparisons of the following kind:
val = int:lo..hi
if (val != lo) {
if (val <= lo) {
// Dead code
}
}
In general, C2's type system is quite limited when it comes to representing "sparse" types. But if
an integer value is found to be unequal to it's lower/upper boundary, we can still narrow the type.
With this enhancement, all checks in the 8 methods in TestFoldNECompares.java are folded and the
methods are compiled as empty.
Thanks,
Tobias
[1] https://bugs.openjdk.java.net/browse/JDK-8229855
More information about the hotspot-compiler-dev
mailing list