0

I played around with the gcc vector extension. Among other things, you can for example calculate vector + vector, vector + scalar, or scalar + vector. The scalar is converted to a vector with all identical elements.

But I cannot find a way to set a vector directly to all identical values. If x is a vector with defined value and n a scalar, i could calculate (x ^ x) + n, which seems to generate optimal code, but I have to fill the vector x with some data first or get a warning. (x * 0) + n is the same.

Question: Is there a way to set a SIMD vector to identical items directly without any strange workarounds and without having to repeat values?

gnasher729
  • 51,477
  • 5
  • 75
  • 98
  • 1
    Does this answer your question? [GNU C native vectors: how to broadcast a scalar, like x86's \_mm\_set1\_epi16](https://stackoverflow.com/questions/40730815/gnu-c-native-vectors-how-to-broadcast-a-scalar-like-x86s-mm-set1-epi16) – teapot418 Mar 21 '23 at 22:57

0 Answers0