[PATCH] x86-64: memcmp-avx2-movbe.S needs saturating subtraction [BZ #21662]

H.J. Lu hjl.tools@gmail.com
Fri Jun 23 18:33:00 GMT 2017


On Fri, Jun 23, 2017 at 9:42 AM, Florian Weimer <fweimer@redhat.com> wrote:
> On 06/23/2017 06:38 PM, Carlos O'Donell wrote:
>
>> I assume that this catches the regression by ensuring the high values of
>> the subtraction result in an underflow which results in a positive value
>> of the subtraction and a wrong answer?
>
> Yes, I thought I said so in the commit message.
>
>> Was this comment ever accurate? mobzwl is not a BE load.
>
> We used bswap, so the register contents before the comparison is in
> big-endian format.
>
>>> +    orl     %edi, %eax
>>> +    orl     %esi, %ecx
>>> +    /* Subtraction is okay because the upper 8 bits a zero.  */
>>
>> s/a zero/are zero/g
>
> Okay, I'll fix this typo in a follow-up commit.

How about this patch to turn

movzbl -1(%rdi, %rdx), %edi
movzbl -1(%rsi, %rdx), %esi
orl %edi, %eax
orl %esi, %ecx

into

movb -1(%rdi, %rdx), %al
movb -1(%rsi, %rdx), %cl


H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-x86-64-Optimize-L-between_2_3-in-memcmp-avx2-movbe.S.patch
Type: text/x-patch
Size: 1214 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20170623/1d18af9c/attachment.bin>


More information about the Libc-alpha mailing list