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 v3] Improve strtok(_r) performance


Hi,

In powerpc64/power7/memchr.S this bit looks suspicious:

L(done):
#ifdef __LITTLE_ENDIAN__
        addi    r0,r3,-1
        andc    r0,r0,r3
        popcntd r0,r0         /* Count trailing zeros.  */
#else
        cntlzd  r0,r3         /* Count leading zeros before the match.  */
#endif
        cmpld   r8,r7         /* Are we on the last dword?  */
        srdi    r0,r0,3       /* Convert leading/trailing zeros to bytes.  */
        add     r3,r8,r0
        cmpld   cr7,r0,r5     /* If on the last dword, check byte offset.  */
        bnelr
        blelr   cr7
        li      r3,0
        blr

When the size is the maximum and the input pointer is at offset 2 or larger within an 8-byte aligned address, r7 == r8, and it will return NULL if it matches in the first 8 bytes since the match appears to be after the end pointer. When it matches later, r7 != r8 and it works.

Wilco



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