Skip to content

Commit

Permalink
Add fmax and fmin inlines for x86-64
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulrich Drepper committed Sep 15, 2011
1 parent ee4d031 commit 4c1a1f7
Showing 2 changed files with 46 additions and 5 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2011-09-15 Ulrich Drepper <drepper@gmail.com>

* sysdeps/x86_64/fpu/bits/mathinline.h: Add fmax and fmin optimizations
for __FINITE_MATH_ONLY__ == 1.

2011-09-14 Ulrich Drepper <drepper@gmail.com>

* sysdeps/x86_64/fpu/s_copysign.S [ELF]: Use correct section.
46 changes: 41 additions & 5 deletions sysdeps/x86_64/fpu/bits/mathinline.h
Original file line number Diff line number Diff line change
@@ -64,26 +64,29 @@ __NTH (__signbitl (long double __x))
return (__u.__i[2] & 0x8000) != 0;
}

#ifdef __USE_ISOC99
__BEGIN_NAMESPACE_C99

/* Round to nearest integer. */
# if __WORDSIZE == 64 || defined __SSE_MATH__
# if __WORDSIZE == 64 || defined __SSE_MATH__
__MATH_INLINE long int
__NTH (lrintf (float __x))
{
long int __res;
asm ("cvtss2si %1, %0" : "=r" (__res) : "xm" (__x));
return __res;
}
# endif
# if __WORDSIZE == 64 || defined __SSE2_MATH__
# endif
# if __WORDSIZE == 64 || defined __SSE2_MATH__
__MATH_INLINE long int
__NTH (lrint (double __x))
{
long int __res;
asm ("cvtsd2si %1, %0" : "=r" (__res) : "xm" (__x));
return __res;
}
# endif
# if __WORDSIZE == 64
# endif
# if __WORDSIZE == 64
__MATH_INLINE long long int
__NTH (llrintf (float __x))
{
@@ -98,6 +101,39 @@ __NTH (llrint (double __x))
asm ("cvtsd2si %1, %0" : "=r" (__res) : "xm" (__x));
return __res;
}
# endif

# if __FINITE_MATH_ONLY__ == 1 && (__WORDSIZE == 64 || defined __SSE2_MATH__)
/* Determine maximum of two values. */
__MATH_INLINE float
__NTH (fmaxf (float __x, float __y))
{
asm ("maxss %1, %0" : "+x" (__x) : "xm" (__y));
return __x;
}
__MATH_INLINE double
__NTH (fmax (double __x, double __y))
{
asm ("maxsd %1, %0" : "+x" (__x) : "xm" (__y));
return __x;
}

/* Determine minimum of two values. */
__MATH_INLINE float
__NTH (fminf (float __x, float __y))
{
asm ("minss %1, %0" : "+x" (__x) : "xm" (__y));
return __x;
}
__MATH_INLINE double
__NTH (fmin (double __x, double __y))
{
asm ("minsd %1, %0" : "+x" (__x) : "xm" (__y));
return __x;
}
# endif

__END_NAMESPACE_C99
# endif

#endif

0 comments on commit 4c1a1f7

Please sign in to comment.