A DESCRIPTION OF THE PROBLEM :
Currently, C2 only emits a good type for interger division nodes if either input is constant. But we can also cover the generic case by looking at the for cases [min_divident / min_divisor], [max_divident / min_divisor], [min_divident / max_divisor] and [max_divident / max_divisor]. This is guranteed to find the extrema that we can use for min/max. Some special logic is required for MIN_INT / -1, as this is a special case. We also need some special logic to handle ranges that cross zero, but in this case, we just need to check for the negative and positive range once.
In some cases, this algorithm can lead to a constant Value() result even though both inputs are non-constant!
I've already built a PR for this: https://github.com/openjdk/jdk/pull/26143
Currently, C2 only emits a good type for interger division nodes if either input is constant. But we can also cover the generic case by looking at the for cases [min_divident / min_divisor], [max_divident / min_divisor], [min_divident / max_divisor] and [max_divident / max_divisor]. This is guranteed to find the extrema that we can use for min/max. Some special logic is required for MIN_INT / -1, as this is a special case. We also need some special logic to handle ranges that cross zero, but in this case, we just need to check for the negative and positive range once.
In some cases, this algorithm can lead to a constant Value() result even though both inputs are non-constant!
I've already built a PR for this: https://github.com/openjdk/jdk/pull/26143
- links to
-
Review(master) openjdk/jdk/26143