In the Power9 instruction set, there are several instructions available for doing byte reversal within a
VSX register. xxbrd can be used for reversing bytes in a 64-bit Long, and xxbrw can be used to reverse bytes in a 32-bit Integer.
There is also an instruction for reversing 16-bit short types, but the cost overhead of using a VSX operation for this is prohibitive compared with the existing instruction sequence.
These two instructions can be used to perform the byte reversal by moving the contents of the source general purpose register to a vector register, performing the reversal, and moving the vector register to the destination general purpose register.
A simple benchmark shows an overall minimum of 38% performance improvement for Long.reverseBytes() and a 15% improvement for Integer.reverseBytes().
VSX register. xxbrd can be used for reversing bytes in a 64-bit Long, and xxbrw can be used to reverse bytes in a 32-bit Integer.
There is also an instruction for reversing 16-bit short types, but the cost overhead of using a VSX operation for this is prohibitive compared with the existing instruction sequence.
These two instructions can be used to perform the byte reversal by moving the contents of the source general purpose register to a vector register, performing the reversal, and moving the vector register to the destination general purpose register.
A simple benchmark shows an overall minimum of 38% performance improvement for Long.reverseBytes() and a 15% improvement for Integer.reverseBytes().
- relates to
-
JDK-8178294 PPC64: optimize byte reverse code for int value
- Closed
-
JDK-8256479 [PPC64] C2 crashes when UseVectorByteReverseInstructionsPPC64 used without SuperwordUseVSX
- Resolved