This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


On Fri, Jun 23, 2017 at 11:33 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> 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

Here is the benchmark result on Haswell.

[hjl@gnu-6 glibc-test]$ make
./test
movb  : 19937666
movzbl: 21518186
[hjl@gnu-6 glibc-test]$

-- 
H.J.

Attachment: movb.tar.xz
Description: application/xz


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]