RFR: 8373555: C2: Optimize redundant input calculations for sign comparisons

Hannes Greule hgreule at openjdk.org
Fri Dec 12 08:23:33 UTC 2025


Instead of sign-comparisons with And,Or,Xor,Max,Min nodes, we can directly compare to one of the inputs of the binary nodes if the other input is irrelevant to the comparison.

There are potentially more operations, but these mentioned here are the most obvious ones. Max and Min could theoretically be expanded to arbitrary comparisons to constants, but I didn't want to introduce more complexity for now.

Please let me know what you think :)

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

Commit messages:
 - more randomized tests
 - simplify sign invariant comparisons
 - test

Changes: https://git.openjdk.org/jdk/pull/28782/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=28782&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8373555
  Stats: 840 lines in 3 files changed: 840 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/28782.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/28782/head:pull/28782

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


More information about the hotspot-compiler-dev mailing list