[jdk17] RFR: 8269230: C2: main loop in micro benchmark never executed [v2]
Roland Westrelin
roland at openjdk.java.net
Wed Jun 30 09:10:38 UTC 2021
> The benchmark loop is roughly:
>
> for (int i = 0; i < limit; i++) {
> if (!(i < max_jint && i > min_jint)) {
> uncommon_trap();
> }
> }
>
> which IfNode::fold_compares() tranforms to:
>
> for (int i = 0; i < limit; i++) {
> if (!(i - min_jint - 1 <u -2)) {
> uncommon_trap();
> }
> }
>
> Range elimination then adjusts loop limits so the unsigned comparison
> can be removed. The new limit is:
>
> min(limit, max(-2 + min_jint + 1, min_jint)) = min(limit, min_jint) = min_jint
>
> and the main loop is never executed.
>
> The logic that protects against overflows during range check
> elimination is what causes the main loop to never be executed. As a
> fix, I propose delaying IfNode::fold_compares() if the resulting test
> compares with a potential negative number which could then cause RC
> overflow code to trigger. I think that would preserve the most
> interesting cases for IfNode::fold_compares() when it comes to range
> check elimination:
>
> i >= 0 && i < array.length
Roland Westrelin has updated the pull request incrementally with one additional commit since the last revision:
benchmark
-------------
Changes:
- all: https://git.openjdk.java.net/jdk17/pull/156/files
- new: https://git.openjdk.java.net/jdk17/pull/156/files/21cc2e4e..f89c063a
Webrevs:
- full: https://webrevs.openjdk.java.net/?repo=jdk17&pr=156&range=01
- incr: https://webrevs.openjdk.java.net/?repo=jdk17&pr=156&range=00-01
Stats: 137 lines in 1 file changed: 137 ins; 0 del; 0 mod
Patch: https://git.openjdk.java.net/jdk17/pull/156.diff
Fetch: git fetch https://git.openjdk.java.net/jdk17 pull/156/head:pull/156
PR: https://git.openjdk.java.net/jdk17/pull/156
More information about the hotspot-compiler-dev
mailing list