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

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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

[PATCH] Fix x86_64 __FP_CLZ


Hi!

bsrq %rdx, %eax ins not a valid instruction.  While we could tweak these
macros to store result in the same sized variable as input and only then
copy to r and furthermore handle the various sizeof (x) cases, GCC 3.4+
contains __builtin_clz{,l,ll} and the generic soft-fp.h definition already
handles that all (plus __builtin_clz expands to bsrl on i?86/x86_64
and __builtin_clzl on x86_64 to bsrq).

2007-01-10  Jakub Jelinek  <jakub@redhat.com>

	* sysdeps/i386/soft-fp/sfp-machine.h (__FP_CLZ): Remove.
	* sysdeps/x86_64/soft-fp/sfp-machine.h (__FP_CLZ): Likewise.

--- libc/sysdeps/i386/soft-fp/sfp-machine.h.jj	2002-11-01 22:49:28.000000000 +0100
+++ libc/sysdeps/i386/soft-fp/sfp-machine.h	2007-01-10 12:15:01.000000000 +0100
@@ -27,12 +27,6 @@
 	  : "0"(xh), "1"(xl), "g"(yh), "g"(yl)				\
 	  : "cc")
 
-#define __FP_CLZ(r, x)							\
-  do {									\
-    __asm__("bsrl %1,%0" : "=r"(r) : "g"(x) : "cc");			\
-    r ^= 31;								\
-  } while (0)
-
 #define _i386_mul_32_64(rh, rl, x, y)					\
   __asm__("mull %2" : "=d"(rh), "=a"(rl) : "%g"(x), "1"(y) : "cc")
 
--- libc/sysdeps/x86_64/soft-fp/sfp-machine.h.jj	2002-11-01 22:49:29.000000000 +0100
+++ libc/sysdeps/x86_64/soft-fp/sfp-machine.h	2007-01-10 12:13:31.000000000 +0100
@@ -3,12 +3,6 @@
 #define _FP_WS_TYPE		signed long
 #define _FP_I_TYPE		long
 
-#define __FP_CLZ(r, x)							\
-  do {									\
-    __asm__("bsrq %1,%0" : "=r"(r) : "g"(x) : "cc");			\
-    r ^= 63;								\
-  } while (0)
-
 #define _FP_NANFRAC_S		_FP_QNANBIT_S
 #define _FP_NANFRAC_D		_FP_QNANBIT_D, 0
 #define _FP_NANFRAC_Q		_FP_QNANBIT_Q, 0, 0, 0

	Jakub


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