RFR: 8293491: Avoid unexpected deoptimization in loop exit due to incorrect branch profiling [v2]

Jie Fu jiefu at openjdk.org
Tue Sep 20 02:24:38 UTC 2022


On Mon, 19 Sep 2022 20:45:43 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:

> Usually after loop you will have other code also with 0 profiling and it will be deoptimized with your changes.

Okay, you're right, for code like the following, it still deopts even with the change.

static int testFor() {
    int sum = 1;
    for(int i = 1; i < N; i++) {
        sum &= i;
    }   

    if (sum == 0) {
      System.out.println("sum = 0");
    }   

    if (sum == 1) {
      System.out.println("sum = 1");
    }   

    return sum;
}


@TobiHartmann had reminded me about this situation, but I didn't get the point before.
So It seems impossible to avoid deopts for this kind of cases.

I agree with you not to fix it.
Thank you all again for the review and comments.

-------------

PR: https://git.openjdk.org/jdk/pull/10200


More information about the hotspot-compiler-dev mailing list