rs6000: Emit better code for parity in DImode
Generates more efficient code for the __builtin_parityll intrinsic on PowerPC by using the popcntd instruction.
This change improves code generation for the __builtin_parityll intrinsic on PowerPC targets. Previously, even when the popcntd instruction was available, the compiler emitted a less efficient sequence. Now, it utilizes popcntd directly when supported, reducing instruction latency and improving performance for parity checks on 64-bit integers.
In Details
This commit optimizes the emission of __builtin_parityll for DImode on rs6000. It replaces a sequence involving popcntb, prtyd, and extsw with a direct use of the popcntd instruction when available (version 2.06 and later). This leverages the hardware capability for faster parity calculation on 64-bit values, avoiding unnecessary intermediate operations.
- DImode
- GCC's internal representation mode for a double integer, typically 64 bits.
- popcntd
- A PowerPC instruction that counts the number of set bits (population count) in a doubleword (64-bit) register.
- __builtin_parityll
- A GCC intrinsic function that computes the parity of a 64-bit unsigned long long integer. Parity is 1 if the number of set bits is odd, and 0 if even.