optabs.h (enum optab_index): Add new OTI_lrint and OTI_llrint.
authorUros Bizjak <uros@kss-loka.si>
Mon, 21 Mar 2005 14:42:48 +0000 (15:42 +0100)
committerUros Bizjak <uros@gcc.gnu.org>
Mon, 21 Mar 2005 14:42:48 +0000 (15:42 +0100)
* optabs.h (enum optab_index): Add new OTI_lrint and OTI_llrint.
(lrint_optab, llrint_optab): Define corresponding macros.
* optabs.c (init_optabs): Initialize lrint_optab and llrint_optab.
* genopinit.c (optabs): Implement lrint_optab using lrintsi2
pattern and llrint_optab using llrintdi2 patterns.
* builtins.c (expand_builtin_mathfn): Handle BUILT_IN_LRINT{,F,L}
using lrint_optab and BUILT_IN_LLRINT{,F,L} using llrint_optab.
(expand_builtin): Expand BUILT_IN_LRINT{,F,L} and
BUILT_IN_LLRINT{,F,L} using expand_builtin_mathfn if
flag_unsafe_math_optimizations is set.

testsuite:

* gcc.dg/builtins-46.c: Also check lrint* and llrint*.

From-SVN: r96802

gcc/ChangeLog
gcc/builtins.c
gcc/genopinit.c
gcc/optabs.c
gcc/optabs.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/builtins-46.c

index 429d32c4528ce41b349a67e59616a97e6de159ef..05317acbbd06db353983b96764c57fc33fcb7a88 100644 (file)
@@ -1,3 +1,16 @@
+2005-03-21  Uros Bizjak  <uros@kss-loka.si>
+
+       * optabs.h (enum optab_index): Add new OTI_lrint and OTI_llrint.
+       (lrint_optab, llrint_optab): Define corresponding macros.
+       * optabs.c (init_optabs): Initialize lrint_optab and llrint_optab.
+       * genopinit.c (optabs): Implement lrint_optab using lrintsi2
+       pattern and llrint_optab using llrintdi2 patterns.
+       * builtins.c (expand_builtin_mathfn): Handle BUILT_IN_LRINT{,F,L}
+       using lrint_optab and BUILT_IN_LLRINT{,F,L} using llrint_optab.
+       (expand_builtin): Expand BUILT_IN_LRINT{,F,L} and
+       BUILT_IN_LLRINT{,F,L} using expand_builtin_mathfn if
+       flag_unsafe_math_optimizations is set.
+
 2005-03-21  Paolo Bonzini  <bonzini@gnu.org>
 
        * combine.c (combine_simplify_rtx, simplify_if_then_else,
index 94fa62755f5b1d22449d9edaf59683f5acfca08b..703fb3fceff83670e8c22c8bb2ef861f074a1d73 100644 (file)
@@ -1758,6 +1758,14 @@ expand_builtin_mathfn (tree exp, rtx target, rtx subtarget)
     case BUILT_IN_RINTF:
     case BUILT_IN_RINTL:
       builtin_optab = rint_optab; break;
+    case BUILT_IN_LRINT:
+    case BUILT_IN_LRINTF:
+    case BUILT_IN_LRINTL:
+      builtin_optab = lrint_optab; break;
+    case BUILT_IN_LLRINT:
+    case BUILT_IN_LLRINTF:
+    case BUILT_IN_LLRINTL:
+      builtin_optab = llrint_optab; break;
     default:
       gcc_unreachable ();
     }
@@ -5261,6 +5269,12 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode,
     case BUILT_IN_RINT:
     case BUILT_IN_RINTF:
     case BUILT_IN_RINTL:
+    case BUILT_IN_LRINT:
+    case BUILT_IN_LRINTF:
+    case BUILT_IN_LRINTL:
+    case BUILT_IN_LLRINT:
+    case BUILT_IN_LLRINTF:
+    case BUILT_IN_LLRINTL:
       target = expand_builtin_mathfn (exp, target, subtarget);
       if (target)
        return target;
index e52ca068984f4148fbd997cd1955f7c05fc6848c..a71abb074d39b65a0d78523c77f1396b979ec99a 100644 (file)
@@ -124,6 +124,8 @@ static const char * const optabs[] =
   "btrunc_optab->handlers[$A].insn_code = CODE_FOR_$(btrunc$a2$)",
   "nearbyint_optab->handlers[$A].insn_code = CODE_FOR_$(nearbyint$a2$)",
   "rint_optab->handlers[$A].insn_code = CODE_FOR_$(rint$a2$)",
+  "lrint_optab->handlers[$A].insn_code = CODE_FOR_$(lrint$a2$)",
+  "llrint_optab->handlers[$A].insn_code = CODE_FOR_$(llrint$a2$)",
   "sincos_optab->handlers[$A].insn_code = CODE_FOR_$(sincos$a3$)",
   "sin_optab->handlers[$A].insn_code = CODE_FOR_$(sin$a2$)",
   "asin_optab->handlers[$A].insn_code = CODE_FOR_$(asin$a2$)",
index b2021f1d358cdc617bfe84002d03d20897b8a86a..57c3339437b5e72ae3e8e6c35d453759983ce296 100644 (file)
@@ -5033,6 +5033,8 @@ init_optabs (void)
   btrunc_optab = init_optab (UNKNOWN);
   nearbyint_optab = init_optab (UNKNOWN);
   rint_optab = init_optab (UNKNOWN);
+  lrint_optab = init_optab (UNKNOWN);
+  llrint_optab = init_optab (UNKNOWN);
   sincos_optab = init_optab (UNKNOWN);
   sin_optab = init_optab (UNKNOWN);
   asin_optab = init_optab (UNKNOWN);
index b9aa6ac4161465c88b5f66e076933c1925387729..92885643604c1ff23f9eb83c8a654dd9b3918cd5 100644 (file)
@@ -191,6 +191,8 @@ enum optab_index
   OTI_round,
   OTI_nearbyint,
   OTI_rint,
+  OTI_lrint,
+  OTI_llrint,
   /* Tangent */
   OTI_tan,
   /* Inverse tangent */
@@ -317,6 +319,8 @@ extern GTY(()) optab optab_table[OTI_MAX];
 #define round_optab (optab_table[OTI_round])
 #define nearbyint_optab (optab_table[OTI_nearbyint])
 #define rint_optab (optab_table[OTI_rint])
+#define lrint_optab (optab_table[OTI_lrint])
+#define llrint_optab (optab_table[OTI_llrint])
 #define tan_optab (optab_table[OTI_tan])
 #define atan_optab (optab_table[OTI_atan])
 #define copysign_optab (optab_table[OTI_copysign])
index 4256904f5c9cd5e60089dac9060a013db1745c65..1dfc53b15d0fef5c7667b9a9f8022acd36852ada 100644 (file)
@@ -1,3 +1,7 @@
+2005-03-21  Uros Bizjak  <uros@kss-loka.si>
+
+       * gcc.dg/builtins-46.c: Also check lrint* and llrint*.
+
 2005-03-21  Paolo Carlini  <pcarlini@suse.de>
 
        * g++.dg/parse/crash25.C: Fix typo.
index 67c979f73f0e3599bfebfa50bd299265b5264df5..3a955a56929c097e725ec09a1904df3dee81e7a0 100644 (file)
@@ -1,6 +1,7 @@
 /* Copyright (C) 2004 Free Software Foundation.
 
-   Check that rint, rintf, rintl, floor, floorf, floorl,
+   Check that rint, rintf, rintl, lrint, lrintf, lrintl,
+   llrint, llrintf, llrintl, floor, floorf, floorl,
    ceil, ceilf, ceill, trunc, truncf, truncl,
    nearbyint, nearbyintf and nearbyintl
    built-in functions compile.
 /* { dg-options "-O2 -ffast-math" } */
 
 extern double rint(double);
+extern long int lrint(double);
+extern long long int llrint(double);
 extern double floor(double);
 extern double ceil(double);
 extern double trunc(double);
 extern double nearbyint(double);
 
 extern float rintf(float);
+extern long int lrintf(float);
+extern long long int llrintf(float);
 extern float floorf(float);
 extern float ceilf(float);
 extern float truncf(float);
 extern float nearbyintf(float);
 
 extern long double rintl(long double);
+extern long int lrintl(long double);
+extern long long int llrintl(long double);
 extern long double floorl(long double);
 extern long double ceill(long double);
 extern long double truncl(long double);
@@ -34,6 +41,16 @@ double test1(double x)
   return rint(x);
 }
 
+long int test11(double x)
+{
+  return lrint(x);
+}
+
+long long int test12(double x)
+{
+  return llrint(x);
+}
+
 double test2(double x)
 {
   return floor(x);
@@ -59,6 +76,16 @@ float test1f(float x)
   return rintf(x);
 }
 
+long int test11f(float x)
+{
+  return lrintf(x);
+}
+
+long long int test12f(float x)
+{
+  return llrintf(x);
+}
+
 float test2f(float x)
 {
   return floorf(x);
@@ -84,6 +111,16 @@ long double test1l(long double x)
   return rintl(x);
 }
 
+long int test11l(long double x)
+{
+  return lrintl(x);
+}
+
+long long int test12l(long double x)
+{
+  return llrintl(x);
+}
+
 long double test2l(long double x)
 {
   return floorl(x);