How to convert SSEish _mm_set1_ps() into AltiVec correctly?
Alexey Dokuchaev
danfe at nsu.ru
Tue Jul 15 05:52:32 UTC 2014
On Mon, Jul 14, 2014 at 09:20:55AM -0700, Justin Hibbits wrote:
> On Mon, Jul 14, 2014 at 8:42 AM, Alexey Dokuchaev <danfe at nsu.ru> wrote:
> > I'm a bit confused about how to convert _mm_set1_ps() [1] SSE function into
> > its AltiVec equivalent. To start with, I need to set all four floats of a
> > vector to the same value. So far, I've come up with two versions that work
> > with GCC or Clang, but I want to have a code that works with any compiler,
> > and is technically correct (works not just by accident). [...]
>
> I just tried the following:
>
> vector float a = (vector float){42.0f};
> vector float b = vec_splat(a, 0);
>
> Haven't done anything more than compile test it, but it builds with
> both gcc and clang. GCC uses vspltw, while clang uses vperm.
Awesome, thanks, that works. It did not occur to me that simply casting a
{42.f} and assigning it directly would DTRT on its own.
./danfe
More information about the freebsd-ppc
mailing list