RFR: 8278857: C2: optimize (x << 2) & -4 to x (and similar patterns) -> KnownBits for LShift

Ashay Rane duke at openjdk.org
Tue Feb 24 17:07:40 UTC 2026


This PR contains the first of the two changes necessary to resolve
JDK-8278857.

The commit message, pasted below, has additional details.

> Augment `RangeInference` with information about left shifts
> 
> Add `RangeInference::infer_lshift()` to compute type information for
> left shift operations.  This method tracks known zero bits in the low
> positions (the bottom `shift` bits are always zero after a left shift)
> and computes signed and unsigned range bounds when the shift does not
> cause overflow.
> 
> This is the first of the two changes necessary to resolve JDK-8278857.
> The second change will build on top of these changes to enable AND nodes
> to be optimized away when the bits that would have been cleared by the
> AND operation were already known to be zero.

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

Commit messages:
 - Augment `RangeInference` with information about left shifts

Changes: https://git.openjdk.org/jdk/pull/29898/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=29898&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8278857
  Stats: 90 lines in 4 files changed: 80 ins; 3 del; 7 mod
  Patch: https://git.openjdk.org/jdk/pull/29898.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/29898/head:pull/29898

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


More information about the hotspot-dev mailing list