public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* GSoC 2018 - Adding functions in math.h
@ 2018-03-11 21:00 Tejas Joshi
  0 siblings, 0 replies; 3+ messages in thread
From: Tejas Joshi @ 2018-03-11 21:00 UTC (permalink / raw)
  To: gcc

[-- Attachment #1: Type: text/plain, Size: 748 bytes --]

> * 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
attachment 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 Attachment:

[-- Attachment #2: roundeven.diff --]
[-- Type: text/x-patch, Size: 1191 bytes --]

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)); })

^ permalink raw reply	[flat|nested] 3+ messages in thread
* GSoC 2018 - Adding functions in math.h
@ 2018-03-11 21:15 Tejas Joshi
  2018-03-12 16:41 ` Joseph Myers
  0 siblings, 1 reply; 3+ messages in thread
From: Tejas Joshi @ 2018-03-11 21:15 UTC (permalink / raw)
  To: gcc

> * 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)); })

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-03-12 16:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-11 21:00 GSoC 2018 - Adding functions in math.h Tejas Joshi
2018-03-11 21:15 Tejas Joshi
2018-03-12 16:41 ` Joseph Myers

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).