[clang] [llvm] [SROA] Vector promote some memsets (PR #133301)

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 14 09:29:35 PDT 2025


nikic wrote:

> > I don't think your general approach here is going to work. We need to be careful about introducing vector operations out of thin air, because LLVM is not going to second guess them. If you convert a memset to <32768 x i8> ops here, LLVM is going to carry those all they down, even though this is almost certainly not performant. Additionally, you are breaking the ability for SROA to split the alloca and fully promote parts of it.
> 
> Is there an appropriate place in the code to decide if a splittable memset should be promoted to a vector operation?

Basically: We should only do it if there already is an existing vector operation. If we have a memset and then a later load of e.g. `<16 x i8>`, then lowering the memset to `store <16 x i8> zeroinitializer` makes sense. But if we only have scalar operations, we should not be introducing vectors in SROA.

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


More information about the cfe-commits mailing list