From 21e01bf10d229bdd98b45464021c10fb510e7348 Mon Sep 17 00:00:00 2001 From: Uros Bizjak Date: Mon, 21 Mar 2005 15:42:48 +0100 Subject: [PATCH] optabs.h (enum optab_index): Add new OTI_lrint and OTI_llrint. * 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 | 13 ++++++++++ gcc/builtins.c | 14 +++++++++++ gcc/genopinit.c | 2 ++ gcc/optabs.c | 2 ++ gcc/optabs.h | 4 +++ gcc/testsuite/ChangeLog | 4 +++ gcc/testsuite/gcc.dg/builtins-46.c | 39 +++++++++++++++++++++++++++++- 7 files changed, 77 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 429d32c4528..05317acbbd0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2005-03-21 Uros Bizjak + + * 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 * combine.c (combine_simplify_rtx, simplify_if_then_else, diff --git a/gcc/builtins.c b/gcc/builtins.c index 94fa62755f5..703fb3fceff 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -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; diff --git a/gcc/genopinit.c b/gcc/genopinit.c index e52ca068984..a71abb074d3 100644 --- a/gcc/genopinit.c +++ b/gcc/genopinit.c @@ -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$)", diff --git a/gcc/optabs.c b/gcc/optabs.c index b2021f1d358..57c3339437b 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -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); diff --git a/gcc/optabs.h b/gcc/optabs.h index b9aa6ac4161..92885643604 100644 --- a/gcc/optabs.h +++ b/gcc/optabs.h @@ -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]) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4256904f5c9..1dfc53b15d0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2005-03-21 Uros Bizjak + + * gcc.dg/builtins-46.c: Also check lrint* and llrint*. + 2005-03-21 Paolo Carlini * g++.dg/parse/crash25.C: Fix typo. diff --git a/gcc/testsuite/gcc.dg/builtins-46.c b/gcc/testsuite/gcc.dg/builtins-46.c index 67c979f73f0..3a955a56929 100644 --- a/gcc/testsuite/gcc.dg/builtins-46.c +++ b/gcc/testsuite/gcc.dg/builtins-46.c @@ -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. @@ -11,18 +12,24 @@ /* { 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); -- 2.30.2