RFR: 8255553: [PPC64] Introduce and use setbc and setnbc P10 instructions [v2]

Ziviani github.com+670087+jrziviani at openjdk.java.net
Sat Oct 31 03:53:02 UTC 2020


On Fri, 30 Oct 2020 10:12:51 GMT, Martin Doerr <mdoerr at openjdk.org> wrote:

>> Ziviani has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains two commits:
>> 
>>  - 8255553: [PPC64] Exploit branchless comparison in C2
>>  - 8255553: [PPC64] Introduce and use setbc and setnbc P10 instructions
>>    
>>    - setbc RT,BI: sets RT to 1 if CR(BI) is 1, otherwise 0.
>>    - setnbc RT,BI: sets RT to -1 if CR(BI) is 1, otherwise 0.
>>    Ref: PowerISA 3.1, page 129.
>>    
>>    These instructions are particularly interesting to improve the following
>>    pattern `(src1<src2)? -1: ((src1>src2)? 1: 0)`, which can be found in
>>    `instruct cmpL3_reg_reg_ExEx()@ppc.ad`, by removing its branches.
>>    
>>    Long.toString, that generate such pattern in getChars, has showed a
>>    good performance gain by using these new instructions.
>>    
>>    Example:
>>    for (int i = 0; i < 200_000; i++)
>>      res = Long.toString((long)i);
>>    
>>    java -Xcomp -XX:CompileThreshold=1 -XX:-TieredCompilation TestToString
>>    
>>    Without setbc (average): 0.1178 seconds
>>    With setbc (average): 0.0396 seconds
>
> src/hotspot/cpu/ppc/ppc.ad line 11521:
> 
>> 11519:     __ setbc(R0, (($crx$$reg << 2) | 1) /* greater than */);
>> 11520:     __ setnbc($dst$$Register, ($crx$$reg << 2) /* less than */);
>> 11521:     __ or_unchecked($dst$$Register, $dst$$Register, R0);
> 
> In general, I think it'd be better to use orr which makes sure we never unintentionally emit an instruction which modifies smt priority "smt_prio_...". In this case dst != R0, so this doesn't happen.

Fixed!

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

PR: https://git.openjdk.java.net/jdk/pull/907


More information about the hotspot-compiler-dev mailing list