[Mlir-commits] [mlir] [mlir][vector][spirv] Handle 1-element vector.{load|store} lowering. (PR #126294)
Md Abdullah Shahneous Bari
llvmlistbot at llvm.org
Fri Feb 7 13:30:23 PST 2025
================
@@ -770,10 +770,20 @@ struct VectorLoadOpConverter final
spirv::StorageClass storageClass = attr.getValue();
auto vectorType = loadOp.getVectorType();
- auto vectorPtrType = spirv::PointerType::get(vectorType, storageClass);
- Value castedAccessChain =
- rewriter.create<spirv::BitcastOp>(loc, vectorPtrType, accessChain);
- rewriter.replaceOpWithNewOp<spirv::LoadOp>(loadOp, vectorType,
+ // Use the converted vector type instead of original (single element vector
+ // would get converted to scalar).
+ auto spirvVectorType = typeConverter.convertType(vectorType);
+ auto vectorPtrType = spirv::PointerType::get(spirvVectorType, storageClass);
+
+ // For single element vectors, we don't need to bitcast the access chain to
+ // the original vector type. Both is going to be the same, a pointer
+ // to a scalar.
+ Value castedAccessChain = (vectorType.getNumElements() == 1)
+ ? accessChain
+ : rewriter.create<spirv::BitcastOp>(
+ loc, vectorPtrType, accessChain);
----------------
mshahneo wrote:
No problem at all :)
https://github.com/llvm/llvm-project/pull/126294
More information about the Mlir-commits
mailing list