This is the mail archive of the glibc-bugs@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]

[Bug string/21662] New: memcmp-avx2-movbe.S lacks saturating subtraction for between_2_3


https://sourceware.org/bugzilla/show_bug.cgi?id=21662

            Bug ID: 21662
           Summary: memcmp-avx2-movbe.S lacks saturating subtraction for
                    between_2_3
           Product: glibc
           Version: 2.26
            Status: NEW
          Severity: normal
          Priority: P2
         Component: string
          Assignee: fweimer at redhat dot com
          Reporter: fweimer at redhat dot com
  Target Milestone: ---
            Target: x86-64

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.

Reproducer:

#include <string.h>
#include <stdio.h>

int
main (void)
{
  const char *left = "\uA46D\u0291";
  const char *right = "bar";
  printf ("%d\n", memcmp (left, right, 2));
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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