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

Ashay Rane duke at openjdk.org
Thu Feb 26 16:42:46 UTC 2026


On Tue, 24 Feb 2026 17:00:42 GMT, Ashay Rane <duke at openjdk.org> wrote:

> 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.

@merykitty I extracted the first set of changes from PR 29546 into this PR.  When you get a chance, could you review this PR please?

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

PR Comment: https://git.openjdk.org/jdk/pull/29898#issuecomment-3967787676


More information about the hotspot-dev mailing list