RFR: 8255553: [PPC64] Introduce and use setbc and setnbc P10 instructions
Martin Doerr
mdoerr at openjdk.java.net
Fri Oct 30 10:21:44 UTC 2020
On Wed, 28 Oct 2020 17:00:43 GMT, Ziviani <github.com+670087+jrziviani at openjdk.org> wrote:
> - 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.
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.
-------------
PR: https://git.openjdk.java.net/jdk/pull/907
More information about the hotspot-compiler-dev
mailing list