PR tree-optimization/21004
authoruros <uros@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 15 Apr 2005 05:43:56 +0000 (05:43 +0000)
committeruros <uros@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 15 Apr 2005 05:43:56 +0000 (05:43 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@98174 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 2aaf517..e30430b 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 1a54a06..78a577f 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 4e0fc84..c6c2620 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 5d78e17..b2b8e97 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 0a08070..e01908c 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)
 {