[llvm] [InstCombine] Simple store-to-load forwaring between fixed/scalable vectors (PR #124577)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 28 00:31:12 PST 2025


iamlouk wrote:

> > The @llvm.vector.insert is matched instead of the load itself because it is
> > invalid to create a temporary insert of a scalable vector (the stored
> > value) into a fixed-sized vector (the load type).
> 
> I don't really understand this part. Can't we replace the load with an llvm.vector.extract? And then for your particular pattern the llvm.vector.extract + llvm.vector.insert pair will fold away?

Sorry for not thinking of that myself, but yes, using a temporary `@llvm.vector.extract` instead of the temporary `@llvm.vector.insert` like I had tried absolutely does work, example: https://godbolt.org/z/xW9TssWhM .

I will rewrite this patch to create a temporary `@llvm.vector.extract` and to match at the load in GVN. I will open a new MR and close this one in the next two days, unless it is prefered to force-push into this existing MR.

Thank you very much for having had a look nikic, and sorry for not going the extract+GVN route directly.

https://github.com/llvm/llvm-project/pull/124577


More information about the llvm-commits mailing list