about summary refs log tree commit diff
path: root/sysdeps/i386/i486/bits
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-04-30 17:37:52 +0000
committerUlrich Drepper <drepper@redhat.com>1999-04-30 17:37:52 +0000
commitc5883607f5b138b31176de7b2664f0d217b2dbf2 (patch)
tree29a4400670e399efad0968872dd2902bb0a2e584 /sysdeps/i386/i486/bits
parentad8fa1c670df9f56378682e2985f0e54057240e9 (diff)
downloadglibc-c5883607f5b138b31176de7b2664f0d217b2dbf2.tar.gz
glibc-c5883607f5b138b31176de7b2664f0d217b2dbf2.tar.xz
glibc-c5883607f5b138b31176de7b2664f0d217b2dbf2.zip
(__memset_gc): Help generating better code in presence of the asm.
Diffstat (limited to 'sysdeps/i386/i486/bits')
-rw-r--r--sysdeps/i386/i486/bits/string.h38
1 files changed, 19 insertions, 19 deletions
diff --git a/sysdeps/i386/i486/bits/string.h b/sysdeps/i386/i486/bits/string.h
index 136de9a199..2317d3f696 100644
--- a/sysdeps/i386/i486/bits/string.h
+++ b/sysdeps/i386/i486/bits/string.h
@@ -210,56 +210,56 @@ memcmp (__const void *__s1, __const void *__s2, size_t __n)
 #define __memset_gc(s, c, n) \
   ({ void *__s = (s);							      \
      unsigned int *__ts = (unsigned int *) __s;				      \
-     unsigned char __c = (unsigned char) (c);				      \
+     unsigned int __c = ((unsigned char) (c)) * 0x01010101;		      \
 									      \
      /* We apply a trick here.  `gcc' would implement the following	      \
 	assignments using absolute operands.  But this uses to much	      \
 	memory (7, instead of 4 bytes).  */				      \
-     if (n >= 5)							      \
+     if (n == 3 || n >= 5)						      \
        __asm__ __volatile__ ("" : "=r" (__c) : "0" (__c));		      \
 									      \
      /* This `switch' statement will be removed at compile-time.  */	      \
      switch (n)								      \
        {								      \
        case 15:								      \
-	 *__ts++ = __c * 0x01010101;					      \
+	 *__ts++ = __c;							      \
        case 11:								      \
-	 *__ts++ = __c * 0x01010101;					      \
+	 *__ts++ = __c;							      \
        case 7:								      \
-	 *__ts++ = __c * 0x01010101;					      \
+	 *__ts++ = __c;							      \
        case 3:								      \
-	 *((unsigned short int *) __ts)++ = __c * 0x0101;		      \
-	 *((unsigned char *) __ts) = __c;				      \
+	 *((unsigned short int *) __ts)++ = (unsigned short int) __c;	      \
+	 *((unsigned char *) __ts) = (unsigned char) __c;		      \
 	 break;								      \
 									      \
        case 14:								      \
-	 *__ts++ = __c * 0x01010101;					      \
+	 *__ts++ = __c;							      \
        case 10:								      \
-	 *__ts++ = __c * 0x01010101;					      \
+	 *__ts++ = __c;							      \
        case 6:								      \
-	 *__ts++ = __c * 0x01010101;					      \
+	 *__ts++ = __c;							      \
        case 2:								      \
-	 *((unsigned short int *) __ts) = __c * 0x0101;			      \
+	 *((unsigned short int *) __ts) = (unsigned short int) __c;	      \
 	 break;								      \
 									      \
        case 13:								      \
-	 *__ts++ = __c * 0x01010101;					      \
+	 *__ts++ = __c;							      \
        case 9:								      \
-	 *__ts++ = __c * 0x01010101;					      \
+	 *__ts++ = __c;							      \
        case 5:								      \
-	 *__ts++ = __c * 0x01010101;					      \
+	 *__ts++ = __c;							      \
        case 1:								      \
-	 *((unsigned char *) __ts) = __c;				      \
+	 *((unsigned char *) __ts) = (unsigned char) __c;		      \
 	 break;								      \
 									      \
        case 16:								      \
-	 *__ts++ = __c * 0x01010101;					      \
+	 *__ts++ = __c;							      \
        case 12:								      \
-	 *__ts++ = __c * 0x01010101;					      \
+	 *__ts++ = __c;							      \
        case 8:								      \
-	 *__ts++ = __c * 0x01010101;					      \
+	 *__ts++ = __c;							      \
        case 4:								      \
-	 *__ts = __c * 0x01010101;					      \
+	 *__ts = __c;							      \
        case 0:								      \
 	 break;								      \
        }								      \