[Mlir-commits] [mlir] [mlir][spirv] Handle vectors of integers of unsupported width (PR #118663)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Dec 4 08:19:06 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: Jakub Kuderski (kuhar)
<details>
<summary>Changes</summary>
Fixes: https://github.com/llvm/llvm-project/issues/118612
---
Full diff: https://github.com/llvm/llvm-project/pull/118663.diff
2 Files Affected:
- (modified) mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp (+7)
- (modified) mlir/test/Conversion/ArithToSPIRV/arith-to-spirv-unsupported.mlir (+8)
``````````diff
diff --git a/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp b/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
index f5700059f68ee2..d8b67bb4389ea2 100644
--- a/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
+++ b/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
@@ -299,6 +299,10 @@ convertScalarType(const spirv::TargetEnv &targetEnv,
/// supported integer types.
static Type convertSubByteIntegerType(const SPIRVConversionOptions &options,
IntegerType type) {
+ if (type.getWidth() > 8) {
+ LLVM_DEBUG(llvm::dbgs() << "not a subbyte type\n");
+ return nullptr;
+ }
if (options.subByteTypeStorage != SPIRVSubByteTypeStorage::Packed) {
LLVM_DEBUG(llvm::dbgs() << "unsupported sub-byte storage kind\n");
return nullptr;
@@ -348,6 +352,9 @@ convertVectorType(const spirv::TargetEnv &targetEnv,
}
Type elementType = convertSubByteIntegerType(options, intType);
+ if (!elementType)
+ return nullptr;
+
if (type.getRank() <= 1 && type.getNumElements() == 1)
return elementType;
diff --git a/mlir/test/Conversion/ArithToSPIRV/arith-to-spirv-unsupported.mlir b/mlir/test/Conversion/ArithToSPIRV/arith-to-spirv-unsupported.mlir
index 24a0bab352c345..9d7ab2be096ef7 100644
--- a/mlir/test/Conversion/ArithToSPIRV/arith-to-spirv-unsupported.mlir
+++ b/mlir/test/Conversion/ArithToSPIRV/arith-to-spirv-unsupported.mlir
@@ -60,6 +60,14 @@ func.func @int_vector4_invalid(%arg0: vector<2xi16>) {
return
}
+// -----
+
+func.func @int_vector_invalid_bitwidth(%arg0: vector<2xi12>) {
+ // expected-error @+1 {{failed to legalize operation 'arith.addi'}}
+ %0 = arith.addi %arg0, %arg0: vector<2xi12>
+ return
+}
+
///===----------------------------------------------------------------------===//
// Constant ops
//===----------------------------------------------------------------------===//
``````````
</details>
https://github.com/llvm/llvm-project/pull/118663
More information about the Mlir-commits
mailing list