[PATCH] D149842: Scalarizer: limit scalarization for small element types

Nicolai Hähnle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 4 04:42:18 PDT 2023


nhaehnle created this revision.
nhaehnle added reviewers: foad, fhahn, arsenm, nikic.
Herald added subscribers: nlopes, StephenFan, hiraditya.
Herald added a project: All.
nhaehnle requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149842

Files:
  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/constant-insertelement.ll
  llvm/test/Transforms/Scalarizer/intrinsics.ll
  llvm/test/Transforms/Scalarizer/min-bits.ll
  llvm/test/Transforms/Scalarizer/opaque-ptr-bug.ll
  llvm/test/Transforms/Scalarizer/order-bug-inseltpoison.ll
  llvm/test/Transforms/Scalarizer/order-bug.ll
  llvm/test/Transforms/Scalarizer/phi-order.ll
  llvm/test/Transforms/Scalarizer/scatter-order.ll
  llvm/test/Transforms/Scalarizer/variable-extractelement.ll
  llvm/test/Transforms/Scalarizer/variable-insertelement.ll
  llvm/test/Transforms/Scalarizer/vector-gep.ll
  llvm/test/Transforms/Scalarizer/vector-of-pointer-to-vector.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149842.519441.patch
Type: text/x-patch
Size: 247672 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230504/6304211a/attachment-0001.bin>


More information about the llvm-commits mailing list