OSDN Git Service

* builtins.def (BUILT_IN_LCEIL, BUILT_IN_LCEILF, BUILT_IN_LCEILL)
authoruros <uros@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 11 Apr 2005 06:16:39 +0000 (06:16 +0000)
committeruros <uros@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 11 Apr 2005 06:16:39 +0000 (06:16 +0000)
(BUILT_IN_LLCEIL, BUILT_IN_LLCEILF, BUILT_IN_LLCEILL): New.
* optabs.h (enum optab_index): Add new OTI_lceil.
(lceil_optab): Define corresponding macro.
* optabs.c (init_optabs): Initialize lceil_optab.
* genopinit.c (optabs): Implement lceil_optab using lceilsi2
and lceildi2 patterns.

* builtins.c (expand_builtin_int_roundingfn): Handle
BUILT_IN_LCEIL{,F,L} and BUILT_IN_LLCEIL{,F,L}.
(fold_builtin_int_roundingfn): Handle BUILT_IN_LCEIL{,F,L} and
BUILT_IN_LLCEIL{,F,L}.
(fold_builtin_1): Fold BUILT_IN_LCEIL{,F,L} and
BUILT_IN_LLCEIL{,F,L} using fold_builtin_int_roundingfn.
(mathfn_built_in): Handle BUILT_IN LCEIL and BUILT_IN_LLCEIL.
(expand_builtin): Expand BUILT_IN_LCEIL{,F,L} and
BUILT_IN_LLCEIL{,F,L} using expand_builtin_int_roundingfn.

* convert.c (convert_to_integer): Convert (long int)ceil{,f,l},
into lceil built-in function and (long long int)ceil{,f,l} into
llceil built-in function.
* fold-const.c (tree_expr_nonnegative_p): Add BUILT_IN_LCEIL and
BUILT_IN_LLCEIL.
testsuite:

* gcc.dg/builtins-53.c: Also check (int)ceil* and
(long long int)ceil*.

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

gcc/ChangeLog
gcc/builtins.c
gcc/builtins.def
gcc/convert.c
gcc/fold-const.c
gcc/genopinit.c
gcc/optabs.c
gcc/optabs.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/builtins-53.c

index 8a0a77b..96df0ff 100644 (file)
@@ -1,3 +1,27 @@
+2005-04-11  Uros Bizjak  <uros@kss-loka.si>
+
+       * builtins.def (BUILT_IN_LCEIL, BUILT_IN_LCEILF, BUILT_IN_LCEILL)
+       (BUILT_IN_LLCEIL, BUILT_IN_LLCEILF, BUILT_IN_LLCEILL): New.
+       * optabs.h (enum optab_index): Add new OTI_lceil.
+       (lceil_optab): Define corresponding macro.
+       * optabs.c (init_optabs): Initialize lceil_optab.
+       * genopinit.c (optabs): Implement lceil_optab using lceilsi2
+       and lceildi2 patterns.
+       * builtins.c (expand_builtin_int_roundingfn): Handle
+       BUILT_IN_LCEIL{,F,L} and BUILT_IN_LLCEIL{,F,L}.
+       (fold_builtin_int_roundingfn): Handle BUILT_IN_LCEIL{,F,L} and
+       BUILT_IN_LLCEIL{,F,L}.
+       (fold_builtin_1): Fold BUILT_IN_LCEIL{,F,L} and
+       BUILT_IN_LLCEIL{,F,L} using fold_builtin_int_roundingfn.
+       (mathfn_built_in): Handle BUILT_IN LCEIL and BUILT_IN_LLCEIL.
+       (expand_builtin): Expand BUILT_IN_LCEIL{,F,L} and
+       BUILT_IN_LLCEIL{,F,L} using expand_builtin_int_roundingfn.
+       * convert.c (convert_to_integer): Convert (long int)ceil{,f,l},
+       into lceil built-in function and (long long int)ceil{,f,l} into
+       llceil built-in function.
+       * fold-const.c (tree_expr_nonnegative_p): Add BUILT_IN_LCEIL and
+       BUILT_IN_LLCEIL.
+
 2005-04-10  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
 
        * pa/quadlib.c (_U_Qfneg): Toggle sign bit instead of subtracting from
index 034934c..b7ddb74 100644 (file)
@@ -1549,9 +1549,11 @@ mathfn_built_in (tree type, enum built_in_function fn)
       CASE_MATHFN (BUILT_IN_J0)
       CASE_MATHFN (BUILT_IN_J1)
       CASE_MATHFN (BUILT_IN_JN)
+      CASE_MATHFN (BUILT_IN_LCEIL)
       CASE_MATHFN (BUILT_IN_LDEXP)
       CASE_MATHFN (BUILT_IN_LFLOOR)
       CASE_MATHFN (BUILT_IN_LGAMMA)
+      CASE_MATHFN (BUILT_IN_LLCEIL)
       CASE_MATHFN (BUILT_IN_LLFLOOR)
       CASE_MATHFN (BUILT_IN_LLRINT)
       CASE_MATHFN (BUILT_IN_LLROUND)
@@ -2141,6 +2143,16 @@ expand_builtin_int_roundingfn (tree exp, rtx target, rtx subtarget)
 
   switch (DECL_FUNCTION_CODE (fndecl))
     {
+    case BUILT_IN_LCEIL:
+    case BUILT_IN_LCEILF:
+    case BUILT_IN_LCEILL:
+    case BUILT_IN_LLCEIL:
+    case BUILT_IN_LLCEILF:
+    case BUILT_IN_LLCEILL:
+      builtin_optab = lceil_optab;
+      fallback_fn = BUILT_IN_CEIL;
+      break;
+
     case BUILT_IN_LFLOOR:
     case BUILT_IN_LFLOORF:
     case BUILT_IN_LFLOORL:
@@ -5376,6 +5388,12 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode,
        return target;
       break;
 
+    case BUILT_IN_LCEIL:
+    case BUILT_IN_LCEILF:
+    case BUILT_IN_LCEILL:
+    case BUILT_IN_LLCEIL:
+    case BUILT_IN_LLCEILF:
+    case BUILT_IN_LLCEILL:
     case BUILT_IN_LFLOOR:
     case BUILT_IN_LFLOORF:
     case BUILT_IN_LFLOORL:
@@ -6771,6 +6789,15 @@ fold_builtin_int_roundingfn (tree fndecl, tree arglist)
              real_floor (&r, TYPE_MODE (ftype), &x);
              break;
 
+           case BUILT_IN_LCEIL:
+           case BUILT_IN_LCEILF:
+           case BUILT_IN_LCEILL:
+           case BUILT_IN_LLCEIL:
+           case BUILT_IN_LLCEILF:
+           case BUILT_IN_LLCEILL:
+             real_ceil (&r, TYPE_MODE (ftype), &x);
+             break;
+
            case BUILT_IN_LROUND:
            case BUILT_IN_LROUNDF:
            case BUILT_IN_LROUNDL:
@@ -8328,6 +8355,12 @@ fold_builtin_1 (tree fndecl, tree arglist, bool ignore)
     case BUILT_IN_RINTL:
       return fold_trunc_transparent_mathfn (fndecl, arglist);
 
+    case BUILT_IN_LCEIL:
+    case BUILT_IN_LCEILF:
+    case BUILT_IN_LCEILL:
+    case BUILT_IN_LLCEIL:
+    case BUILT_IN_LLCEILF:
+    case BUILT_IN_LLCEILL:
     case BUILT_IN_LFLOOR:
     case BUILT_IN_LFLOORF:
     case BUILT_IN_LFLOORL:
index 36a644c..51d87ca 100644 (file)
@@ -257,6 +257,9 @@ DEF_EXT_LIB_BUILTIN    (BUILT_IN_J1L, "j1l", BT_FN_LONGDOUBLE_LONGDOUBLE, ATTR_M
 DEF_EXT_LIB_BUILTIN    (BUILT_IN_JN, "jn", BT_FN_DOUBLE_INT_DOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
 DEF_EXT_LIB_BUILTIN    (BUILT_IN_JNF, "jnf", BT_FN_FLOAT_INT_FLOAT, ATTR_MATHFN_FPROUNDING_ERRNO)
 DEF_EXT_LIB_BUILTIN    (BUILT_IN_JNL, "jnl", BT_FN_LONGDOUBLE_INT_LONGDOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
+DEF_GCC_BUILTIN        (BUILT_IN_LCEIL, "lceil", BT_FN_LONG_DOUBLE, ATTR_MATHFN_FPROUNDING)
+DEF_GCC_BUILTIN        (BUILT_IN_LCEILF, "lceilf", BT_FN_LONG_FLOAT, ATTR_MATHFN_FPROUNDING)
+DEF_GCC_BUILTIN        (BUILT_IN_LCEILL, "lceill", BT_FN_LONG_LONGDOUBLE, ATTR_MATHFN_FPROUNDING)
 DEF_LIB_BUILTIN        (BUILT_IN_LDEXP, "ldexp", BT_FN_DOUBLE_DOUBLE_INT, ATTR_MATHFN_FPROUNDING_ERRNO)
 DEF_C99_C90RES_BUILTIN (BUILT_IN_LDEXPF, "ldexpf", BT_FN_FLOAT_FLOAT_INT, ATTR_MATHFN_FPROUNDING_ERRNO)
 DEF_C99_C90RES_BUILTIN (BUILT_IN_LDEXPL, "ldexpl", BT_FN_LONGDOUBLE_LONGDOUBLE_INT, ATTR_MATHFN_FPROUNDING_ERRNO)
@@ -266,6 +269,9 @@ DEF_GCC_BUILTIN        (BUILT_IN_LFLOORL, "lfloorl", BT_FN_LONG_LONGDOUBLE, ATTR
 DEF_C99_BUILTIN        (BUILT_IN_LGAMMA, "lgamma", BT_FN_DOUBLE_DOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
 DEF_C99_BUILTIN        (BUILT_IN_LGAMMAF, "lgammaf", BT_FN_FLOAT_FLOAT, ATTR_MATHFN_FPROUNDING_ERRNO)
 DEF_C99_BUILTIN        (BUILT_IN_LGAMMAL, "lgammal", BT_FN_LONGDOUBLE_LONGDOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
+DEF_GCC_BUILTIN        (BUILT_IN_LLCEIL, "llceil", BT_FN_LONGLONG_DOUBLE, ATTR_MATHFN_FPROUNDING)
+DEF_GCC_BUILTIN        (BUILT_IN_LLCEILF, "llceilf", BT_FN_LONGLONG_FLOAT, ATTR_MATHFN_FPROUNDING)
+DEF_GCC_BUILTIN        (BUILT_IN_LLCEILL, "llceill", BT_FN_LONGLONG_LONGDOUBLE, ATTR_MATHFN_FPROUNDING)
 DEF_GCC_BUILTIN        (BUILT_IN_LLFLOOR, "llfloor", BT_FN_LONGLONG_DOUBLE, ATTR_MATHFN_FPROUNDING)
 DEF_GCC_BUILTIN        (BUILT_IN_LLFLOORF, "llfloorf", BT_FN_LONGLONG_FLOAT, ATTR_MATHFN_FPROUNDING)
 DEF_GCC_BUILTIN        (BUILT_IN_LLFLOORL, "llfloorl", BT_FN_LONGLONG_LONGDOUBLE, ATTR_MATHFN_FPROUNDING)
index 79aef21..9ae300d 100644 (file)
@@ -349,6 +349,13 @@ convert_to_integer (tree type, tree expr)
       
       switch (fcode)
         {
+       case BUILT_IN_CEIL: case BUILT_IN_CEILF: case BUILT_IN_CEILL:
+         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:
          if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (long_long_integer_type_node))
            fn = mathfn_built_in (s_intype, BUILT_IN_LLFLOOR);
index 4d7ee93..061e92a 100644 (file)
@@ -10618,8 +10618,10 @@ tree_expr_nonnegative_p (tree t)
            CASE_BUILTIN_F (BUILT_IN_EXPM1)
            CASE_BUILTIN_F (BUILT_IN_FLOOR)
            CASE_BUILTIN_F (BUILT_IN_FMOD)
+           CASE_BUILTIN_F (BUILT_IN_LCEIL)
            CASE_BUILTIN_F (BUILT_IN_LDEXP)
            CASE_BUILTIN_F (BUILT_IN_LFLOOR)
+           CASE_BUILTIN_F (BUILT_IN_LLCEIL)
            CASE_BUILTIN_F (BUILT_IN_LLFLOOR)
            CASE_BUILTIN_F (BUILT_IN_LLRINT)
            CASE_BUILTIN_F (BUILT_IN_LLROUND)
index 42a525f..da80f78 100644 (file)
@@ -121,6 +121,7 @@ static const char * const optabs[] =
   "floor_optab->handlers[$A].insn_code = CODE_FOR_$(floor$a2$)",
   "lfloor_optab->handlers[$A].insn_code = CODE_FOR_$(lfloor$a2$)",
   "ceil_optab->handlers[$A].insn_code = CODE_FOR_$(ceil$a2$)",
+  "lceil_optab->handlers[$A].insn_code = CODE_FOR_$(lceil$a2$)",
   "round_optab->handlers[$A].insn_code = CODE_FOR_$(round$a2$)",
   "btrunc_optab->handlers[$A].insn_code = CODE_FOR_$(btrunc$a2$)",
   "nearbyint_optab->handlers[$A].insn_code = CODE_FOR_$(nearbyint$a2$)",
index d672744..6835a9a 100644 (file)
@@ -5035,6 +5035,7 @@ init_optabs (void)
   floor_optab = init_optab (UNKNOWN);
   lfloor_optab = init_optab (UNKNOWN);
   ceil_optab = init_optab (UNKNOWN);
+  lceil_optab = init_optab (UNKNOWN);
   round_optab = init_optab (UNKNOWN);
   btrunc_optab = init_optab (UNKNOWN);
   nearbyint_optab = init_optab (UNKNOWN);
index a1c2d37..dea332e 100644 (file)
@@ -188,6 +188,7 @@ enum optab_index
   OTI_floor,
   OTI_lfloor,
   OTI_ceil,
+  OTI_lceil,
   OTI_btrunc,
   OTI_round,
   OTI_nearbyint,
@@ -316,6 +317,7 @@ extern GTY(()) optab optab_table[OTI_MAX];
 #define floor_optab (optab_table[OTI_floor])
 #define lfloor_optab (optab_table[OTI_lfloor])
 #define ceil_optab (optab_table[OTI_ceil])
+#define lceil_optab (optab_table[OTI_lceil])
 #define btrunc_optab (optab_table[OTI_btrunc])
 #define round_optab (optab_table[OTI_round])
 #define nearbyint_optab (optab_table[OTI_nearbyint])
index 1933911..1ad47f1 100644 (file)
@@ -1,3 +1,8 @@
+2005-04-11  Uros Bizjak  <uros@kss-loka.si>
+
+       * gcc.dg/builtins-53.c: Also check (int)ceil* and
+       (long long int)ceil*.
+       
 2005-04-10  Mark Mitchell  <mark@codesourcery.com>
 
        * g++.dg/warn/Wdtor1.C: Declare template in system header with
 
 2005-04-09  Uros Bizjak  <uros@kss-loka.si>
 
+       * gcc.dg/builtins-53.c: Also check lceil* and llceil*.
+
+2005-04-09  Uros Bizjak  <uros@kss-loka.si>
+
        * gcc.dg/builtins-53.c: New test.
 
 2005-04-08  Diego Novillo  <dnovillo@redhat.com>
index 6b1a6f8..6bf481b 100644 (file)
@@ -1,7 +1,9 @@
 /* Copyright (C) 2005 Free Software Foundation.
 
    Check that (long)floor, (long)floorf, (long)floorl,
-   (long long)floor, (long long)floorf and (long long)floorl
+   (long long)floor, (long long)floorf, (long long)floorl,
+   (long)ceil, (long)ceilf, (long)ceill,
+   (long long)ceil, (long long)ceilf, (long long)ceill
    built-in functions compile.
 
    Written by Uros Bizjak, 5th April 2005.  */
 /* { dg-options "-O2 -ffast-math" } */
 
 extern double floor(double);
+extern double ceil(double);
+
 extern float floorf(float);
+extern float ceilf(float);
+
 extern long double floorl(long double);
+extern long double ceill(long double);
 
 
 long int test1(double x)
@@ -24,6 +31,16 @@ long long int test2(double x)
   return floor(x);
 }
 
+long int test3(double x)
+{
+  return ceil(x);
+}
+
+long long int test4(double x)
+{
+  return ceil(x);
+}
+
 long int test1f(float x)
 {
   return floorf(x);
@@ -34,6 +51,16 @@ long long int test2f(float x)
   return floorf(x);
 }
 
+long int test3f(float x)
+{
+  return ceilf(x);
+}
+
+long long int test4f(float x)
+{
+  return ceilf(x);
+}
+
 long int test1l(long double x)
 {
   return floorl(x);
@@ -43,3 +70,13 @@ long long int test2l(long double x)
 {
   return floorl(x);
 }
+
+long int test3l(long double x)
+{
+  return ceill(x);
+}
+
+long long int test4l(long double x)
+{
+  return ceill(x);
+}