llvm-project
467390e7 - [InstCombine] Skip redundant demanded element queries in insert chains (#205948)

Commit
2 days ago
[InstCombine] Skip redundant demanded element queries in insert chains (#205948) Avoid re-running `SimplifyDemandedVectorElts` on intermediate `insertelement` chain nodes when a bounded scan proves the top-level all-lanes query cannot change the IR. The skip is implemented inside the `InsertElement` case of `SimplifyDemandedVectorElts` and is limited to the top-level all-lanes query (`Depth == 0 && DemandedElts.isAllOnes()`). The bounded scan matches the existing SDVE depth window and only skips chains with distinct in-range constant insert indices. This keeps the normal SDVE path for duplicate indices, variable indices, out-of-range indices, multi-use chains, and the final chain root. This was motivated by a cutile matmul compile-time case where loop unrolling produced 128-lane vector insert/extract chains. Before this change, InstCombine repeatedly invoked SDVE on intermediate `insertelement` nodes in those chains. On the representative IR, the affected InstCombine pass time went from about `44.9 ms` to `29.8 ms`, and total `opt` compile time was reduced by about 20%. AI disclosure: This patch was developed with assistance from @openai-codex using GPT-5.5 via [Codex](https://openai.com/codex/). I reviewed and tested the final changes before submission.
Author
Parents
Loading