diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-04-15 08:23:19 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-04-15 08:23:19 +0000 |
commit | 534dfb536f19737f2642ee56dd67a97c5db6a74e (patch) | |
tree | faf1e08295d084cb44c8986fa179d306d6f0a377 | |
parent | 07bbf922670cce83c0b54f28ad43473d044cae5e (diff) |
amd64 string ops: replace some instructions by smaller ones,
e.g. testb $0xff, %cl -> testb %cl, %cl
-rw-r--r-- | libc/string/x86_64/memset.S | 8 | ||||
-rw-r--r-- | libc/string/x86_64/strcat.S | 2 | ||||
-rw-r--r-- | libc/string/x86_64/strcspn.S | 7 | ||||
-rw-r--r-- | libc/string/x86_64/strlen.S | 2 | ||||
-rw-r--r-- | libc/string/x86_64/strspn.S | 6 |
5 files changed, 12 insertions, 13 deletions
diff --git a/libc/string/x86_64/memset.S b/libc/string/x86_64/memset.S index 0f054ade6..3092e81eb 100644 --- a/libc/string/x86_64/memset.S +++ b/libc/string/x86_64/memset.S @@ -53,15 +53,15 @@ ENTRY (memset) imul %rax,%r8 #endif test $0x7,%edi /* Check for alignment. */ - je 2f + jz 2f .p2align 4 1: /* Align ptr to 8 byte. */ mov %sil,(%rcx) dec %rdx inc %rcx - test $0x7,%ecx - jne 1b + test $0x7,%cl + jnz 1b 2: /* Check for really large regions. */ mov %rdx,%rax @@ -107,7 +107,7 @@ ENTRY (memset) jne 8b 9: #if BZERO_P - nop /* huh?? */ + /* nothing */ #else /* Load result (only if used as memset). */ mov %rdi,%rax /* start address of destination is result */ diff --git a/libc/string/x86_64/strcat.S b/libc/string/x86_64/strcat.S index ddec8ee79..9e2da50f2 100644 --- a/libc/string/x86_64/strcat.S +++ b/libc/string/x86_64/strcat.S @@ -103,7 +103,7 @@ ENTRY (BP_SYM (strcat)) the addition will not result in 0. */ jz 4b /* no NUL found => continue loop */ - .p2align 4 /* Align, it's a jump target. */ + .p2align 4 /* Align, it is a jump target. */ 3: subq $8,%rax /* correct pointer increment. */ testb %cl, %cl /* is first byte NUL? */ diff --git a/libc/string/x86_64/strcspn.S b/libc/string/x86_64/strcspn.S index c02fbbb5f..9563de496 100644 --- a/libc/string/x86_64/strcspn.S +++ b/libc/string/x86_64/strcspn.S @@ -26,7 +26,6 @@ #include "_glibc_inc.h" /* Seems to be unrolled too much */ -/* (and why testb $0xff, %cl, not testb %cl, %cl?) */ /* BEWARE: `#ifdef strcspn' means that strcspn is redefined as `strpbrk' */ #define STRPBRK_P (defined strcspn) @@ -63,19 +62,19 @@ L(2): movb (%rax), %cl /* get byte from skipset */ movb %cl, (%rsp,%rcx) /* set corresponding byte in skipset table */ movb 1(%rax), %cl /* get byte from skipset */ - testb $0xff, %cl /* is NUL char? */ + testb %cl, %cl /* is NUL char? */ jz L(1) /* yes => start compare loop */ movb %cl, (%rsp,%rcx) /* set corresponding byte in skipset table */ movb 2(%rax), %cl /* get byte from skipset */ - testb $0xff, %cl /* is NUL char? */ + testb %cl, %cl /* is NUL char? */ jz L(1) /* yes => start compare loop */ movb %cl, (%rsp,%rcx) /* set corresponding byte in skipset table */ movb 3(%rax), %cl /* get byte from skipset */ addq $4, %rax /* increment skipset pointer */ movb %cl, (%rsp,%rcx) /* set corresponding byte in skipset table */ - testb $0xff, %cl /* is NUL char? */ + testb %cl, %cl /* is NUL char? */ jnz L(2) /* no => process next dword from skipset */ L(1): leaq -4(%rdx), %rax /* prepare loop */ diff --git a/libc/string/x86_64/strlen.S b/libc/string/x86_64/strlen.S index e79537f87..3b6f2ac86 100644 --- a/libc/string/x86_64/strlen.S +++ b/libc/string/x86_64/strlen.S @@ -98,7 +98,7 @@ ENTRY (strlen) the addition will not result in 0. */ jz 4b /* no NUL found => continue loop */ - .p2align 4 /* Align, it's a jump target. */ + .p2align 4 /* Align, it is a jump target. */ 3: subq $8,%rax /* correct pointer increment. */ testb %cl, %cl /* is first byte NUL? */ diff --git a/libc/string/x86_64/strspn.S b/libc/string/x86_64/strspn.S index c126abd2e..416424565 100644 --- a/libc/string/x86_64/strspn.S +++ b/libc/string/x86_64/strspn.S @@ -57,19 +57,19 @@ L(2): movb (%rax), %cl /* get byte from stopset */ movb %cl, (%rsp,%rcx) /* set corresponding byte in stopset table */ movb 1(%rax), %cl /* get byte from stopset */ - testb $0xff, %cl /* is NUL char? */ + testb %cl, %cl /* is NUL char? */ jz L(1) /* yes => start compare loop */ movb %cl, (%rsp,%rcx) /* set corresponding byte in stopset table */ movb 2(%rax), %cl /* get byte from stopset */ - testb $0xff, %cl /* is NUL char? */ + testb %cl, %cl /* is NUL char? */ jz L(1) /* yes => start compare loop */ movb %cl, (%rsp,%rcx) /* set corresponding byte in stopset table */ movb 3(%rax), %cl /* get byte from stopset */ addq $4, %rax /* increment stopset pointer */ movb %cl, (%rsp,%rcx) /* set corresponding byte in stopset table */ - testb $0xff, %cl /* is NUL char? */ + testb %cl, %cl /* is NUL char? */ jnz L(2) /* no => process next dword from stopset */ L(1): leaq -4(%rdx), %rax /* prepare loop */ |