OSDN Git Service

* gcc.dg/torture/builtin-math-2.c: New test.
authorghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 24 Oct 2006 12:25:06 +0000 (12:25 +0000)
committerghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 24 Oct 2006 12:25:06 +0000 (12:25 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@118003 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/builtin-math-2.c [new file with mode: 0644]

index e5533b0..5ed77bf 100644 (file)
@@ -1,3 +1,7 @@
+2006-10-24  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+       * gcc.dg/torture/builtin-math-2.c: New test.
+
 2006-10-24  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/28796
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-math-2.c b/gcc/testsuite/gcc.dg/torture/builtin-math-2.c
new file mode 100644 (file)
index 0000000..deeedf7
--- /dev/null
@@ -0,0 +1,67 @@
+/* Test things that should block GCC from optimizing compile-time
+   constants passed to a builtin transcendental function.
+
+   Origin: Kaveh R. Ghazi 10/22/2006.  */
+
+/* { dg-do compile } */
+/* { dg-options "-fdump-tree-original" } */
+
+extern void foof (float);
+extern void foo (double);
+extern void fool (long double);
+
+void bar()
+{
+  /* An argument of NaN is not evaluated at compile-time.  */
+  foof (__builtin_exp2f (__builtin_nanf("")));
+  foo (__builtin_exp2 (__builtin_nan("")));
+  fool (__builtin_exp2l (__builtin_nanl("")));
+
+  /* An argument of Inf/-Inf is not evaluated at compile-time.  */
+  foof (__builtin_exp2f (__builtin_inff()));
+  foo (__builtin_exp2 (__builtin_inf()));
+  fool (__builtin_exp2l (__builtin_infl()));
+  foof (__builtin_exp2f (-__builtin_inff()));
+  foo (__builtin_exp2 (-__builtin_inf()));
+  fool (__builtin_exp2l (-__builtin_infl()));
+
+  /* Result overflows MPFR, which in version 2.2.x has 30 exponent bits.  */
+  foof (__builtin_exp2f (0x1p50F));
+  foo (__builtin_exp2 (0x1p50));
+  fool (__builtin_exp2l (0x1p50L));
+  /* Result underflows MPFR, which in version 2.2.x has 30 exponent bits.  */
+  foof (__builtin_exp2f (-0x1p50F));
+  foo (__builtin_exp2 (-0x1p50));
+  fool (__builtin_exp2l (-0x1p50L));
+
+  /* Result overflows GCC's REAL_VALUE_TYPE, which has 26 exponent bits.  */
+  foof (__builtin_exp2f (0x1p28F));
+  foo (__builtin_exp2 (0x1p28));
+  fool (__builtin_exp2l (0x1p28L));
+  /* Result underflows GCC's REAL_VALUE_TYPE, which has 26 exponent bits.  */
+  foof (__builtin_exp2f (-0x1p28F));
+  foo (__builtin_exp2 (-0x1p28));
+  fool (__builtin_exp2l (-0x1p28L));
+
+  /* Result overflows (even an extended) C double's mode.  */
+  foof (__builtin_exp2f (0x1p24F));
+  foo (__builtin_exp2 (0x1p24));
+  fool (__builtin_exp2l (0x1p24L));
+  /* Result underflows (even an extended) C double's mode.  */
+  foof (__builtin_exp2f (-0x1p24F));
+  foo (__builtin_exp2 (-0x1p24));
+  fool (__builtin_exp2l (-0x1p24L));
+
+  /* Ensure that normal arguments/results are folded.  */
+  foof (__builtin_exp2f (1.5F));
+  foo (__builtin_exp2 (1.5));
+  fool (__builtin_exp2l (1.5L));
+  foof (__builtin_exp2f (-1.5F));
+  foo (__builtin_exp2 (-1.5));
+  fool (__builtin_exp2l (-1.5L));
+}
+
+/* { dg-final { scan-tree-dump-times "exp2 " 9 "original" } } */
+/* { dg-final { scan-tree-dump-times "exp2f" 9 "original" } } */
+/* { dg-final { scan-tree-dump-times "exp2l" 9 "original" } } */
+/* { dg-final { cleanup-tree-dump "original" } } */