[llvm] [SPIRV] Handle ptrcast between array and vector types (PR #166418)
Nathan Gauër via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 6 08:28:05 PST 2025
================
@@ -116,6 +116,85 @@ class SPIRVLegalizePointerCast : public FunctionPass {
return LI;
}
+ // Loads elements from an array and constructs a vector.
+ Value *loadVectorFromArray(IRBuilder<> &B, FixedVectorType *TargetType,
+ ArrayType *SourceType, Value *Source) {
+ // Ensure the element types of the array and vector are the same.
+ assert(TargetType->getElementType() == SourceType->getElementType() &&
+ "Element types of array and vector must be the same.");
+
+ // Load each element of the array.
+ SmallVector<Value *, 4> LoadedElements;
+ for (unsigned i = 0; i < TargetType->getNumElements(); ++i) {
----------------
Keenuts wrote:
Are we sure the source type always has enough elements?
(related question: is the spv_gep always inbounds as specified in both functions?)
https://github.com/llvm/llvm-project/pull/166418
More information about the llvm-commits
mailing list