Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - _smp_cmpxchg needlessly restricts register allocator to %ecx and %edx: (1 Item)
   
_smp_cmpxchg needlessly restricts register allocator to %ecx and %edx  
In implementation for x86 in 6.5.0 _smp_cmpxchg needlessly restricts arguments to %ecx and %edx registers.

static __inline int __attribute__((__unused__)) _smp_cmpxchg(volatile unsigned *__dst, unsigned __cmd, unsigned __new) {

	__asm__ __volatile__(
		"lock; cmpxchgl %3, (%2)"
		:"=m" (__atomic_fool_gcc(__dst)), "=a" (__cmd)
		:"d" (__dst), "c" (__new), "1" (__cmd)
		:"memory");
	return __cmd;
}

It could be easily changed to avoid incurring that restriction.

static __inline int __attribute__((__unused__)) _smp_cmpxchg(volatile unsigned *__dst, unsigned __cmd, unsigned __new) {

	__asm__ __volatile__(
		"lock; cmpxchgl %3, %0"
		:"=m" (__atomic_fool_gcc(__dst)), "=a" (__cmd)
        :"m" (*__dst), "r" (__new), "1" (__cmd)
		:"memory");
	return __cmd;
}