[llvm] [LV] Improve materialisation of VFxUF for scalable vectors (PR #216708)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 19 01:56:52 PDT 2026
david-arm wrote:
> Is it a complex fold? All we need is mul (shl) extending the existing one. With iterative combines, it can be changed to shl(shl), but we still need the same match. The below should be sufficient to cover all cases in this PR + a few more.
But after adding this extra fold, the set of folds for all possible permutations will surely still be incomplete? At some point we'll still end up needing to either:
1. Support all combinations of shl(mul(X, 4), 2), mul(mul(X, 4), 4), shl(shl(X, 2), 2) and mul(shl(X, 2), 4) (because we only get one chance at simplification), or
2. Support iterative simplification so the first round of simplifications can canonicalise all multiplies of power-of-2 into shl, and the second round then only ever has to check shl(shl(X, 2), 2). I think this is how instcombine works - canonicalises first, optimises second. This approach has the advantage of drastically reducing the required complexity of `simplifyRecipe` to support all permutations for folds of all kinds. Given that vplan has already reimplemented/replicated many middle-end IR optimisations in line with IR passes such as CSE, InstCombine, LICM, DCE, etc. perhaps it makes sense to be consistent with how those passes work?
https://github.com/llvm/llvm-project/pull/216708
More information about the llvm-commits
mailing list