[all-commits] [llvm/llvm-project] cbb24e: [LLVM][IR] Add native vector support to ConstantIn...
Paul Walker via All-commits
all-commits at lists.llvm.org
Thu Feb 22 06:07:28 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: cbb24e139d0753d755d17fbe6bfac48ab44d0721
https://github.com/llvm/llvm-project/commit/cbb24e139d0753d755d17fbe6bfac48ab44d0721
Author: Paul Walker <paul.walker at arm.com>
Date: 2024-02-22 (Thu, 22 Feb 2024)
Changed paths:
M llvm/include/llvm/IR/Constants.h
M llvm/lib/Bitcode/Reader/BitcodeReader.cpp
M llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
M llvm/lib/IR/AsmWriter.cpp
M llvm/lib/IR/Constants.cpp
M llvm/lib/IR/LLVMContextImpl.cpp
M llvm/lib/IR/LLVMContextImpl.h
A llvm/test/Bitcode/constant-splat.ll
Log Message:
-----------
[LLVM][IR] Add native vector support to ConstantInt & ConstantFP. (#74502)
NOTE: For brevity the following talks about ConstantInt but
everything extends to cover ConstantFP as well.
Whilst ConstantInt::get() supports the creation of vectors whereby
each lane has the same value, it achieves this via other constants:
* ConstantVector for fixed-length vectors
* ConstantExprs for scalable vectors
However, ConstantExprs are being deprecated and ConstantVector is
not space efficient for larger vector types. By extending ConstantInt
we can represent vector splats by only storing the underlying scalar
value.
More specifically:
* ConstantInt gains an ElementCount variant of get().
* LLVMContext is extended to map <EC,APInt>->ConstantInt.
* BitcodeReader/Writer support is extended to allow vector types.
Whilst this patch adds the base support, more work is required
before it's production ready. For example, there's likely to be
many places where isa<ConstantInt> assumes a scalar type. Accordingly
the default behaviour of ConstantInt::get() remains unchanged but a
set of flags are added to allow wider testing and thus help with the
migration:
--use-constant-int-for-fixed-length-splat
--use-constant-fp-for-fixed-length-splat
--use-constant-int-for-scalable-splat
--use-constant-fp-for-scalable-splat
NOTE: No change is required to the bitcode format because types and
values are handled separately.
NOTE: For similar reasons as above, code generation doesn't work
out-the-box.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list