Scalarizer: limit scalarization for small element types
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Fri, 2 Dec 2022 02:15:13 +0000 (03:15 +0100)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Tue, 13 Jun 2023 19:14:32 +0000 (21:14 +0200)
commit2cb5c6d124d64344fd91eb769438fb81367bb266
treef94fd81d82e4ee8013eb529f3743ba0f2de0d539
parentfc7e60f1f6749e9620f9005e740a8e1ec3cb9298
Scalarizer: limit scalarization for small element types

Scalarization can expose optimization opportunities for the individual
elements of a vector, and can therefore be beneficial on targets like
GPUs that tend to operate on scalars anyway.

However, notably with 16-bit operations it is often beneficial to keep
<2 x i16 / half> vectors around since there are packed instructions for
those.

Refactor the code to operate on "fragments" of split vectors. The
fragments are usually scalars, but may themselves be smaller vectors
when the scalarizer-min-bits option is used. If the split is uneven,
the last fragment is a shorter remainder.

This is almost NFC when the new option is unused, but it happens to
clean up some code in the fully scalarized case as well.

Differential Revision: https://reviews.llvm.org/D149842
llvm/include/llvm/Transforms/Scalar/Scalarizer.h
llvm/lib/Transforms/Scalar/Scalarizer.cpp
llvm/test/Transforms/Scalarizer/basic-inseltpoison.ll
llvm/test/Transforms/Scalarizer/basic.ll
llvm/test/Transforms/Scalarizer/min-bits.ll
llvm/test/Transforms/Scalarizer/opaque-ptr-bug.ll
llvm/test/Transforms/Scalarizer/vector-gep.ll