public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Split constant handling out of fold_builtin_fma
@ 2015-10-26  9:58 Richard Sandiford
  2015-10-26 10:45 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Sandiford @ 2015-10-26  9:58 UTC (permalink / raw)
  To: gcc-patches

Just makes an upcoming patch a bit clearer.

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

Thanks,
Richard


gcc/
	* builtins.c (fold_builtin_fma): Remove constant handling.
	(fold_builtin_3): Handle constant fma arguments here.

diff --git a/gcc/builtins.c b/gcc/builtins.c
index a03dffc..6cd8879 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -7881,18 +7881,13 @@ fold_fma (location_t loc ATTRIBUTE_UNUSED,
 static tree
 fold_builtin_fma (location_t loc, tree arg0, tree arg1, tree arg2, tree type)
 {
+  /* ??? Only expand to FMA_EXPR if it's directly supported.  */
   if (validate_arg (arg0, REAL_TYPE)
       && validate_arg (arg1, REAL_TYPE)
-      && validate_arg (arg2, REAL_TYPE))
-    {
-      tree tem = fold_fma (loc, type, arg0, arg1, arg2);
-      if (tem)
-	return tem;
+      && validate_arg (arg2, REAL_TYPE)
+      && optab_handler (fma_optab, TYPE_MODE (type)) != CODE_FOR_nothing)
+    return fold_build3_loc (loc, FMA_EXPR, type, arg0, arg1, arg2);
 
-      /* ??? Only expand to FMA_EXPR if it's directly supported.  */
-      if (optab_handler (fma_optab, TYPE_MODE (type)) != CODE_FOR_nothing)
-        return fold_build3_loc (loc, FMA_EXPR, type, arg0, arg1, arg2);
-    }
   return NULL_TREE;
 }
 
@@ -9307,8 +9302,9 @@ fold_builtin_3 (location_t loc, tree fndecl,
       return fold_builtin_sincos (loc, arg0, arg1, arg2);
 
     CASE_FLT_FN (BUILT_IN_FMA):
+      if (tree tem = fold_fma (loc, type, arg0, arg1, arg2))
+	return tem;
       return fold_builtin_fma (loc, arg0, arg1, arg2, type);
-    break;
 
     CASE_FLT_FN (BUILT_IN_REMQUO):
       if (validate_arg (arg0, REAL_TYPE)

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

* Re: Split constant handling out of fold_builtin_fma
  2015-10-26  9:58 Split constant handling out of fold_builtin_fma Richard Sandiford
@ 2015-10-26 10:45 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2015-10-26 10:45 UTC (permalink / raw)
  To: GCC Patches, richard.sandiford

On Mon, Oct 26, 2015 at 10:57 AM, Richard Sandiford
<richard.sandiford@arm.com> wrote:
> Just makes an upcoming patch a bit clearer.
>
> 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_fma): Remove constant handling.
>         (fold_builtin_3): Handle constant fma arguments here.
>
> diff --git a/gcc/builtins.c b/gcc/builtins.c
> index a03dffc..6cd8879 100644
> --- a/gcc/builtins.c
> +++ b/gcc/builtins.c
> @@ -7881,18 +7881,13 @@ fold_fma (location_t loc ATTRIBUTE_UNUSED,
>  static tree
>  fold_builtin_fma (location_t loc, tree arg0, tree arg1, tree arg2, tree type)
>  {
> +  /* ??? Only expand to FMA_EXPR if it's directly supported.  */
>    if (validate_arg (arg0, REAL_TYPE)
>        && validate_arg (arg1, REAL_TYPE)
> -      && validate_arg (arg2, REAL_TYPE))
> -    {
> -      tree tem = fold_fma (loc, type, arg0, arg1, arg2);
> -      if (tem)
> -       return tem;
> +      && validate_arg (arg2, REAL_TYPE)
> +      && optab_handler (fma_optab, TYPE_MODE (type)) != CODE_FOR_nothing)
> +    return fold_build3_loc (loc, FMA_EXPR, type, arg0, arg1, arg2);
>
> -      /* ??? Only expand to FMA_EXPR if it's directly supported.  */
> -      if (optab_handler (fma_optab, TYPE_MODE (type)) != CODE_FOR_nothing)
> -        return fold_build3_loc (loc, FMA_EXPR, type, arg0, arg1, arg2);
> -    }
>    return NULL_TREE;
>  }
>
> @@ -9307,8 +9302,9 @@ fold_builtin_3 (location_t loc, tree fndecl,
>        return fold_builtin_sincos (loc, arg0, arg1, arg2);
>
>      CASE_FLT_FN (BUILT_IN_FMA):
> +      if (tree tem = fold_fma (loc, type, arg0, arg1, arg2))
> +       return tem;
>        return fold_builtin_fma (loc, arg0, arg1, arg2, type);
> -    break;
>
>      CASE_FLT_FN (BUILT_IN_REMQUO):
>        if (validate_arg (arg0, REAL_TYPE)
>

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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-26  9:58 Split constant handling out of fold_builtin_fma Richard Sandiford
2015-10-26 10:45 ` 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).