public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tejas Joshi <tejasjoshi9673@gmail.com>
To: gcc@gcc.gnu.org
Subject: GSoC 2018 - Adding functions in math.h
Date: Sun, 11 Mar 2018 21:15:00 -0000	[thread overview]
Message-ID: <CACMrGjDicnx7-3msyZnn9Jp6wehH2UON6nps0_kr7Rx96fOJLw@mail.gmail.com> (raw)

> * roundeven is similar to existing functions round / ceil / floor / trunc.
> So you'd define built-in functions (roundeven / roundevenf / roundevenl
> and _FloatN and _FloatNx variants) similar to those for the older rounding
> functions, in builtins.def.



Hello,
Thanks to all for your inputs to get me through. As mentioned above, I
have added the function roundeven in match.pd
and its declaration in builtins.def for the testcase 0. Following is
the patch for the same.

For inlining functions, is it the same kind of specialized expansion from
GIMPLE to RTL which is already there for some math functions in bultins.c?
If I get more clear with it, I'd get to go for the proposal.
Thank you.


Regards,
-Tejas

Patch:

diff --git a/gcc/builtins.def b/gcc/builtins.def
index 17f825da367..70640a53347 100644
--- a/gcc/builtins.def
+++ b/gcc/builtins.def
@@ -563,6 +563,7 @@ DEF_C99_BUILTIN        (BUILT_IN_RINTL, "rintl",
BT_FN_LONGDOUBLE_LONGDOUBLE, AT
 DEF_EXT_LIB_FLOATN_NX_BUILTINS (BUILT_IN_RINT, "rint", RINT_TYPE,
ATTR_CONST_NOTHROW_LEAF_LIST)
 #undef RINT_TYPE
 DEF_C99_BUILTIN        (BUILT_IN_ROUND, "round", BT_FN_DOUBLE_DOUBLE,
ATTR_CONST_NOTHROW_LEAF_LIST)
+DEF_C11_BUILTIN        (BUILT_IN_ROUNDEVEN, "roundeven",
BT_FN_DOUBLE_DOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_C99_BUILTIN        (BUILT_IN_ROUNDF, "roundf", BT_FN_FLOAT_FLOAT,
ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_C99_BUILTIN        (BUILT_IN_ROUNDL, "roundl",
BT_FN_LONGDOUBLE_LONGDOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
 #define ROUND_TYPE(F) BT_FN_##F##_##F
diff --git a/gcc/match.pd b/gcc/match.pd
index 5ba1304af4e..fd77349ed55 100644

--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -4686,3 +4686,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
     || wi::geu_p (wi::to_wide (@rpos),
               wi::to_wide (@ipos) + isize))
     (BIT_FIELD_REF @0 @rsize @rpos)))))
+(simplify
+  (BUILT_IN_ROUNDEVEN real_zerop@0)
+  { build_zero_cst (TREE_TYPE(@0)); })

             reply	other threads:[~2018-03-11 21:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-11 21:15 Tejas Joshi [this message]
2018-03-12 16:41 ` Joseph Myers
  -- strict thread matches above, loose matches on Subject: below --
2018-03-11 21:00 Tejas Joshi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACMrGjDicnx7-3msyZnn9Jp6wehH2UON6nps0_kr7Rx96fOJLw@mail.gmail.com \
    --to=tejasjoshi9673@gmail.com \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).