Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Aliasing of NEON vector data types

Tags:

c++

c

simd

sse

neon

Does NEON support aliasing of the vector data types with their scalar components?

E.g.(Intel SSE)

typedef long long __m128i __attribute__ ((__vector_size__ (16), __may_alias__));

The above will allow me to do:

__m128i* somePtr;
somePtr++;//advance to the next block

Aliasing a la Intel it will allow to advance my pointer to the next block I want to process without managing extra counts and indexes.

like image 427
celavek Avatar asked Oct 19 '25 11:10

celavek


2 Answers

The __may_alias__ attribute on __m128i should be viewed as a work-around which makes it possible to write strict-aliasing-correct code even though Intel completely screwed up the signatures of some of the SEE load/store intrinsics. (The 8-byte loading _mm_loadl_epi64(const __m128i*) is the most hilarious example, but there are others). ARM got their intrinsics right, so __may_alias__ isn't needed.

Just use pointers to the element type, and use explicit loads and stores. In my experience that leads to better code being generated, and is probably also more portable. (Does the ARM C language spec even allow pointers to NEON types? I wouldn't be surprised if they didn't).

like image 121
fgp Avatar answered Oct 21 '25 02:10

fgp


NEON intrinsics implementation does NOT support aliasing of the vector data types with their scalar components.

like image 29
celavek Avatar answered Oct 21 '25 00:10

celavek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!