[1/11][IR] Permit load/store/alloca for struct of the same scalable vector type
authoreopXD <yueh.ting.chen@gmail.com>
Thu, 23 Mar 2023 08:51:39 +0000 (01:51 -0700)
committereopXD <yueh.ting.chen@gmail.com>
Fri, 19 May 2023 16:39:36 +0000 (09:39 -0700)
commitc8eb535aed0368c20b25fe05bca563ab38dd91e9
tree8a2b1d6e9853b9498c3cfb58cb47afa9d251fec8
parentdae175423a07fbc63cf9d996751609361493f925
[1/11][IR] Permit load/store/alloca for struct of the same scalable vector type

This patch-set aims to simplify the existing RVV segment load/store
intrinsics to use a type that represents a tuple of vectors instead.

To achieve this, first we need to relax the current limitation for an
aggregate type to be a target of load/store/alloca when the aggregate
type contains homogeneous scalable vector types. Then to adjust the
prolog of an LLVM function during lowering to clang. Finally we
re-define the RVV segment load/store intrinsics to use the tuple types.

The pull request under the RVV intrinsic specification is
riscv-non-isa/rvv-intrinsic-doc#198

---

This is the 1st patch of the patch-set. This patch is originated from
D98169.

This patch allows aggregate type (StructType) that contains homogeneous
scalable vector types to be a target of load/store/alloca. The RFC of
this patch was posted in LLVM Discourse.

https://discourse.llvm.org/t/rfc-ir-permit-load-store-alloca-for-struct-of-the-same-scalable-vector-type/69527

The main changes in this patch are:

Extend `StructLayout::StructSize` from `uint64_t` to `TypeSize` to
accommodate an expression of scalable size.

Allow `StructType:isSized` to also return true for homogeneous
scalable vector types.

Let `Type::isScalableTy` return true when `Type` is `StructType`
and contains scalable vectors

Extra description is added in the LLVM Language Reference Manual on the
relaxation of this patch.

Authored-by: Hsiangkai Wang <kai.wang@sifive.com>
Co-Authored-by: eop Chen <eop.chen@sifive.com>
Reviewed By: craig.topper, nikic

Differential Revision: https://reviews.llvm.org/D146872
23 files changed:
llvm/docs/LangRef.rst
llvm/include/llvm/CodeGen/Analysis.h
llvm/include/llvm/IR/DataLayout.h
llvm/include/llvm/IR/DerivedTypes.h
llvm/include/llvm/IR/Type.h
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/CodeGen/Analysis.cpp
llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/IR/DataLayout.cpp
llvm/lib/IR/Type.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/lib/Transforms/Scalar/SROA.cpp
llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
llvm/test/Assembler/scalable-vector-struct.ll [new file with mode: 0644]
llvm/test/CodeGen/AArch64/sme-aarch64-svcount.ll
llvm/test/CodeGen/RISCV/rvv/alloca-load-store-scalable-struct.ll [new file with mode: 0644]
llvm/test/Transforms/InstCombine/scalable-vector-struct.ll [new file with mode: 0644]
llvm/test/Transforms/SROA/scalable-vector-struct.ll [new file with mode: 0644]
llvm/test/Verifier/scalable-vector-struct-gep.ll [new file with mode: 0644]