[llvm] [VectorCombine] Fold ZExt/SExt (Shuffle (ZExt/SExt %src)) to ZExt/SExt (Shuffle %src). (PR #141109)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 4 11:27:22 PDT 2025
https://github.com/fhahn commented:
> Two high level comments:
>
> 1. Why does this need to be a single unified transform? It really seems like the scalar-load+insert+bitcast --> vector load, and the ext+shuffle+ext are independent transforms. Is there a reason these can't be separated?
>
Thanks, they can be separated. I generalized the pattern in the patch to just fold the extends and shuffle. Folding the scalar load to a vector load should already be done in the backend. Folding the extends together makes it easier to scalarize them if needed (will share a follow-up soon).
> 2. All of your tests appear to use identity shuffles. Those can just be removed. Once that's done, we have two adjacent extends, which should already be handled? Either your tests need updated, or there's something off here?
I may be missing something, but the shuffles are needed to extract half the vector elements. In the current version, I create a new shuffle of the narrower vector type, which is trivially fold-able by instcombine for the test cases.
https://github.com/llvm/llvm-project/pull/141109
More information about the llvm-commits
mailing list