i386: Implement bitreverse<mode>2 optab for GFNI
GCC now uses the GFNI instruction set to accelerate bit reversal operations on x86 when compiling with `-mgfni` and `-msse2`.
This commit enables the use of the GFNI instruction set for bit reversal operations on x86 when compiling with -mgfni and -msse2. It implements the bitreverse<mode>2 optab by using the gf2p8affineqb instruction with a special constant that reverses bits in each byte. For modes wider than QImode, a byteswap is also performed. This improves the performance of __builtin_bitreverse when targeting modern x86 processors.
In Details
This patch adds ix86_expand_gfni_bitreverse in i386-expand.cc and declares it in i386-protos.h. It introduces a new expander for bitreverse<mode>2 in i386.md. The implementation uses gf2p8affineqb for bit reversal and bswap for byte swapping in larger modes. This relies on the target having both GFNI and SSE2 support, and exposes a TARGET_USE_GFNI_BITREV macro.
For Context
Bit reversal is the operation of inverting the order of bits in a binary number. Modern x86 processors have special instructions like GFNI that can perform this operation more efficiently than traditional methods. This commit teaches GCC to use the GFNI instruction set when it's available, resulting in faster bit reversal operations. The compiler uses "optabs" to represent different ways of implementing operations, and this commit adds a new one for bit reversal using GFNI.