diff mbox

[i386] : Handle IX86_BUILTIN_INFQ and IX86_BUILTIN_HUGE_VALQ in ix86_fold_builtin

Message ID CAFULd4Zw7XRmCCK9tC6j18NX1BEfaqFDBbS9gQXbDDO_M9PDjA@mail.gmail.com
State New
Headers show

Commit Message

Uros Bizjak Oct. 20, 2016, 10:59 p.m. UTC
2016-10-21  Uros Bizjak  <ubizjak@gmail.com>

    * config/i386/i386.c (ix86_fold_builtin): Handle IX86_BUILTIN_INFQ
    and IX86_BUILTIN_HUGE_VALQ here ...
    (ix86_expand_builtin): ... not here.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.
Committed to mainline SVN.

Uros.

Comments

Joseph Myers Oct. 20, 2016, 11:33 p.m. UTC | #1
On Fri, 21 Oct 2016, Uros Bizjak wrote:

> 2016-10-21  Uros Bizjak  <ubizjak@gmail.com>
> 
>     * config/i386/i386.c (ix86_fold_builtin): Handle IX86_BUILTIN_INFQ
>     and IX86_BUILTIN_HUGE_VALQ here ...
>     (ix86_expand_builtin): ... not here.
> 
> Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.
> Committed to mainline SVN.

Do you know if it's possible to make architecture-specific built-in 
functions into aliases of architecture-independent ones?  That would be 
the ideal thing for the *q __float128 functions - make them aliases of the 
*f128 architecture-independent ones, and so subject to any 
architecture-independent optimizations (for these two there's nothing more 
than folding to do, but at some point I expect we'll optimize fabsf128 and 
copysignf128 as much as the corresponding functions for float / double / 
long double, for example).
Uros Bizjak Oct. 21, 2016, 7 a.m. UTC | #2
On Fri, Oct 21, 2016 at 1:33 AM, Joseph Myers <joseph@codesourcery.com> wrote:
> On Fri, 21 Oct 2016, Uros Bizjak wrote:
>
>> 2016-10-21  Uros Bizjak  <ubizjak@gmail.com>
>>
>>     * config/i386/i386.c (ix86_fold_builtin): Handle IX86_BUILTIN_INFQ
>>     and IX86_BUILTIN_HUGE_VALQ here ...
>>     (ix86_expand_builtin): ... not here.
>>
>> Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.
>> Committed to mainline SVN.
>
> Do you know if it's possible to make architecture-specific built-in
> functions into aliases of architecture-independent ones?  That would be
> the ideal thing for the *q __float128 functions - make them aliases of the
> *f128 architecture-independent ones, and so subject to any
> architecture-independent optimizations (for these two there's nothing more
> than folding to do, but at some point I expect we'll optimize fabsf128 and
> copysignf128 as much as the corresponding functions for float / double /
> long double, for example).

The only thing that is remotely similar to the above functionality is
library name argument to add_builtin_function. Maybe this function can
be enhanced to consider library_name as a true alias for
arch-independent optimizations, not only as a fallback library call?

Uros.
Jakub Jelinek Oct. 21, 2016, 8:02 a.m. UTC | #3
On Thu, Oct 20, 2016 at 11:33:14PM +0000, Joseph Myers wrote:
> On Fri, 21 Oct 2016, Uros Bizjak wrote:
> 
> > 2016-10-21  Uros Bizjak  <ubizjak@gmail.com>
> > 
> >     * config/i386/i386.c (ix86_fold_builtin): Handle IX86_BUILTIN_INFQ
> >     and IX86_BUILTIN_HUGE_VALQ here ...
> >     (ix86_expand_builtin): ... not here.
> > 
> > Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.
> > Committed to mainline SVN.
> 
> Do you know if it's possible to make architecture-specific built-in 
> functions into aliases of architecture-independent ones?  That would be 
> the ideal thing for the *q __float128 functions - make them aliases of the 
> *f128 architecture-independent ones, and so subject to any 
> architecture-independent optimizations (for these two there's nothing more 
> than folding to do, but at some point I expect we'll optimize fabsf128 and 
> copysignf128 as much as the corresponding functions for float / double / 
> long double, for example).

I guess e.g. ix86_fold_builtin could just fold those builtins into calls to
the arch-indepdendent ones, so while it wouldn't be an alias, it could be
represented as the arch-independent builtin from gimplification onwards.

	Jakub
diff mbox

Patch

Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 241384)
+++ config/i386/i386.c	(working copy)
@@ -33323,6 +33323,15 @@  ix86_fold_builtin (tree fndecl, int n_args,
 	    return NULL_TREE;
 	  }
 
+	case IX86_BUILTIN_INFQ:
+	case IX86_BUILTIN_HUGE_VALQ:
+	  {
+	    tree type = TREE_TYPE (TREE_TYPE (fndecl));
+	    REAL_VALUE_TYPE inf;
+	    real_inf (&inf);
+	    return build_real (type, inf);
+	  }
+
 	default:
 	  break;
 	}
@@ -36684,24 +36693,6 @@  ix86_expand_builtin (tree exp, rtx target, rtx sub
     case IX86_BUILTIN_VEC_SET_V16QI:
       return ix86_expand_vec_set_builtin (exp);
 
-    case IX86_BUILTIN_INFQ:
-    case IX86_BUILTIN_HUGE_VALQ:
-      {
-	REAL_VALUE_TYPE inf;
-	rtx tmp;
-
-	real_inf (&inf);
-	tmp = const_double_from_real_value (inf, mode);
-
-	tmp = validize_mem (force_const_mem (mode, tmp));
-
-	if (target == 0)
-	  target = gen_reg_rtx (mode);
-
-	emit_move_insn (target, tmp);
-	return target;
-      }
-
     case IX86_BUILTIN_NANQ:
     case IX86_BUILTIN_NANSQ:
       return expand_call (exp, target, ignore);