re PR tree-optimization/21004 (gcc.dg/builtins-53.c fails)
authorUros Bizjak <uros@kss-loka.si>
Fri, 15 Apr 2005 05:43:56 +0000 (07:43 +0200)
committerUros Bizjak <uros@gcc.gnu.org>
Fri, 15 Apr 2005 05:43:56 +0000 (07:43 +0200)
PR tree-optimization/21004
* convert.c (convert_to_integer): Convert ceilf, ceill, floorf
and floorl in c99 mode only.
* builtins.c (expand_builtin_int_roundingfn): Assert that
fallback_fndecl is not NULL_TREE.

testsuite:

PR tree-optimization/21004
* gcc.dg/builtins-53.c: Include builtins-config.h.
Check floorf, ceilf, floorl and ceill transformations
only when HAVE_C99_RUNTIME is defined.

From-SVN: r98174

gcc/ChangeLog
gcc/builtins.c
gcc/convert.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/builtins-53.c

index 2aaf517441643b3028ade0f60504f3b87afbd02c..e30430bd9fd3ce525bbffbcf6310d921a7127c64 100644 (file)
@@ -1,3 +1,11 @@
+2005-04-15  Uros Bizjak  <uros@kss-loka.si>
+
+       PR tree-optimization/21004
+       * convert.c (convert_to_integer): Convert ceilf, ceill, floorf
+       and floorl in c99 mode only.
+       * builtins.c (expand_builtin_int_roundingfn): Assert that
+       fallback_fndecl is not NULL_TREE.
+
 2005-04-15  Kazu Hirata  <kazu@cs.umass.edu>
 
        * cfgrtl.c (purge_all_dead_edge): Remove an unused argument.
index 1a54a06854b275352796ea9d209ed48aac069bf3..78a577f53fe83711649bb33e836c092cabc1e78d 100644 (file)
@@ -2220,6 +2220,9 @@ expand_builtin_int_roundingfn (tree exp, rtx target, rtx subtarget)
 
   /* Fall back to floating point rounding optab.  */
   fallback_fndecl = mathfn_built_in (TREE_TYPE (arg), fallback_fn);
+  /* We shouldn't get here on targets without TARGET_C99_FUNCTIONS.
+     ??? Perhaps convert (int)floorf(x) into (int)floor((double)x).  */
+  gcc_assert (fallback_fndecl != NULL_TREE);
   exp = build_function_call_expr (fallback_fndecl, arglist);
 
   tmp = expand_builtin_mathfn (exp, NULL_RTX, NULL_RTX);
index 4e0fc84050b249a7e7e333448e1715066ad69d75..c6c2620ab11a6cf28f7effb202ca592a63148831 100644 (file)
@@ -349,14 +349,26 @@ convert_to_integer (tree type, tree expr)
       
       switch (fcode)
         {
-       case BUILT_IN_CEIL: case BUILT_IN_CEILF: case BUILT_IN_CEILL:
+       case BUILT_IN_CEILF:
+       case BUILT_IN_CEILL:
+         /* Only convert in ISO C99 mode.  */
+         if (!TARGET_C99_FUNCTIONS)
+           break;
+         /* ... Fall through ...  */
+       case BUILT_IN_CEIL:
          if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (long_long_integer_type_node))
            fn = mathfn_built_in (s_intype, BUILT_IN_LLCEIL);
          else
            fn = mathfn_built_in (s_intype, BUILT_IN_LCEIL);
          break;
 
-       case BUILT_IN_FLOOR: case BUILT_IN_FLOORF: case BUILT_IN_FLOORL:
+       case BUILT_IN_FLOORF:
+       case BUILT_IN_FLOORL:
+         /* Only convert in ISO C99 mode.  */
+         if (!TARGET_C99_FUNCTIONS)
+           break;
+         /* ... Fall through ...  */
+       case BUILT_IN_FLOOR:
          if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (long_long_integer_type_node))
            fn = mathfn_built_in (s_intype, BUILT_IN_LLFLOOR);
          else
index 5d78e17783dd7496880882b933e80539e8ee6f48..b2b8e9798e1da9a3673927330980896d6310e0b8 100644 (file)
@@ -1,3 +1,10 @@
+2005-04-15  Uros Bizjak  <uros@kss-loka.si>
+
+       PR tree-optimization/21004
+       * gcc.dg/builtins-53.c: Include builtins-config.h.
+       Check floorf, ceilf, floorl and ceill transformations
+       only when HAVE_C99_RUNTIME is defined.
+       
 2005-04-15  Alexandre Oliva  <aoliva@redhat.com>
 
        PR middle-end/20739
index 0a080704fb3860212131510a47642ebb4599083b..e01908c26a7d87648acfec740f5bc27a422824bb 100644 (file)
@@ -11,6 +11,8 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -ffast-math" } */
 
+#include "builtins-config.h"
+
 extern double floor(double);
 extern double ceil(double);
 extern double trunc(double);
@@ -54,6 +56,7 @@ long long int test6(double x)
   return trunc(x);
 }
 
+#ifdef HAVE_C99_RUNTIME
 long int test1f(float x)
 {
   return floorf(x);
@@ -73,6 +76,7 @@ long long int test4f(float x)
 {
   return ceilf(x);
 }
+#endif
 
 long int test5f(float x)
 {
@@ -84,6 +88,7 @@ long long int test6f(float x)
   return truncf(x);
 }
 
+#ifdef HAVE_C99_RUNTIME
 long int test1l(long double x)
 {
   return floorl(x);
@@ -103,6 +108,7 @@ long long int test4l(long double x)
 {
   return ceill(x);
 }
+#endif
 
 long int test5l(long double x)
 {