ARMv8指令集新增了crypto加密指令集,支持包括AES、SHA1、SHA256
SHA256指令集支持128bit的寄存器
PINE 64 aarch64环境下测试
速度对比:10000000次计算SHA256测试
CPU C CODE : time:14872734 ns ARMv8 HW : time:1567756 ns
下面是aarch64下的部分汇编代码
ld1 {v5.16b-v8.16b}, [x1], #64 mov v2.16b, v0.16b mov v3.16b, v1.16b rev32 v5.16b, v5.16b rev32 v6.16b, v6.16b add v9.4s, v5.4s, v16.4s rev32 v7.16b, v7.16b add v10.4s, v6.4s, v17.4s mov v4.16b, v2.16b sha256h q2, q3, v9.4s sha256h2 q3, q4, v9.4s sha256su0 v5.4s, v6.4s rev32 v8.16b, v8.16b add v9.4s, v7.4s, v18.4s mov v4.16b, v2.16b sha256h q2, q3, v10.4s sha256h2 q3, q4, v10.4s sha256su0 v6.4s, v7.4s sha256su1 v5.4s, v7.4s, v8.4s add v10.4s, v8.4s, v19.4s mov v4.16b, v2.16b sha256h q2, q3, v9.4s sha256h2 q3, q4, v9.4s sha256su0 v7.4s, v8.4s sha256su1 v6.4s, v8.4s, v5.4s add v9.4s, v5.4s, v20.4s mov v4.16b, v2.16b sha256h q2, q3, v10.4s sha256h2 q3, q4, v10.4s sha256su0 v8.4s, v5.4s
完整测试代码:github