RFR: 8332265: RISC-V: Materialize pointers faster by using a temp register [v6]

Hamlin Li mli at openjdk.org
Fri May 24 10:52:07 UTC 2024


On Thu, 23 May 2024 10:55:35 GMT, Robbin Ehn <rehn at openjdk.org> wrote:

>> Hi, please consider!
>> 
>> Materializing a 48-bit pointer, using an additional register, we can do with:
>> lui + lui + slli + add + addi
>> This 15% faster both on VF2 and in CPU models, compared to movptr().
>> 
>> As we often materialize during calls there is free registers.
>> 
>> I have choose just a few spot to use it, many more can use.
>> E.g. la() with tmp register can use li48 instead of movptr.
>> 
>> Running tests now (so far so good), as if I screwed up IC calls it should be seen fast.
>> And benchmarks when hardware is free.
>
> Robbin Ehn has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - Fixed more comments
>  - Fixed comments

src/hotspot/cpu/riscv/macroAssembler_riscv.cpp line 1681:

> 1679: }
> 1680: 
> 1681: void MacroAssembler::movptr1(Register Rd, uint64_t imm64, int32_t &offset) {

Original code of MacroAssembler:: movptr(...) is bit tricky at `upper -= lower;` to understand for me, and I think new MacroAssembler:: movptr2(...) uses the similar way at `lower30 - low12`.
I can add some comment later to help future understanding.

src/hotspot/cpu/riscv/macroAssembler_riscv.cpp line 1703:

> 1701:   assert_different_registers(Rd, tmp, noreg);
> 1702: 
> 1703:   uint32_t upper18 = (addr >> 30ull);

literal suffix `ull` could be removed?
And `uint32_t upper18 = (addr >> 30ull);` + `lui(tmp, upper18 << 12);` could be replaced with `lui(tmp, addr >> 18);`?

src/hotspot/cpu/riscv/macroAssembler_riscv.cpp line 1706:

> 1704:   int32_t  lower30 = (addr & 0x3fffffffu);
> 1705:   int32_t  low12   = (lower30 << 20) >> 20;
> 1706:   int32_t  mid18   = ((lower30 - low12) >> 12);

Similar here. `mid18 = ((lower30 - low12) >> 12);` and `lui(Rd, mid18 << 12);` could be replaced with `lui(Rd, lower30 - low12);`?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19246#discussion_r1613279908
PR Review Comment: https://git.openjdk.org/jdk/pull/19246#discussion_r1613247627
PR Review Comment: https://git.openjdk.org/jdk/pull/19246#discussion_r1613257147


More information about the hotspot-dev mailing list