This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

Re: [PATCH]: PR29335 use MPFR for builtin sincos


On Thu, 2 Nov 2006, Kaveh R. GHAZI wrote:

> On Wed, 1 Nov 2006, Roger Sayle wrote:
>
> > On Wed, 1 Nov 2006, Kaveh R. GHAZI wrote:
> > > Is there any other testcase you would like me to try or can I install
> > > the patch?
> >
> > The patch is OK for mainline.  It would also be nice if you could
> > turn the sincos(zero,&s,&c) test case into something suitable for
> > GCC's dejagnu testsuite and check that in.  And just for good luck
> > perhaps something like:
> >
> > void foo(double x)
> > {
> >   double s, c;
> >
> >   if (x == 0.0)
> >   {
> >     sincos(x,&s,&c);
> >     /* Check s and c.  */
> >   }
> > }
> >
> > However these new test cases can be committed as a follow-up patch.
> > We've no reason to believe the tree-ssa passes can't handle the new
> > non-gimple (*sp=X, *cp=Y) idiom that sincos folding can now produce,
> > but it does no harm as to make sure things don't break in future.
> >
> > [I'll admit that I'm a bit curious as to which pass actually performs
> > the simplification you tested for, but it'll be easy enough for me
> > to investigate this for myself once your patch goes in. :-)]
>
> Sure I'll add some tests in a bit.  Two notes:
>
> 1.  In the case above, the simplification occurs only with both -O1 (or
>     higher) and -ffast-math.  I'm not sure why -ffast-math is necessary.

Hi Roger,

Here's a testcase that checks sincos(var,...).  Thanks to Richard for
diagnosing the problem with zeros.  I used +/- one instead.

A test using the if (x == 1.0) sincos(x, ...) form like above fails in
certain circumstances to propagate the value for x into the sincos when
checking long double values.  I'll post details in a followup message.
However it appears unrelated to my builtins stuff.  So I'd like to simply
put this update in and treat that separately.


Tested via "make check" on sparc-sun-solaris2.10.  Test passes.

Okay for mainline?

		Thanks,
		--Kaveh


2006-11-07  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* gcc.dg/torture/builtin-math-3.c: Add more sincos tests.

diff -rup orig/egcc-SVN20061105/gcc/testsuite/gcc.dg/torture/builtin-math-3.c egcc-SVN20061105/gcc/testsuite/gcc.dg/torture/builtin-math-3.c
--- orig/egcc-SVN20061105/gcc/testsuite/gcc.dg/torture/builtin-math-3.c	2006-11-01 22:21:38.000000000 -0500
+++ egcc-SVN20061105/gcc/testsuite/gcc.dg/torture/builtin-math-3.c	2006-11-07 21:00:24.255141342 -0500
@@ -90,9 +90,9 @@ extern void link_error(int);
 int main (void)
 {
 #ifdef __OPTIMIZE__
-  float sf, cf;
-  double s, c;
-  long double sl, cl;
+  float sf, cf, oneF = 1.0F;
+  double s, c, one = 1.0;
+  long double sl, cl, oneL = 1.0L;
 #endif

   TESTIT_R (asin, -1.0, -3.15/2.0, -3.14/2.0); /* asin(-1) == -pi/2 */
@@ -139,12 +139,14 @@ int main (void)
   TESTIT_R (tan, 1.0, 1.55, 1.56); /* tan(1) == 1.557... */

 #ifdef __OPTIMIZE__
-  /* These tests rely on propagating the variables s and c, which
+  /* These tests rely on propagating the variables s, c and one, which
      happens only when optimization is turned on.  */
   TESTIT_2P_R (sincos, -1.0, s, c, -0.85, -0.84, 0.54, 0.55); /* (s==-0.841..., c==0.5403...) */
   TESTIT_2P (sincos, 0.0, s, c, 0.0, 1.0); /* (s==0, c==1) */
   TESTIT_2P (sincos, -0.0, s, c, -0.0, 1.0); /* (s==-0, c==1) */
   TESTIT_2P_R (sincos, 1.0, s, c, 0.84, 0.85, 0.54, 0.55); /* (s==0.841..., c==0.5403...) */
+  TESTIT_2P_R (sincos, one, s, c, 0.84, 0.85, 0.54, 0.55); /* (s==0.841..., c==0.5403...) */
+  TESTIT_2P_R (sincos, -one, s, c, -0.85, -0.84, 0.54, 0.55); /* (s==-0.841..., c==0.5403...) */
 #endif

   TESTIT_R (sinh, -1.0, -1.18, -1.17); /* sinh(-1) == -1.175... */


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