This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [power7-meissner] Vectorize simple math builtins
- From: Michael Meissner <meissner at linux dot vnet dot ibm dot com>
- To: Paolo Bonzini <bonzini at gnu dot org>
- Cc: Michael Meissner <meissner at linux dot vnet dot ibm dot com>, gcc-patches at gcc dot gnu dot org, ERES at il dot ibm dot com
- Date: Wed, 15 Jul 2009 13:49:10 -0400
- Subject: Re: [power7-meissner] Vectorize simple math builtins
- References: <20090713212835.GA24856@hungry-tiger.westford.ibm.com> <4A5BC11B.5060109@gnu.org>
On Tue, Jul 14, 2009 at 01:19:55AM +0200, Paolo Bonzini wrote:
> On 07/13/2009 11:28 PM, Michael Meissner wrote:
> >+ case BUILT_IN_COPYSIGNF:
> >+ if (VECTOR_UNIT_VSX_P (V4SFmode)
> >+ && out_mode == SFmode&& out_n == 4
> >+ && in_mode == SFmode&& in_n == 4)
> >+ return rs6000_builtin_decls[VSX_BUILTIN_CPSGNSP];
> >+ break;
>
> Since the implementation for Altivec should be as simple as this:
>
> vspltisw v1,-1 ; v1 = (0xFFFFFFFF, ...)
> vxor v2,v3,v4
> vslw v1,v1,v1 ; v1 = v1 << 31 = (0x80000000, ...)
> vand v1,v1,v2 ; v1 != 0 if sign bits of v3/v4 differ
> vxor v1,v1,v3 ; v1 = v3 with v4's sign bits
>
> Maybe it's worthwhile making it available for Altivec too.
Actually it is much simpler to load up a mask with every bit set except for the
sign bit (or just the sign bit set), and then do a vsel (vector select) between
the value with the sign bit and the value with the rest of the floating point
value.
--
Michael Meissner, IBM
4 Technology Place Drive, MS 2203A, Westford, MA, 01886, USA
meissner@linux.vnet.ibm.com