summaryrefslogtreecommitdiffstats
path: root/crypto/x86_64cpuid.pl
diff options
context:
space:
mode:
authorAndy Polyakov <appro@openssl.org>2007-05-14 21:35:25 +0000
committerAndy Polyakov <appro@openssl.org>2007-05-14 21:35:25 +0000
commitb2dba9bf1f8f73376b9c1f0904a86996c728b236 (patch)
tree8848a4f5efdf02d841b1ebea4969d879d6e61eb5 /crypto/x86_64cpuid.pl
parent932cc129ee61f5b72636eee6a7c3268e23967f7b (diff)
Profiling revealed that OPENSSL_cleanse consumes *more* CPU time than
sha1_block_data_order when hashing short messages. Move OPENSSL_cleanse to "cpuid" assembler module and gain 2x.
Diffstat (limited to 'crypto/x86_64cpuid.pl')
-rw-r--r--crypto/x86_64cpuid.pl32
1 files changed, 32 insertions, 0 deletions
diff --git a/crypto/x86_64cpuid.pl b/crypto/x86_64cpuid.pl
index bc06e99cfb..2f657ca9d8 100644
--- a/crypto/x86_64cpuid.pl
+++ b/crypto/x86_64cpuid.pl
@@ -155,4 +155,36 @@ OPENSSL_ia32_cpuid:
or %rcx,%rax
ret
.size OPENSSL_ia32_cpuid,.-OPENSSL_ia32_cpuid
+
+.globl OPENSSL_cleanse
+.type OPENSSL_cleanse,\@function,2
+.align 16
+OPENSSL_cleanse:
+ xor %rax,%rax
+ cmp \$15,%rsi
+ jae .Lot
+.Little:
+ mov %al,(%rdi)
+ sub \$1,%rsi
+ lea 1(%rdi),%rdi
+ jnz .Little
+ ret
+.align 16
+.Lot:
+ test \$7,%rdi
+ jz .Laligned
+ mov %al,(%rdi)
+ lea -1(%rsi),%rsi
+ lea 1(%rdi),%rdi
+ jmp .Lot
+.Laligned:
+ mov %rax,(%rdi)
+ lea -8(%rsi),%rsi
+ test \$-8,%rsi
+ lea 8(%rdi),%rdi
+ jnz .Laligned
+ cmp \$0,%rsi
+ jne .Little
+ ret
+.size OPENSSL_cleanse,.-OPENSSL_cleanse
___