On Thu, 22 May 2025 08:55:09 GMT, Maurizio Cimadamore <mcimadam...@openjdk.org> 
wrote:

>> Per Minborg has updated the pull request incrementally with one additional 
>> commit since the last revision:
>> 
>>   Correct typo in comment
>
> src/java.base/share/classes/jdk/internal/foreign/SegmentBulkOperations.java 
> line 93:
> 
>> 91:             case 2 -> {
>> 92:                 
>> SCOPED_MEMORY_ACCESS.putShortUnaligned(dst.sessionImpl(), 
>> dst.unsafeGetBase(), dst.unsafeGetOffset(), (short) longValue, 
>> !Architecture.isLittleEndian());
>> 93:                 
>> SCOPED_MEMORY_ACCESS.putShortUnaligned(dst.sessionImpl(), 
>> dst.unsafeGetBase(), dst.unsafeGetOffset() + len - Short.BYTES, (short) 
>> longValue, !Architecture.isLittleEndian());
> 
> So that I understand, since this configuration might pick up both length = 2 
> and length = 3, in 50% of cases there's a redundant store? This is also true 
> for length = 4, 5, 6, 7 -- but in this case the chance of redundant store is 
> reduced to 25%.

That is correct. But it seems the hardware can handle redundant stores better 
than handling more branching. One idea is to add in "halfbits" to the 
tableswitch which would reduce redundant stores. I think this would have little 
to no performance effect while complicating the code, but it might be worth 
trying anyhow.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25383#discussion_r2102307360

Reply via email to