x86-64: memcmp-avx2-movbe.S needs saturating subtraction [BZ #21662]
commit3ec7c02cc3e922b9364dc8cfd1d4546671b91003
authorFlorian Weimer <fweimer@redhat.com>
Fri, 23 Jun 2017 15:23:44 +0000 (23 17:23 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Fri, 23 Jun 2017 15:24:40 +0000 (23 17:24 +0200)
tree283d54448fe89359272093156316884e61992c9a
parent7fa1d9462baabc5a1058efc13a48444af4678acf
x86-64: memcmp-avx2-movbe.S needs saturating subtraction [BZ #21662]

This code:

L(between_2_3):
/* Load as big endian with overlapping loads and bswap to avoid
   branches.  */
movzwl -2(%rdi, %rdx), %eax
movzwl -2(%rsi, %rdx), %ecx
shll $16, %eax
shll $16, %ecx
movzwl (%rdi), %edi
movzwl (%rsi), %esi
orl %edi, %eax
orl %esi, %ecx
bswap %eax
bswap %ecx
subl %ecx, %eax
ret

needs a saturating subtract because the full register is used.
With this commit, only the lower 24 bits of the register are used,
so a regular subtraction suffices.

The test case change adds coverage for these kinds of bugs.
ChangeLog
string/test-memcmp.c
sysdeps/x86_64/multiarch/memcmp-avx2-movbe.S