RFR: 8346664: C2: Optimize mask check with constant offset
Emanuel Peter
epeter at openjdk.org
Fri Jan 17 14:53:01 UTC 2025
On Mon, 13 Jan 2025 18:28:26 GMT, Matthias Ernst <duke at openjdk.org> wrote:
>> Fixes [JDK-8346664](https://bugs.openjdk.org/browse/JDK-8346664): extends the optimization of masked sums introduced in #6697 to cover constant values, which currently break the optimization.
>>
>> Such constant values arise in an expression of the following form, for example from `MemorySegmentImpl#isAlignedForElement`:
>>
>>
>> (base + (index + 1) << 8) & 255
>> => MulNode
>> (base + (index << 8 + 256)) & 255
>> => AddNode
>> ((base + index << 8) + 256) & 255
>>
>>
>> Currently, `256` is not being recognized as a shifted value. This PR enables further reduction:
>>
>>
>> ((base + index << 8) + 256) & 255
>> => MulNode (this PR)
>> (base + index << 8) & 255
>> => MulNode (PR #6697)
>> base & 255 (loop invariant)
>>
>>
>> Implementation notes:
>> * I verified that the originating issue "scaled varhandle indexed with i+1" (https://mail.openjdk.org/pipermail/panama-dev/2024-December/020835.html) is resolved with this PR.
>> * ~in order to stay with the flow of the current implementation, I refrained from solving general (const & mask)==0 cases, but only those where const == _ << shift.~
>> * ~I modified existing test cases adding/subtracting from the index var (which would fail with current C2). Let me know if would like to see separate cases for these.~
>
>> two weeks to process your OCA
>
> I don't get the impression anything is being processed here. Is there any way to understand where we stand?
@mernst-github I just saw your message. I'm mentioned it to my manager @TobiHartmann . We are looking into it, it looks like it is taking longer than usual. Seems the holidays were a partial reason for that.
I will also get back to reviewing, there are lots of open PR at the time, so it may take a few days.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/22856#issuecomment-2589608006
More information about the hotspot-compiler-dev
mailing list