[PATCH] D149967: [AArch64][SVE] Enable shouldFoldSelectWithIdentityConstant for SVE.

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 14 03:30:04 PDT 2023


dmgreen added a comment.

The argument may not apply as well to SVE as much as it does to over architectures. The general pattern for a predicated vector operation is `select(cond, binop(a, b), passthru)`, where a==passthru is a special case and gets transformed by instcombine to `binop(select(cond, a, identity), b)`. If the backend already has patterns for the `select(binop` form then the special case with identity isn't helpful, and it is better to canonicalize it back to select(binop. With SVE, my understanding is that this should often be handled via movpfx if it is fast enough.

I'm not sure I buy the one-use argument. We already know that we have a predicated operation so in general want to produce a single instruction, and that the instructions were not previously optimized by instcombine. Most major architectures already use shouldFoldSelectWithIdentityConstant and it seems unlikely that there would be many folds that we want that were not already handled. Using shouldFoldSelectWithIdentityConstant will be simpler and less error prone, especially around floating point patterns with multiple possible identity values around zero.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149967/new/

https://reviews.llvm.org/D149967



More information about the llvm-commits mailing list