[llvm] [SPIRV] Handle ptrcast between array and vector types (PR #166418)
Steven Perron via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 7 16:48:51 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) {
----------------
s-perron wrote:
In bounds or not is a parameter to spv_gep.
If the target type has more elements, then we get an out-of-bounds access with undefined behaviour. However, the original access would have had undefined behaviour anyway.
https://github.com/llvm/llvm-project/pull/166418
More information about the llvm-commits
mailing list