How to use x86intrin.h

In one of my applications, I need to efficiently de-move bits in a long data stream. Ideally, I would like to use the built-in BMI2 pext_u32()and / or pext_u64()x86_64 instructions when available. I browsed the internet for the doc on x86intrin.h( GCC ), but could not find much on this subject; so I ask the StackOverflow guru to help me.

  • Where can I find documentation on how to work with functions in x86intrin.h?
  • Does the gcc implementation pext_*()already have code behind it to return, or do I need to write the backup code myself (for conditional compilation)?
  • Is it possible to write a binary file that automatically returns to an alternative implementation if the target does not support the internal one? If so, how to do it?
  • Is there a well-known programming pattern that GCC will recognize and automatically convert to pext_*()when compiled with optimization turned on and -mbmi2?
+4
source share
2 answers

Intel publishes Feature Guide , which also applies to GCC. You will have to write your own backup code if you use these built-in functions.

You can achieve automatic implementation switching using IFUNC resolvers , but for non-library code, using conditional expressions or function pointers is probably easier.

gcc/config/i386/i386.md gcc/config/i386/i386.c, GCC 8, pext .

+3

Intel intrinsics , , . , ().

Intel intrinsics GNU C __builtin_popcountll ( , -mpopcnt, .)

+1

Source: https://habr.com/ru/post/1695623/


All Articles