CSE eliminates redundant scalar duplication at different vector widths.
CSE pass now matches and optimizes redundant vector duplications of scalars across different vector widths.
GCC’s Common Subexpression Elimination (CSE) pass now eliminates redundant scalar duplication instructions that arise from low-to-highpart builtins. Previously, identical scalars duplicated into vectors of different widths were placed in separate registers, leading to inefficiency. This fix enables CSE to match these duplicates, emit a single wider vector, and use SUBREGs for narrower uses, optimizing instruction count and potentially enabling single load instructions.
In Details
A fix in GCC's CSE pass addresses redundant vector duplication instructions generated by low-to-highpart builtins. When a scalar is duplicated into vectors of different widths but the same element size, CSE now identifies these matches during cse_prescan and cse_main. The wider duplication is emitted first, and narrower duplicates are converted to SUBREGs of this instruction, reducing register pressure and improving code density.
- CSE
- Common Subexpression Elimination, a compiler optimization that identifies and replaces identical expressions with a single temporary variable.
- low-to-highpart builtins
- Intrinsics or functions that extract a lower part of a vector and potentially use it to construct a higher part, often involving vector width conversions.
- SUBREG
- A subregister, which refers to a portion of a larger register, used in instruction scheduling and optimization to represent smaller data units.
- cse_prescan
- A preliminary scanning phase within the CSE optimization pass to identify potential common subexpressions.
- cse_main
- The main processing phase of the CSE optimization pass, where identified common subexpressions are replaced.