RFR: 8344306: RISC-V: Add zicond
Robbin Ehn
rehn at openjdk.org
Wed Nov 27 07:28:43 UTC 2024
On Wed, 27 Nov 2024 01:23:13 GMT, Fei Yang <fyang at openjdk.org> wrote:
>> Hi, please consider.
>>
>> In cpu models we save ~1 cycle per removed branch.
>> This patch removes ~0.1% of branches in generic C2 generated code.
>> We should probably investigate if we can improve/add peephole optimization to remove more branches.
>>
>> As the C1 cmov code is a bit tricky I left that as a followup.
>>
>> I added gtests for the cmovs.
>> (we should add coverage for more of masm in this gtest suit)
>> Pro tip, invoke the gtestLauncher directly (you only need to build exploded):
>> `gtestLauncher -jdk build/linux-riscv64-server-fastdebug/jdk/ --gtest_break_on_failure --gtest_filter="*RiscV*" -XX:+UnlockDiagnosticVMOptions -XX:+UseZicond -XX:ParallelGCThreads=1 -XX:ConcGCThreads=1 -XX:CICompilerCount=2`
>>
>> Tested on Spacemit X60, gtests and tier1.
>>
>> Thanks, Robbin
>
> src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp line 2006:
>
>> 2004:
>> 2005: void C2_MacroAssembler::enc_cmove(int cmpFlag, Register op1, Register op2, Register dst, Register src) {
>> 2006: bool is_unsigned = (cmpFlag & unsigned_branch_mask) == unsigned_branch_mask ? true : false;
>
> Maybe:
> `bool is_unsigned = (cmpFlag & unsigned_branch_mask) ? true : false;`
The "(cmpFlag & unsigned_branch_mask)" is a integer value.
As [hotspot don't do implicit bool values](https://github.com/openjdk/jdk/blob/master/doc/hotspot-style.md), I need to create the bool value by that comparison.
But I don't need the ternary operator.
I'll update to:
`bool is_unsigned = (cmpFlag & unsigned_branch_mask) == unsigned_branch_mask;`
> src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp line 2007:
>
>> 2005: void C2_MacroAssembler::enc_cmove(int cmpFlag, Register op1, Register op2, Register dst, Register src) {
>> 2006: Label L;
>> 2007: cmp_branch(cmpFlag ^ (1 << neg_cond_bits), op1, op2, L);
>
> The global `neg_cond_bits` is unused after this change. I think we should remove it.
Thanks
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22386#discussion_r1860065725
PR Review Comment: https://git.openjdk.org/jdk/pull/22386#discussion_r1860066652
More information about the hotspot-dev
mailing list