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: PR math/13202: -O2 -std=c99 doesn't work


On Fri, Sep 16, 2011 at 11:38:25AM -0700, H.J. Lu wrote:
> On Thu, Sep 15, 2011 at 10:31:23PM -0700, H.J. Lu wrote:
> > On Thu, Sep 15, 2011 at 10:14:59PM -0700, H.J. Lu wrote:
> > > Hi,
> > > 
> > > GCC 4.7 failed to compile math/test-tgmath.o and math/test-tgmath2.o
> > > on Linux/x86-64:
> > > 
> > > test-tgmath.c: In function âmainâ:
> > > test-tgmath.c:698:4: error: inlining failed in call to always_inline
> > > âlrintâ: function not inlinable
> > > test-tgmath.c:267:7: error: called from here
> > > test-tgmath.c:714:4: error: inlining failed in call to always_inline
> > > âllrintâ: function not inlinable
> > > test-tgmath.c:268:7: error: called from here
> > > In file included from test-tgmath.c:201:0:
> > > test-tgmath.c:698:1: error: inlining failed in call to always_inline
> > > âlrintfâ: function not inlinable
> > > test-tgmath.c:267:7: error: called from here
> > > test-tgmath.c:714:1: error: inlining failed in call to always_inline
> > > âllrintfâ: function not inlinable
> > > test-tgmath.c:268:7: error: called from here
> > > 
> > > It defines __NO_MATH_INLINES.  But <bits/mathinline.h> is still
> > > included.  This patch fixes it.
> > > 
> > > 
> > > H.J.
> > > ----
> > > 2011-09-15  H.J. Lu  <hongjiu.lu@intel.com>
> > >  
> > >  	* math/math.h: Don't include <bits/mathinline.h> if
> > > 	__NO_MATH_INLINES is defined.
> > > 
> > 
> > When __LIBC_INTERNAL_MATH_INLINES is defined, <bits/mathinline.h>
> > should be included since libm is compiled with
> > 
> > -D__NO_MATH_INLINES -D__LIBC_INTERNAL_MATH_INLINES
> > 
> > 
> 
> We also need to undef __LIBC_INTERNAL_MATH_INLINES in math/test-tgmath.c
> and math/test-tgmath2.c since -D__LIBC_INTERNAL_MATH_INLINES is used
> to compile them.
> 
> 

It turns out the problem is asm in bits/mathinline.h.  This
patch fixes it.

H.J.
---
2011-09-21  H.J. Lu  <hongjiu.lu@intel.com>

	PR math/13202
	* Makefile (tests): Add test-c99.
	(CFLAGS-test-c99.c): Set to -std=c99.

	* math/test-c99.c: New.

	* sysdeps/x86_64/fpu/bits/mathinline.h (lrintf): Replace asm
	with __asm.
	(lrint): Likewise.
	(llrintf): Likewise.
	(llrint): Likewise.
	(fmaxf): Likewise.
	(fmax): Likewise.
	(fminf): Likewise.
	(fmin): Likewise.

diff --git a/math/Makefile b/math/Makefile
index 45954e2..3b8031c 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -91,7 +91,7 @@ distribute += $(filter-out $(generated),$(long-m-yes:=.c) $(long-c-yes:=.c))
 tests = test-matherr test-fenv atest-exp atest-sincos atest-exp2 basic-test \
 	test-misc test-fpucw tst-definitions test-tgmath test-tgmath-ret \
 	bug-nextafter bug-nexttoward bug-tgmath1 test-tgmath-int \
-	test-tgmath2 test-powl
+	test-tgmath2 test-powl test-c99
 # We do the `long double' tests only if this data type is available and
 # distinct from `double'.
 test-longdouble-yes = test-ldouble test-ildoubl
@@ -133,6 +133,7 @@ CFLAGS-test-tgmath.c = -fno-builtin
 CFLAGS-test-tgmath2.c = -fno-builtin
 CFLAGS-test-tgmath-ret.c = -fno-builtin
 CFLAGS-test-powl.c = -fno-builtin
+CFLAGS-test-c99.c = -std=c99
 CPPFLAGS-test-ifloat.c = -U__LIBC_INTERNAL_MATH_INLINES -D__FAST_MATH__ \
 			 -DTEST_FAST_MATH -fno-builtin
 CPPFLAGS-test-idouble.c = -U__LIBC_INTERNAL_MATH_INLINES -D__FAST_MATH__ \
diff --git a/math/test-c99.c b/math/test-c99.c
new file mode 100644
index 0000000..b09edae
--- /dev/null
+++ b/math/test-c99.c
@@ -0,0 +1 @@
+#include "test-misc.c"
diff --git a/sysdeps/x86_64/fpu/bits/mathinline.h b/sysdeps/x86_64/fpu/bits/mathinline.h
index b63ab12..780f878 100644
--- a/sysdeps/x86_64/fpu/bits/mathinline.h
+++ b/sysdeps/x86_64/fpu/bits/mathinline.h
@@ -73,7 +73,7 @@ __MATH_INLINE long int
 __NTH (lrintf (float __x))
 {
   long int __res;
-  asm ("cvtss2si %1, %0" : "=r" (__res) : "xm" (__x));
+  __asm ("cvtss2si %1, %0" : "=r" (__res) : "xm" (__x));
   return __res;
 }
 #  endif
@@ -82,7 +82,7 @@ __MATH_INLINE long int
 __NTH (lrint (double __x))
 {
   long int __res;
-  asm ("cvtsd2si %1, %0" : "=r" (__res) : "xm" (__x));
+  __asm ("cvtsd2si %1, %0" : "=r" (__res) : "xm" (__x));
   return __res;
 }
 #  endif
@@ -91,14 +91,14 @@ __MATH_INLINE long long int
 __NTH (llrintf (float __x))
 {
   long long int __res;
-  asm ("cvtss2si %1, %0" : "=r" (__res) : "xm" (__x));
+  __asm ("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 ("cvtsd2si %1, %0" : "=r" (__res) : "xm" (__x));
   return __res;
 }
 #  endif
@@ -108,13 +108,13 @@ __NTH (llrint (double __x))
 __MATH_INLINE float
 __NTH (fmaxf (float __x, float __y))
 {
-  asm ("maxss %1, %0" : "+x" (__x) : "xm" (__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));
+  __asm ("maxsd %1, %0" : "+x" (__x) : "xm" (__y));
   return __x;
 }
 
@@ -122,13 +122,13 @@ __NTH (fmax (double __x, double __y))
 __MATH_INLINE float
 __NTH (fminf (float __x, float __y))
 {
-  asm ("minss %1, %0" : "+x" (__x) : "xm" (__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));
+  __asm ("minsd %1, %0" : "+x" (__x) : "xm" (__y));
   return __x;
 }
 #  endif


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