summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/torture/builtin-math-6.c
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-16 13:09:38 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-16 13:09:38 +0000
commit22642efda7e6534076c91bd0d9ee4a244ea44c4a (patch)
treef379042d103278bfa7fe040ddace8f7ca34aa4cd /gcc/testsuite/gcc.dg/torture/builtin-math-6.c
parent5be59a5529f8877a7933cf0131353a0d54383b96 (diff)
downloadgcc-22642efda7e6534076c91bd0d9ee4a244ea44c4a.tar.gz
2009-06-16 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk r148523 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@148527 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/torture/builtin-math-6.c')
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-math-6.c78
1 files changed, 47 insertions, 31 deletions
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-math-6.c b/gcc/testsuite/gcc.dg/torture/builtin-math-6.c
index 636381f5f2e..7fd1f729e2c 100644
--- a/gcc/testsuite/gcc.dg/torture/builtin-math-6.c
+++ b/gcc/testsuite/gcc.dg/torture/builtin-math-6.c
@@ -11,57 +11,73 @@
/* All references to link_error should go away at compile-time. */
extern void link_error(int);
-/* Return TRUE if the sign of X != sign of Y. This is important when
- comparing signed zeros. */
+/* Return TRUE if the signs of floating point values X and Y are not
+ equal. This is important when comparing signed zeros. */
#define CKSGN_F(X,Y) \
- (__builtin_copysignf(1.0F,(X)) != __builtin_copysignf(1.0F,(Y)))
+ (__builtin_copysignf(1,(X)) != __builtin_copysignf(1,(Y)))
#define CKSGN(X,Y) \
- (__builtin_copysign(1.0,(X)) != __builtin_copysign(1.0,(Y)))
+ (__builtin_copysign(1,(X)) != __builtin_copysign(1,(Y)))
#define CKSGN_L(X,Y) \
- (__builtin_copysignl(1.0L,(X)) != __builtin_copysignl(1.0L,(Y)))
+ (__builtin_copysignl(1,(X)) != __builtin_copysignl(1,(Y)))
+
+/* Return TRUE if signs of the real parts, and the signs of the
+ imaginary parts, of X and Y are not equal. */
+#define COMPLEX_CKSGN_F(X,Y) \
+ (CKSGN_F(__real__ (X), __real__ (Y)) || CKSGN_F (__imag__ (X), __imag__ (Y)))
+#define COMPLEX_CKSGN(X,Y) \
+ (CKSGN(__real__ (X), __real__ (Y)) || CKSGN (__imag__ (X), __imag__ (Y)))
+#define COMPLEX_CKSGN_L(X,Y) \
+ (CKSGN_L(__real__ (X), __real__ (Y)) || CKSGN_L (__imag__ (X), __imag__ (Y)))
/* For complex numbers, test that FUNC(ARG) == (RES). */
#define TESTIT_COMPLEX(FUNC, ARG, RES) do { \
if (__builtin_##FUNC##f(ARG) != (RES) \
- || CKSGN_F(__real__ __builtin_##FUNC##f(ARG), __real__ (RES)) \
- || CKSGN_F(__imag__ __builtin_##FUNC##f(ARG), __imag__ (RES))) \
+ || COMPLEX_CKSGN_F(__builtin_##FUNC##f(ARG), (RES))) \
link_error(__LINE__); \
if (__builtin_##FUNC(ARG) != (RES) \
- || CKSGN(__real__ __builtin_##FUNC(ARG), __real__ (RES)) \
- || CKSGN(__imag__ __builtin_##FUNC(ARG), __imag__ (RES))) \
+ || COMPLEX_CKSGN(__builtin_##FUNC(ARG), (RES))) \
link_error(__LINE__); \
if (__builtin_##FUNC##l(ARG) != (RES) \
- || CKSGN_L(__real__ __builtin_##FUNC##l(ARG), __real__ (RES)) \
- || CKSGN_L(__imag__ __builtin_##FUNC##l(ARG), __imag__ (RES))) \
+ || COMPLEX_CKSGN_L(__builtin_##FUNC##l(ARG), (RES))) \
link_error(__LINE__); \
} while (0)
+/* Return TRUE if X differs from EXPECTED by more than 1%. If
+ EXPECTED is zero, then any difference may return TRUE. We don't
+ worry about signed zeros. */
+#define DIFF1PCT_F(X,EXPECTED) \
+ (__builtin_fabsf((X)-(EXPECTED)) * 100 > __builtin_fabsf(EXPECTED))
+#define DIFF1PCT(X,EXPECTED) \
+ (__builtin_fabs((X)-(EXPECTED)) * 100 > __builtin_fabs(EXPECTED))
+#define DIFF1PCT_L(X,EXPECTED) \
+ (__builtin_fabsl((X)-(EXPECTED)) * 100 > __builtin_fabsl(EXPECTED))
+
+/* Return TRUE if complex value X differs from EXPECTED by more than
+ 1% in either the real or imaginary parts. */
+#define COMPLEX_DIFF1PCT_F(X,EXPECTED) \
+ (DIFF1PCT_F(__real__ (X), __real__ (EXPECTED)) \
+ || DIFF1PCT_F(__imag__ (X), __imag__ (EXPECTED)))
+#define COMPLEX_DIFF1PCT(X,EXPECTED) \
+ (DIFF1PCT(__real__ (X), __real__ (EXPECTED)) \
+ || DIFF1PCT(__imag__ (X), __imag__ (EXPECTED)))
+#define COMPLEX_DIFF1PCT_L(X,EXPECTED) \
+ (DIFF1PCT_L(__real__ (X), __real__ (EXPECTED)) \
+ || DIFF1PCT_L(__imag__ (X), __imag__ (EXPECTED)))
+
/* Range test, for complex numbers check that FUNC(ARG) is within 1%
of RES. This is NOT a test for accuracy to the last-bit, we're
merely checking that we get relatively sane results. I.e. the GCC
builtin is hooked up to the correct MPC function call. We first
check the magnitude and then the sign. */
#define TESTIT_COMPLEX_R(FUNC, ARG, RES) do { \
- if (__builtin_fabsf(__real__ __builtin_##FUNC##f(ARG)) < __builtin_fabsf(__real__ (RES)) * 0.99F \
- || __builtin_fabsf(__real__ __builtin_##FUNC##f(ARG)) > __builtin_fabsf(__real__ (RES)) * 1.01F \
- || __builtin_fabsf(__imag__ __builtin_##FUNC##f(ARG)) < __builtin_fabsf(__imag__ (RES)) * 0.99F \
- || __builtin_fabsf(__imag__ __builtin_##FUNC##f(ARG)) > __builtin_fabsf(__imag__ (RES)) * 1.01F \
- || CKSGN_F(__real__ __builtin_##FUNC##f(ARG), __real__ (RES)) \
- || CKSGN_F(__imag__ __builtin_##FUNC##f(ARG), __imag__ (RES))) \
+ if (COMPLEX_DIFF1PCT_F (__builtin_##FUNC##f(ARG), (RES)) \
+ || COMPLEX_CKSGN_F(__builtin_##FUNC##f(ARG), (RES))) \
link_error(__LINE__); \
- if (__builtin_fabs(__real__ __builtin_##FUNC(ARG)) < __builtin_fabs(__real__ (RES)) * 0.99F \
- || __builtin_fabs(__real__ __builtin_##FUNC(ARG)) > __builtin_fabs(__real__ (RES)) * 1.01F \
- || __builtin_fabs(__imag__ __builtin_##FUNC(ARG)) < __builtin_fabs(__imag__ (RES)) * 0.99F \
- || __builtin_fabs(__imag__ __builtin_##FUNC(ARG)) > __builtin_fabs(__imag__ (RES)) * 1.01F \
- || CKSGN(__real__ __builtin_##FUNC(ARG), __real__ (RES)) \
- || CKSGN(__imag__ __builtin_##FUNC(ARG), __imag__ (RES))) \
+ if (COMPLEX_DIFF1PCT (__builtin_##FUNC(ARG), (RES)) \
+ || COMPLEX_CKSGN(__builtin_##FUNC(ARG), (RES))) \
link_error(__LINE__); \
- if (__builtin_fabsl(__real__ __builtin_##FUNC##l(ARG)) < __builtin_fabsl(__real__ (RES)) * 0.99F \
- || __builtin_fabsl(__real__ __builtin_##FUNC##l(ARG)) > __builtin_fabsl(__real__ (RES)) * 1.01F \
- || __builtin_fabsl(__imag__ __builtin_##FUNC##l(ARG)) < __builtin_fabsl(__imag__ (RES)) * 0.99F \
- || __builtin_fabsl(__imag__ __builtin_##FUNC##l(ARG)) > __builtin_fabsl(__imag__ (RES)) * 1.01F \
- || CKSGN_L(__real__ __builtin_##FUNC##l(ARG), __real__ (RES)) \
- || CKSGN_L(__imag__ __builtin_##FUNC##l(ARG), __imag__ (RES))) \
+ if (COMPLEX_DIFF1PCT (__builtin_##FUNC(ARG), (RES)) \
+ || COMPLEX_CKSGN(__builtin_##FUNC(ARG), (RES))) \
link_error(__LINE__); \
} while (0)
@@ -129,8 +145,8 @@ int main (void)
TESTIT_COMPLEX (clog, 1.0F, 0.0F);
TESTIT_COMPLEX_R (clog, -1.0F, 3.141593FI);
- TESTIT_COMPLEX (clog, __builtin_conjf(1.0F), 0.0F);
- TESTIT_COMPLEX_R (clog, __builtin_conjf(-1.0F), 3.141593FI);
+ TESTIT_COMPLEX (clog, __builtin_conjf(1.0F), __builtin_conjf(0.0F)); /* Fails with mpc-0.6. */
+ TESTIT_COMPLEX_R (clog, __builtin_conjf(-1.0F), __builtin_conjf(3.141593FI)); /* Fails with mpc-0.6. */
TESTIT_COMPLEX_R (clog, 3.45678F + 2.34567FI, 1.429713F + 0.596199FI);
TESTIT_COMPLEX_R (clog, 3.45678F - 2.34567FI, 1.429713F - 0.596199FI);