Match.pd now handles BUILT_IN_BITREVERSE8 like the other bitreverses.
GCC's pattern-matching pass now recognises `__builtin_bitreverse8` when optimising bit-reversal operations.
GCC’s pattern matching pass (match.pd) missed BUILT_IN_BITREVERSE8 when optimizing bit-reversal operations; this commit adds it to the BITREVERSE operator list. The change comes with additional test cases for __builtin_bitreverse{8,16,64,128}.
In Details
The match.pd file in GCC defines patterns for tree-based optimizations. BUILT_IN_BITREVERSE* are compiler intrinsics for reversing the bits in an integer. The pattern-matching pass uses these patterns to identify opportunities to replace generic code with optimized bit-reversal implementations. This patch modifies the BITREVERSE macro in match.pd to include BUILT_IN_BITREVERSE8.
For Context
Compilers often include built-in functions that map directly to specific CPU instructions or optimized library routines. These builtins can expose hardware features or provide performance benefits. To take advantage, the compiler needs to recognise these builtins during optimization. This commit updates GCC's pattern-matching pass to recognise the __builtin_bitreverse8 intrinsic, which reverses the order of bits in a byte, allowing the compiler to generate more efficient code when this operation is used.