RFR: 8364766: C2: Improve Value() of DivI and DivL for non-constant inputs [v6]

Emanuel Peter epeter at openjdk.org
Mon Aug 25 12:59:02 UTC 2025


On Mon, 25 Aug 2025 09:19:24 GMT, Manuel Hässig <mhaessig at openjdk.org> wrote:

>> src/hotspot/share/opto/divnode.cpp line 543:
>> 
>>> 541:   NativeType i2_hi = i2->_hi == 0 ? -1 : i2->_hi;
>>> 542:   NativeType min_val = std::numeric_limits<NativeType>::min();
>>> 543:   assert(min_val == min_jint || min_val == min_jlong, "min has to be either min_jint or min_jlong");
>> 
>> I find this assert a little confusing, as its outcome is completely independent from the inputs of the function. I would remove it
>
> It depends on the template type. I would rather keep it to sanity check that the minimum value of `NativeType` is as we expect. If that does not hold, the optimization below is potentially wrong and has UB.

We will one day want to use use smaller integer types here, just for some exhaustive gtesting. But I suppose we can remove it at that point.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26143#discussion_r2297978419


More information about the hotspot-compiler-dev mailing list