Patchwork [SH,committed] Fix sh4a-fprun test case

login
register
mail settings
Submitter Oleg Endo
Date Nov. 12, 2012, 12:04 a.m.
Message ID <1352678688.8110.336.camel@yam-132-YW-E178-FTW>
Download mbox | patch
Permalink /patch/198311/
State New
Headers show

Comments

Oleg Endo - Nov. 12, 2012, 12:04 a.m.
Hello,

The sh4a-fprun.c test case was bogus.  It did not really use the fsca
instruction to do any calculations, because the things it tests could be
evaluated at compile time and folded away.  The test case was supposed
to be failing since rev 188149, as I introduced a bug in the commit for
PR 53512.  I got the sincos standard name pattern wrong -- the sin and
cos outputs are swapped.

The attached patch fixes the test case by using noinline wrappers around
sinf and cosf.
Committed as obvious as rev 193419.
The other fixes for the docs and the sincos pattern in sh.md will
follow.

Cheers,
Oleg

testsuite/ChangeLog:

	* gcc.target/sh/sh4a-fprun.c: Add test_sinf and test_cosf 
	noinline wrappers around sinf and cosf.

Patch

Index: gcc/testsuite/gcc.target/sh/sh4a-fprun.c
===================================================================
--- gcc/testsuite/gcc.target/sh/sh4a-fprun.c	(revision 193405)
+++ gcc/testsuite/gcc.target/sh/sh4a-fprun.c	(working copy)
@@ -11,25 +11,43 @@ 
 float dg2rad_f;
 double dg2rad_d;
 
-void check_f (float res, float expected) {
+float __attribute__ ((noinline))
+test_sinf (float x)
+{
+  return sinf (x);
+}
+
+float __attribute ((noinline))
+test_cosf (float x)
+{
+  return cosf (x);
+}
+
+void
+check_f (float res, float expected)
+{
   if (res >= expected - 0.001f && res <= expected + 0.001f)
     return;
 
   abort ();
 }
 
-void check_d (double res, double expected) {
+void
+check_d (double res, double expected)
+{
   if (res >= expected - 0.001 && res <= expected + 0.001)
     return;
 
   abort ();
 }
 
-int main() {
+int
+main()
+{
   check_f (sqrtf(sqrt_arg), sqrt_res);
   dg2rad_f = dg2rad_d = atan(1) / 45;
-  check_f (sinf(90*dg2rad_f), 1);
-  check_f (cosf(90*dg2rad_f), 0);
+  check_f (test_sinf(90*dg2rad_f), 1);
+  check_f (test_cosf(90*dg2rad_f), 0);
   check_d (sin(-90*dg2rad_d), -1);
   check_d (cos(180*dg2rad_d), -1);
   check_d (sin(-45*dg2rad_d) * cosf(135*dg2rad_f), 0.5);