On Tue, 20 Sep 2022 22:12:04 GMT, Xue-Lei Andrew Fan <xue...@openjdk.org> wrote:
> Hi, > > In the message digest implementation, for example SHA256, in JDK, two bitwise > operations could be improved with equivalent arithmetic, and then the number > bitwise operations could be reduced accordingly. Specifically > "(x and y) xor ((complement x) and z)" could be replaced with the equivalent > "z xor (x and (y xor z))", and "(x and y) xor (x and z) xor (y and z)" could > be replaced with the equivalent "(x and y) xor ((x xor y) and z)". Each > replacement reduces one bitwise operation, and thus improve the performance. > > Per my testing on my MacOS laptop, the update on SHA256 improves the message > digest throughput by 0.5%-0.8%. The improvement is not significant, but > might be worthy of it as the update is pretty simple and trivial, for those > platforms that do not support CPU intrinsic for a certain hash algorithm. > > This patch update SHA2 implementation only. Please let me know what do you > think. If you are good with this little bit performance, I will update more > message digest implementations. If no one interested in these little > benefits, I will close this PR later. > > Thanks, > Xuelei Marked as reviewed by jjiang (Reviewer). ------------- PR: https://git.openjdk.org/jdk/pull/10365