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

Tobias Hotz duke at openjdk.org
Wed Aug 6 19:18:06 UTC 2025


This PR improves the value of interger division nodes.
Currently, we only emit a good type if either input is constant. But we can also cover the generic case. It does that by finding the four corners of the division. This is guranteed to find the extrema that we can use for min/max. Some special logic is required for MIN_INT / -1, though, 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.
This also cleans up and unifies the code paths for DivINode and DivLNode.
I've added some tests to validate the optimization. Without the changes, some of these tests fail.

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

Commit messages:
 - Merge branch 'master' of https://github.com/openjdk/jdk into better_interger_div_type
 - Adjust bug number
 - Use LF line endings
 - Add verification to tests
 - Add tests and comments
 - Merge branch 'master' of https://github.com/openjdk/jdk into better_interger_div_type
 - Move more logic into generic computation
 - Return TOP if no value is possible
 - Merge remote-tracking branch 'refs/remotes/upstream/master' into better_interger_div_type
 - Merge remote-tracking branch 'origin/master' into better_interger_div_type
 - ... and 4 more: https://git.openjdk.org/jdk/compare/f95af744...dacaddac

Changes: https://git.openjdk.org/jdk/pull/26143/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=26143&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8364766
  Stats: 450 lines in 2 files changed: 381 ins; 58 del; 11 mod
  Patch: https://git.openjdk.org/jdk/pull/26143.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/26143/head:pull/26143

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


More information about the hotspot-compiler-dev mailing list