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

Ziviani github.com+670087+jrziviani at openjdk.java.net
Sat Oct 31 04:01:54 UTC 2020


On Fri, 30 Oct 2020 10:19:03 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
>
> If you just want to add C1 code, I suggest to do that in this PR.
> It's up to you if you prefer a new PR for further changes. I still think cleaning up the ad file a bit and using branch free code for all Power processors would be nice. I'd also be ok with replacing the "expand" code by assembly code directly in "ins_encode". Should be good enough for modern out-of-order processors.

Hello Martin,
I added a new  [commit](https://github.com/openjdk/jdk/pull/907/commits/fed1b46bb776d0bd63a9a4b1b9d55d248d3fecfc) here just to make sure I'm following your idea.
About C1, my experiences didn't make much difference. I think I need to write a better load to stress the code.

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

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


More information about the hotspot-compiler-dev mailing list