[VectorCombine] Scalarize vector load/extract.
authorFlorian Hahn <flo@fhahn.com>
Mon, 24 May 2021 08:19:40 +0000 (09:19 +0100)
committerFlorian Hahn <flo@fhahn.com>
Mon, 24 May 2021 08:29:08 +0000 (09:29 +0100)
commit86497785d540e59eaca24bed4219ddec183cbc9b
treeadca64fb04357b8a01c8b241851e3a8cf2124675
parent058f384ae94ae0ac94441043804e4a25d338d483
[VectorCombine] Scalarize vector load/extract.

This patch adds a new combine that tries to scalarize chains of
`extractelement (load %ptr), %idx` to `load (gep %ptr, %idx)`. This is
profitable when extracting only a few elements out of a large vector.

At the moment, `store (extractelement (load %ptr), %idx), %ptr`
operations on large vectors result in huge code in the backend.

This can easily be triggered by using the matrix extension, e.g.
https://clang.godbolt.org/z/qsccPdPf4

This should complement D98240.

Reviewed By: spatel

Differential Revision: https://reviews.llvm.org/D100273
llvm/lib/Transforms/Vectorize/VectorCombine.cpp
llvm/test/Transforms/VectorCombine/AArch64/load-extractelement-scalarization.ll
llvm/test/Transforms/VectorCombine/X86/load-inseltpoison.ll
llvm/test/Transforms/VectorCombine/X86/load.ll