aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>2006-10-24 12:25:06 +0000
committerKaveh Ghazi <ghazi@gcc.gnu.org>2006-10-24 12:25:06 +0000
commita5326b13ed7805ba0c18cbd0362c95e8971f6b48 (patch)
tree99506c5eb0cdbf2dfd9841d13a428627c1e65a8f /gcc
parent27d7d0422ce932e1f531fec5de9b81bced2f369b (diff)
downloadgcc-a5326b13ed7805ba0c18cbd0362c95e8971f6b48.zip
gcc-a5326b13ed7805ba0c18cbd0362c95e8971f6b48.tar.gz
gcc-a5326b13ed7805ba0c18cbd0362c95e8971f6b48.tar.bz2
builtin-math-2.c: New test.
* gcc.dg/torture/builtin-math-2.c: New test. From-SVN: r118003
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-math-2.c67
2 files changed, 71 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index e5533b0..5ed77bf 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..deeedf7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/builtin-math-2.c
@@ -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" } } */