match.pd: Fold zero test for .CLZ/.CTZ over vector modes
GCC's pattern matching now simplifies zero checks for CLZ/CTZ operations on vector types, improving instruction selection.
This commit extends the simplification of zero tests for count-leading-zeros (.CLZ) and count-trailing-zeros (.CTZ) operations from scalar types to vector types. Additionally, it updates documentation to clarify that .CLZ/.CTZ can accept an optional second argument specifying the value returned when the input is zero. A test case for s390 has been adapted to this change.
In Details
The match.pd file contains pattern definitions for instruction selection. This change enhances the IFN_CLZ and IFN_CTZ (insn-specific functions) to recognize and simplify zero-input cases for vector data types, mirroring existing scalar optimizations. This allows the backend to generate more efficient code by folding these checks into the instruction patterns, potentially avoiding conditional branches. The documentation update clarifies the behavior for at-zero values.
- .CLZ
- An intrinsic or pattern representing the count-leading-zeros operation, which calculates the number of zero bits from the most significant bit down to the first set bit.
- .CTZ
- An intrinsic or pattern representing the count-trailing-zeros operation, which calculates the number of zero bits from the least significant bit up to the first set bit.
- vector modes
- Data types that represent multiple scalar values packed together, allowing for SIMD (Single Instruction, Multiple Data) operations that process multiple data elements in parallel.
- RTL
- Register Transfer Language, an intermediate representation used within GCC to represent code before it is translated into machine code. It describes data transfers between registers and memory.
- s390
- The architecture name for IBM's System/360 and its successors, including z/Architecture. GCC supports compilation for this platform.