rs6000: Improve __builtin_bswap16 codegen on GPRs
rs6000 backend optimizes __builtin_bswap16 on pre-Power10 by using a rotate-insert idiom.
The code generation for __builtin_bswap16 on rs6000 pre-Power10 processors has been improved. Previously, it used a less optimal sequence of multiple rlwinm and or instructions. The new implementation employs a more efficient rotate-insert idiom, reducing the instruction count and improving performance.
In Details
The rs6000 backend's machine-dependent code generation for __builtin_bswap16 has been optimized for pre-Power10 CPUs. The pattern bswaphi2_reg in rs6000.md is updated to replace a sequence of rlwinm/or instructions with a more efficient slwi/rlwimi sequence. This change targets the specific pattern that handles 16-bit byte swaps when the input is in a general-purpose register.
- __builtin_bswap16
- A GCC intrinsic function that reverses the byte order of a 16-bit integer. It's used for endianness conversions.
- rlwinm
- A PowerPC instruction that rotates and masks bits in a word. It's a versatile instruction for bit manipulation.
- rotate-insert idiom
- A sequence of instructions that achieves a bit rotation and insertion efficiently, often by combining shifts and rotates.