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:01 UTC 2020


> - 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

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

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

Changes: https://git.openjdk.java.net/jdk/pull/907/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=907&range=01
  Stats: 145 lines in 3 files changed: 43 ins; 73 del; 29 mod
  Patch: https://git.openjdk.java.net/jdk/pull/907.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/907/head:pull/907

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


More information about the hotspot-compiler-dev mailing list