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


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] Add volatiles for x86-64 bits/mathinline.h


As mentioned previously today, lrintf fails for me with gcc 4.7. The
resolution in bugzilla suggests to add volatiles, here's a patch to do
so. I will in a separate patch add checks for specific gcc versions so
that we use the gcc builtins.

My patch introduces new make check ulps for float, I'll handle those
separately:

testing float (inline functions)
Failure: Test: acos_towardzero (0) == pi/2
Result:
 is:          1.57079625129699707031e+00   0x1.921fb400000000000000p+0
 should be:   1.57079637050628662109e+00   0x1.921fb600000000000000p+0
 difference:  1.19209289550781250000e-07   0x1.00000000000000000000p-23
 ulp       :  1.0000
 max.ulp   :  0.0000
Failure: Test: acos_towardzero (-0) == pi/2
Result:
 is:          1.57079625129699707031e+00   0x1.921fb400000000000000p+0
 should be:   1.57079637050628662109e+00   0x1.921fb600000000000000p+0
 difference:  1.19209289550781250000e-07   0x1.00000000000000000000p-23
 ulp       :  1.0000
 max.ulp   :  0.0000
Failure: Test: acos_towardzero (-1) == pi
Result:
 is:          3.14159250259399414062e+00   0x1.921fb400000000000000p+1
 should be:   3.14159274101257324219e+00   0x1.921fb600000000000000p+1
 difference:  2.38418579101562500000e-07   0x1.00000000000000000000p-22
 ulp       :  1.0000
 max.ulp   :  0.0000
Failure: Test: acos_downward (0) == pi/2
Result:
 is:          1.57079625129699707031e+00   0x1.921fb400000000000000p+0
 should be:   1.57079637050628662109e+00   0x1.921fb600000000000000p+0
 difference:  1.19209289550781250000e-07   0x1.00000000000000000000p-23
 ulp       :  1.0000
 max.ulp   :  0.0000
Failure: Test: acos_downward (-0) == pi/2
Result:
 is:          1.57079625129699707031e+00   0x1.921fb400000000000000p+0
 should be:   1.57079637050628662109e+00   0x1.921fb600000000000000p+0
 difference:  1.19209289550781250000e-07   0x1.00000000000000000000p-23
 ulp       :  1.0000
 max.ulp   :  0.0000
Failure: Test: acos_downward (-1) == pi
Result:
 is:          3.14159250259399414062e+00   0x1.921fb400000000000000p+1
 should be:   3.14159274101257324219e+00   0x1.921fb600000000000000p+1
 difference:  2.38418579101562500000e-07   0x1.00000000000000000000p-22
 ulp       :  1.0000
 max.ulp   :  0.0000

Test suite completed:
  3773 test cases plus 3329 tests for exception flags executed.
  6 errors occurred.

Ok to commit?

Andreas

2012-05-02  Andreas Jaeger  <aj@suse.de>

        [BZ #14053]
	* sysdeps/x86_64/fpu/bits/mathinline.h (lrintf): Add __volatile to asm.
	(lrint): Likewise.
	(llrintf): Likewise.
	(llrint): Likewise.
	(rint): Likewise.
	(rintf): Likewise.
	(nearbyint): Likewise.
	(nearbyintf): Likewise.

diff --git a/sysdeps/x86_64/fpu/bits/mathinline.h b/sysdeps/x86_64/fpu/bits/mathinline.h
index c072f16..8e1ec7b 100644
--- a/sysdeps/x86_64/fpu/bits/mathinline.h
+++ b/sysdeps/x86_64/fpu/bits/mathinline.h
@@ -79,7 +79,7 @@ __MATH_INLINE long int
 __NTH (lrintf (float __x))
 {
   long int __res;
-  __asm ("cvtss2si %1, %0" : "=r" (__res) : "xm" (__x));
+  __asm __volatile__ ("cvtss2si %1, %0" : "=r" (__res) : "xm" (__x));
   return __res;
 }
 #  endif
@@ -88,7 +88,7 @@ __MATH_INLINE long int
 __NTH (lrint (double __x))
 {
   long int __res;
-  __asm ("cvtsd2si %1, %0" : "=r" (__res) : "xm" (__x));
+  __asm __volatile__ ("cvtsd2si %1, %0" : "=r" (__res) : "xm" (__x));
   return __res;
 }
 #  endif
@@ -97,14 +97,14 @@ __MATH_INLINE long long int
 __NTH (llrintf (float __x))
 {
   long long int __res;
-  __asm ("cvtss2si %1, %0" : "=r" (__res) : "xm" (__x));
+  __asm __volatile__ ("cvtss2si %1, %0" : "=r" (__res) : "xm" (__x));
   return __res;
 }
 __MATH_INLINE long long int
 __NTH (llrint (double __x))
 {
   long long int __res;
-  __asm ("cvtsd2si %1, %0" : "=r" (__res) : "xm" (__x));
+  __asm __volatile__ ("cvtsd2si %1, %0" : "=r" (__res) : "xm" (__x));
   return __res;
 }
 #  endif
@@ -176,14 +176,14 @@ __MATH_INLINE double
 __NTH (rint (double __x))
 {
   double __res;
-  __asm ("roundsd $4, %1, %0" : "=x" (__res) : "xm" (__x));
+  __asm __volatile__ ("roundsd $4, %1, %0" : "=x" (__res) : "xm" (__x));
   return __res;
 }
 __MATH_INLINE float
 __NTH (rintf (float __x))
 {
   float __res;
-  __asm ("roundss $4, %1, %0" : "=x" (__res) : "xm" (__x));
+  __asm __volatile__ ("roundss $4, %1, %0" : "=x" (__res) : "xm" (__x));
   return __res;
 }
 
@@ -193,14 +193,14 @@ __MATH_INLINE double
 __NTH (nearbyint (double __x))
 {
   double __res;
-  __asm ("roundsd $0xc, %1, %0" : "=x" (__res) : "xm" (__x));
+  __asm __volatile__ ("roundsd $0xc, %1, %0" : "=x" (__res) : "xm" (__x));
   return __res;
 }
 __MATH_INLINE float
 __NTH (nearbyintf (float __x))
 {
   float __res;
-  __asm ("roundss $0xc, %1, %0" : "=x" (__res) : "xm" (__x));
+  __asm __volatile__ ("roundss $0xc, %1, %0" : "=x" (__res) : "xm" (__x));
   return __res;
 }
 #   endif

-- 
 Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
  SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 NÃrnberg, Germany
   GF: Jeff Hawn,Jennifer Guild,Felix ImendÃrffer,HRB16746 (AG NÃrnberg)
    GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126


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