Bitwise operation and strong alias

Bitwise operation and strict aliasing

I am trying to write some high performance functions for bit based operations that take advantage of the latest hardware features, the problem I am facing is:

I want to enable bit counting operation, in which case I used Intel SSE4.2

popcnt

to only use values ​​of the integer type accecpt.

At the same time, if I need to do other bitwise logical operations, it AVX

supports 256 bit bit logical operations such as VORPD

(instead of SSE2

128 bit bit logical operations), but only on floating data.

Linking to fact for bit-mutating setup / reset operations, char is the fastest, so I might need at least three types of pointers to point to the same memory locations: a char, long long (64-bit integer for optimal bit counting) and pointers of floating type , however, the coexistence of integer and floating types of pointers violates strict anti-aliasing rules.

Any suggestion on this? thank.

+3


source to share


1 answer


Are you using gcc

or clang

or something that behaves similarly? They have __attribute__((__may_alias__))

to work around these problems.



0


source







All Articles