RFR: 8351140: RISC-V: Intrinsify Unsafe::setMemory [v10]

Fei Yang fyang at openjdk.org
Mon May 19 08:46:52 UTC 2025


On Mon, 19 May 2025 06:45:31 GMT, Anjian-Wen <duke at openjdk.org> wrote:

>> The current version is okay. I mean, we can unroll the storage bytes and save some "bnez" by eliminating the loop, something like this:
>> 
>> bind(unroll_4);
>> test_bit(tmp, count, 2);
>> beqz(tmp, unroll_2);
>> sb(value, Address(dest, 0);
>> sb(value, Address(dest, 1);
>> sb(value, Address(dest, 2);
>> sb(value, Address(dest, 3);
>> addi(dest, dest, 4);
>> subi(count, count, 4);
>> 
>> bind(unroll_2);
>> test_bit(tmp, count, 1);
>> beqz(tmp, unroll_1);
>> sb(value, Address(dest, 0);
>> sb(value, Address(dest, 1);
>> addi(dest, dest, 2);
>> subi(count, count, 2);
>> 
>> bind(unroll_1);
>> test_bit(tmp, count, 0);
>> beqz(tmp, end);
>> sb(value, Address(dest, 0);
>> addi(dest, dest, 1);
>> subi(count, count, 1);
>> 
>> bind(end);
>
> I understand, that makes sence,  it seems can reduce 4 jump when count is 7, I will test on that later, thanks!!

Interesting! There's no need to update `dest` and `count` in `unroll_1`. And I think we can reuse existing label names like `L_fill_4`, `L_fill_2`, `L_fill_1` here which will look more obvious. We can make them local with `{` and `}` when they are decared and used.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23890#discussion_r2095176894


More information about the hotspot-compiler-dev mailing list