This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [power7-meissner] Vectorize simple math builtins


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]