summaryrefslogtreecommitdiffstats
path: root/lib/libc/i386/string
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2005-04-21 23:07:20 +0000
committeralc <alc@FreeBSD.org>2005-04-21 23:07:20 +0000
commitb459bdba219f3fa62232f821fc325ce4a3f05974 (patch)
tree6c9382005f6d2d9ebd16979efd2a63cfa990c571 /lib/libc/i386/string
parent2b9aae1b7a6e7fb07dfaaa35a34911449d807dea (diff)
downloadFreeBSD-src-b459bdba219f3fa62232f821fc325ce4a3f05974.zip
FreeBSD-src-b459bdba219f3fa62232f821fc325ce4a3f05974.tar.gz
Eliminate an unpredictable branch from bcmp().
Reviewed by: bde
Diffstat (limited to 'lib/libc/i386/string')
-rw-r--r--lib/libc/i386/string/bcmp.S9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/libc/i386/string/bcmp.S b/lib/libc/i386/string/bcmp.S
index 60ece4f..aa6a6ab 100644
--- a/lib/libc/i386/string/bcmp.S
+++ b/lib/libc/i386/string/bcmp.S
@@ -43,7 +43,6 @@ ENTRY(bcmp)
pushl %esi
movl 12(%esp),%edi
movl 16(%esp),%esi
- xorl %eax,%eax /* clear return value */
cld /* set compare direction forward */
movl 20(%esp),%ecx /* compare by words */
@@ -56,9 +55,9 @@ ENTRY(bcmp)
andl $3,%ecx
repe
cmpsb
- je L2
-
-L1: incl %eax
-L2: popl %esi
+L1:
+ setne %al
+ movsbl %al,%eax
+ popl %esi
popl %edi
ret
OpenPOWER on IntegriCloud