A.nechi
A.nechi

Reputation: 541

Can't set a vector of 4 floatx32 with ARM NEON intrinsics

I want to load some values from a table and set them into a vector: in the first case set the four values of the vector to a:

float32x4_t dest = vdupq_n_f32(a);

this was so obvious when I read the intrinsics manual.

in the second case set the four values of the vector to different values from a table. This was a little bit tricky because there is no instruction for that, so I did the following:

float32x4_t dest = {a3,a2,a1,a0};

it's not an intrinsic but, basing on other publications and forums on the Net it was the only solution for me. Sadly, I'm getting this error:

error: expected expression before ‘{’ token

Anyone could help or have an alternative for this?

Upvotes: 2

Views: 3942

Answers (1)

Paul R
Paul R

Reputation: 212979

If your compiler does not support direct initialisation like this (i.e. you're using something other than gcc or clang), then you'll need to load the values explicitly, e.g.

const float init[4] = {a3,a2,a1,a0};
float32x4_t dest = vld1q_f32(init);

Note that your first example appears to be wrong - if you're trying to set all 4 vector elements to the same value (like SSE's _mm_set1_ps) then you'll want to use something like vdupq_n_f32.

Upvotes: 5

Related Questions