diff options
author | alc <alc@FreeBSD.org> | 2005-04-21 23:07:20 +0000 |
---|---|---|
committer | alc <alc@FreeBSD.org> | 2005-04-21 23:07:20 +0000 |
commit | b459bdba219f3fa62232f821fc325ce4a3f05974 (patch) | |
tree | 6c9382005f6d2d9ebd16979efd2a63cfa990c571 | |
parent | 2b9aae1b7a6e7fb07dfaaa35a34911449d807dea (diff) | |
download | FreeBSD-src-b459bdba219f3fa62232f821fc325ce4a3f05974.zip FreeBSD-src-b459bdba219f3fa62232f821fc325ce4a3f05974.tar.gz |
Eliminate an unpredictable branch from bcmp().
Reviewed by: bde
-rw-r--r-- | lib/libc/i386/string/bcmp.S | 9 | ||||
-rw-r--r-- | sys/i386/i386/support.s | 6 |
2 files changed, 6 insertions, 9 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 diff --git a/sys/i386/i386/support.s b/sys/i386/i386/support.s index 300aa91..1e970da 100644 --- a/sys/i386/i386/support.s +++ b/sys/i386/i386/support.s @@ -1401,7 +1401,6 @@ ENTRY(bcmp) movl 12(%esp),%edi movl 16(%esp),%esi movl 20(%esp),%edx - xorl %eax,%eax movl %edx,%ecx shrl $2,%ecx @@ -1414,10 +1413,9 @@ ENTRY(bcmp) andl $3,%ecx repe cmpsb - je 2f 1: - incl %eax -2: + setne %al + movsbl %al,%eax popl %esi popl %edi ret |