llvm-project
f60eec59 - [VectorCombine] foldPermuteOfBinops - support multi-use binary ops and operands in shuffle folding (#173153)

Commit
9 days ago
[VectorCombine] foldPermuteOfBinops - support multi-use binary ops and operands in shuffle folding (#173153) Fixes #173033 This patch extends VectorCombine to fold binary operations through shuffles in scenarios involving multiple uses of both the binary operator and its operands. Previously, the transformation was restricted to single-use cases to prevent instruction duplication. This change implements a cost-based evaluation that allows the fold even when: 1. The binary operator has multiple users (requiring duplication of the arithmetic instruction). 2. The operands of the binary operator (the shuffles) have multiple users (requiring the original shuffles to be preserved). The optimization is performed if the TTI cost of the new instruction sequence—including any duplicated arithmetic—is lower than the cost of the shuffle sequence it replaces. This is particularly beneficial on X86 targets for expensive cross-lane shuffles.
Author
Parents
Loading