aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/builtins-55.c
diff options
context:
space:
mode:
authorRoger Sayle <roger@eyesopen.com>2006-07-27 14:02:27 +0000
committerRoger Sayle <sayle@gcc.gnu.org>2006-07-27 14:02:27 +0000
commit482c6ce8854e83bb5d89f367cf2a391e454c4735 (patch)
tree8f719633623f288ed24eae0d3489f6505aeb6a66 /gcc/testsuite/gcc.dg/builtins-55.c
parent721cedf2517390c2fd7b7f2c3272177ff1a50f10 (diff)
downloadgcc-482c6ce8854e83bb5d89f367cf2a391e454c4735.zip
gcc-482c6ce8854e83bb5d89f367cf2a391e454c4735.tar.gz
gcc-482c6ce8854e83bb5d89f367cf2a391e454c4735.tar.bz2
builtins.c (fold_fixed_mathfn): When long and long long are the same size...
* builtins.c (fold_fixed_mathfn): When long and long long are the same size, canonicalize llceil*, llfloor*, llround* and llrint* functions to their lceil*, lfloor*, lround* and lrint* forms. * gcc.dg/builtins-55.c: New test case. From-SVN: r115775
Diffstat (limited to 'gcc/testsuite/gcc.dg/builtins-55.c')
-rw-r--r--gcc/testsuite/gcc.dg/builtins-55.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/builtins-55.c b/gcc/testsuite/gcc.dg/builtins-55.c
new file mode 100644
index 0000000..d804f29
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/builtins-55.c
@@ -0,0 +1,75 @@
+/* { dg-do link } */
+/* { dg-options "-O2 -ffast-math" } */
+/* { dg-options "-ffast-math -mmacosx-version-min=10.3" { target powerpc-*-darwin* } } */
+/* { dg-options "-O2 -ffast-math -std=c99" { target *-*-solaris2* } } */
+
+#include "builtins-config.h"
+
+void link_error (void);
+
+extern long lround(double);
+extern long lrint(double);
+
+extern long long llround(double);
+extern long long llrint(double);
+
+extern long lroundf(float);
+extern long lrintf(float);
+
+extern long long llroundf(float);
+extern long long llrintf(float);
+
+extern long lroundl(long double);
+extern long lrintl(long double);
+
+extern long long llroundl(long double);
+extern long long llrintl(long double);
+
+
+void test(double x)
+{
+#ifdef HAVE_C99_RUNTIME
+ if (sizeof(long) != sizeof(long long))
+ return;
+
+ if (lround(x) != llround(x))
+ link_error();
+ if (lrint(x) != llrint(x))
+ link_error();
+#endif
+}
+
+void testf(float x)
+{
+#ifdef HAVE_C99_RUNTIME
+ if (sizeof(long) != sizeof(long long))
+ return;
+
+ if (lroundf(x) != llroundf(x))
+ link_error();
+ if (lrintf(x) != llrintf(x))
+ link_error();
+#endif
+}
+
+void testl(long double x)
+{
+#ifdef HAVE_C99_RUNTIME
+ if (sizeof(long) != sizeof(long long))
+ return;
+
+ if (lroundl(x) != llroundl(x))
+ link_error();
+ if (lrintl(x) != llrintl(x))
+ link_error();
+#endif
+}
+
+int main()
+{
+ test(0.0);
+ testf(0.0);
+ testl(0.0);
+ return 0;
+}
+