RFR: 8364766: C2: Improve Value() of DivI and DivL for non-constant inputs [v7]
Manuel Hässig
mhaessig at openjdk.org
Tue Oct 21 08:24:24 UTC 2025
On Sun, 19 Oct 2025 19:17:26 GMT, Tobias Hotz <duke at openjdk.org> wrote:
>> src/hotspot/share/opto/divnode.cpp line 651:
>>
>>> 649: if( (t1 == bot) || (t2 == bot) ||
>>> 650: (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) )
>>> 651: return bot;
>>
>> I think this can be removed - and in cases where one side is the local bottom (i.e., `TypeInt::INT`) and the other is more restricted, the result should even more precise after removing. Could you also add tests for such cases? For example dividing `TypeInt::INT` by some interval with a lower bound of 2, the resulting range can be narrowed. Similarly, dividing some small interval `[lo, hi]` by `TypeInt::INT` should result in a similar interval with bounds adjusted to deal with sign changes. If I didn't miss something, your code should already be able to deal with this, it's just this early return here preventing it.
>
> I think you are correct. The only part where I am not sure is if every instance where i1/i2 can be Type::BOTTOM, i1/i2 can be cast to TypeInt.
> Can someone please confirm the removal is safe?
`Type::BOTTOM` should not happen, since we are in a method `DivI/L` and thus know that the inputs should be some particular type. I think removing this check is fine, since you are doing `t1->is_int()` below, which would assert for `t1 == Type::BOTTOM`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26143#discussion_r2447203932
More information about the hotspot-compiler-dev
mailing list