RFR: 8352893: C2: OrL/INode::add_ring optimize (x | -1) to -1 [v3]

Manuel Hässig duke at openjdk.org
Mon Mar 31 14:31:43 UTC 2025


> # Issue Summary
> 
> The `add_ring()` implementations of `OrINode` and `OrLNode` are missing the optimization that an or with a value where all bits are ones (since we have signed integers in this case `~0 == -1`) will always yield all zeroes.
> 
> # Changes
> 
> This PR makes the following straight forward changes:
>  - `Or(I|L)Node::add_ring()` returns `-1` if one of the two inputs is `-1`.
>  - Add `Or(I|L)` nodes to the IR framework.
>  - Add a regression IR test for the implemented optimization.
> 
> # Testing
> 
> - [Github Actions](https://github.com/mhaessig/jdk/actions/runs/14110978686)
> - Ran tier1 through tier3 and Oracle internal testing

Manuel Hässig has updated the pull request incrementally with one additional commit since the last revision:

  Remove loop in test and instead use random values

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/24289/files
  - new: https://git.openjdk.org/jdk/pull/24289/files/f286eee0..e02adc43

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=24289&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=24289&range=01-02

  Stats: 19 lines in 1 file changed: 3 ins; 2 del; 14 mod
  Patch: https://git.openjdk.org/jdk/pull/24289.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/24289/head:pull/24289

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


More information about the hotspot-compiler-dev mailing list