Eliminate an unpredictable branch from bcmp().

Reviewed by: bde
This commit is contained in:
alc 2005-04-21 23:07:20 +00:00
parent 2b9aae1b7a
commit b459bdba21
2 changed files with 6 additions and 9 deletions

View File

@ -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

View File

@ -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