RFR: 8309266: C2: assert(final_con == (jlong)final_int) failed: final value should be integer

Daohan Qu duke at openjdk.org
Wed Jun 7 15:27:56 UTC 2023


On Wed, 7 Jun 2023 14:31:19 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

> Please always make sure that you have it assigned to you, or at least mention in JIRA that you are working on it.

Hi, @eme64 , I'm so sorry for that! I don't have a JBS account yet, but from now on I will avoid to work on assigned issues and try to get an account ASAP.

> Why is the overflow acceptable? Does that not mean that the calculation did something wrong?

If my understanding is correct, the final value should be `i`'s value at loop exit. If limit is `max_jint`, the final value should be `max_jint + 2`. So the calculation is not wrong but is an intermediate result. We need to check `LoopLimitNode::Value()` at end of CCP to ensure this calculation doesn't overflow.

BTW, The `LoopLimitNode` is generated and its check happens because it believe that the code don't always overflow and overflow case will be handled by a `uncommon_trap`, which is done by the following code (If `check_stride_overflow()` returns `-1`, the overflow will always happen).
https://github.com/openjdk/jdk/blob/5b147eb5e46ac7fa637ed997c6da8f238f685ea4/src/hotspot/share/opto/loopnode.cpp#L1781-L1804

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

PR Comment: https://git.openjdk.org/jdk/pull/14353#issuecomment-1581056520


More information about the hotspot-compiler-dev mailing list