public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Rename logb and significand folds
@ 2015-10-26 10:07 Richard Sandiford
  2015-10-26 10:50 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Sandiford @ 2015-10-26 10:07 UTC (permalink / raw)
  To: gcc-patches

fold_builtin_logb and fold_builtin_significand now only handle
constant arguments, so this patch renames them to fold_const...,
to match fold_const_builtin_pow.  The idea is to differentiate
constant-only folds so that they can be moved to a const_binop-like
function in future.

The functions also had some unnecessary calls to STRIP_NOPS, which
I think are left over from code that has already moved to match.pd.

Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.
OK to install?

Thanks,
Richard


gcc/
	* builtins.c (fold_builtin_logb): Rename to...
	(fold_const_builtin_logb): ...this and remove STRIP_NOPS call.
	(fold_builtin_significand): Rename to...
	(fold_const_builtin_significand): ...this and remove STRIP_NOPS call.
	(fold_builtin_1): Update accordingly.

diff --git a/gcc/builtins.c b/gcc/builtins.c
index 86eac5c..260b66d 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -7916,13 +7916,11 @@ fold_builtin_carg (location_t loc, tree arg, tree type)
 /* Fold a call to builtin logb/ilogb.  */
 
 static tree
-fold_builtin_logb (location_t loc, tree arg, tree rettype)
+fold_const_builtin_logb (location_t loc, tree arg, tree rettype)
 {
   if (! validate_arg (arg, REAL_TYPE))
     return NULL_TREE;
 
-  STRIP_NOPS (arg);
-
   if (TREE_CODE (arg) == REAL_CST && ! TREE_OVERFLOW (arg))
     {
       const REAL_VALUE_TYPE *const value = TREE_REAL_CST_PTR (arg);
@@ -7967,13 +7965,11 @@ fold_builtin_logb (location_t loc, tree arg, tree rettype)
 /* Fold a call to builtin significand, if radix == 2.  */
 
 static tree
-fold_builtin_significand (location_t loc, tree arg, tree rettype)
+fold_const_builtin_significand (location_t loc, tree arg, tree rettype)
 {
   if (! validate_arg (arg, REAL_TYPE))
     return NULL_TREE;
 
-  STRIP_NOPS (arg);
-
   if (TREE_CODE (arg) == REAL_CST && ! TREE_OVERFLOW (arg))
     {
       const REAL_VALUE_TYPE *const value = TREE_REAL_CST_PTR (arg);
@@ -9002,11 +8998,11 @@ fold_builtin_1 (location_t loc, tree fndecl, tree arg0)
       break;
 
     CASE_FLT_FN (BUILT_IN_SIGNIFICAND):
-      return fold_builtin_significand (loc, arg0, type);
+      return fold_const_builtin_significand (loc, arg0, type);
 
     CASE_FLT_FN (BUILT_IN_ILOGB):
     CASE_FLT_FN (BUILT_IN_LOGB):
-      return fold_builtin_logb (loc, arg0, type);
+      return fold_const_builtin_logb (loc, arg0, type);
 
     case BUILT_IN_ISASCII:
       return fold_builtin_isascii (loc, arg0);

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

* Re: Rename logb and significand folds
  2015-10-26 10:07 Rename logb and significand folds Richard Sandiford
@ 2015-10-26 10:50 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2015-10-26 10:50 UTC (permalink / raw)
  To: GCC Patches, richard.sandiford

On Mon, Oct 26, 2015 at 11:05 AM, Richard Sandiford
<richard.sandiford@arm.com> wrote:
> fold_builtin_logb and fold_builtin_significand now only handle
> constant arguments, so this patch renames them to fold_const...,
> to match fold_const_builtin_pow.  The idea is to differentiate
> constant-only folds so that they can be moved to a const_binop-like
> function in future.
>
> The functions also had some unnecessary calls to STRIP_NOPS, which
> I think are left over from code that has already moved to match.pd.
>
> Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.
> OK to install?

Ok.

Thanks,
Richard.

> Thanks,
> Richard
>
>
> gcc/
>         * builtins.c (fold_builtin_logb): Rename to...
>         (fold_const_builtin_logb): ...this and remove STRIP_NOPS call.
>         (fold_builtin_significand): Rename to...
>         (fold_const_builtin_significand): ...this and remove STRIP_NOPS call.
>         (fold_builtin_1): Update accordingly.
>
> diff --git a/gcc/builtins.c b/gcc/builtins.c
> index 86eac5c..260b66d 100644
> --- a/gcc/builtins.c
> +++ b/gcc/builtins.c
> @@ -7916,13 +7916,11 @@ fold_builtin_carg (location_t loc, tree arg, tree type)
>  /* Fold a call to builtin logb/ilogb.  */
>
>  static tree
> -fold_builtin_logb (location_t loc, tree arg, tree rettype)
> +fold_const_builtin_logb (location_t loc, tree arg, tree rettype)
>  {
>    if (! validate_arg (arg, REAL_TYPE))
>      return NULL_TREE;
>
> -  STRIP_NOPS (arg);
> -
>    if (TREE_CODE (arg) == REAL_CST && ! TREE_OVERFLOW (arg))
>      {
>        const REAL_VALUE_TYPE *const value = TREE_REAL_CST_PTR (arg);
> @@ -7967,13 +7965,11 @@ fold_builtin_logb (location_t loc, tree arg, tree rettype)
>  /* Fold a call to builtin significand, if radix == 2.  */
>
>  static tree
> -fold_builtin_significand (location_t loc, tree arg, tree rettype)
> +fold_const_builtin_significand (location_t loc, tree arg, tree rettype)
>  {
>    if (! validate_arg (arg, REAL_TYPE))
>      return NULL_TREE;
>
> -  STRIP_NOPS (arg);
> -
>    if (TREE_CODE (arg) == REAL_CST && ! TREE_OVERFLOW (arg))
>      {
>        const REAL_VALUE_TYPE *const value = TREE_REAL_CST_PTR (arg);
> @@ -9002,11 +8998,11 @@ fold_builtin_1 (location_t loc, tree fndecl, tree arg0)
>        break;
>
>      CASE_FLT_FN (BUILT_IN_SIGNIFICAND):
> -      return fold_builtin_significand (loc, arg0, type);
> +      return fold_const_builtin_significand (loc, arg0, type);
>
>      CASE_FLT_FN (BUILT_IN_ILOGB):
>      CASE_FLT_FN (BUILT_IN_LOGB):
> -      return fold_builtin_logb (loc, arg0, type);
> +      return fold_const_builtin_logb (loc, arg0, type);
>
>      case BUILT_IN_ISASCII:
>        return fold_builtin_isascii (loc, arg0);
>

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

end of thread, other threads:[~2015-10-26 10:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-26 10:07 Rename logb and significand folds Richard Sandiford
2015-10-26 10:50 ` Richard Biener

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