Skip to content

Commit 1025e2b

Browse files
committed
Check for type conversion failures
1 parent 7a7ecaf commit 1025e2b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

mlir/lib/Conversion/AMDGPUToROCDL/AMDGPUToROCDL.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,7 +1718,8 @@ LogicalResult ScaledExtPacked816OpLowering::matchAndRewrite(
17181718
LLVM::BitcastOp::create(rewriter, loc, i32, adaptor.getScale());
17191719

17201720
Value source = adaptor.getSource();
1721-
Type packedType;
1721+
Type llvmResultType = typeConverter->convertType(op.getResult().getType());
1722+
Type packedType = nullptr;
17221723
if (isa<fp4>(srcElemType)) {
17231724
packedType = i32;
17241725
packedType = getTypeConverter()->convertType(packedType);
@@ -1729,8 +1730,13 @@ LogicalResult ScaledExtPacked816OpLowering::matchAndRewrite(
17291730
packedType = VectorType::get(3, i32);
17301731
packedType = getTypeConverter()->convertType(packedType);
17311732
} else {
1732-
llvm_unreachable("invalid element type for scaled ext");
1733+
llvm_unreachable("invalid element type for packed scaled ext");
1734+
}
1735+
1736+
if (!packedType || !llvmResultType) {
1737+
return rewriter.notifyMatchFailure(op, "type conversion failed");
17331738
}
1739+
17341740
Value castedSource =
17351741
LLVM::BitcastOp::create(rewriter, loc, packedType, source);
17361742

@@ -1741,7 +1747,6 @@ LogicalResult ScaledExtPacked816OpLowering::matchAndRewrite(
17411747
"no intrinsic matching packed scaled conversion on the given chipset");
17421748

17431749
OperationState loweredOp(loc, *maybeIntrinsic);
1744-
Type llvmResultType = typeConverter->convertType(op.getResult().getType());
17451750
loweredOp.addTypes({llvmResultType});
17461751
loweredOp.addOperands({castedSource, castedScale});
17471752

0 commit comments

Comments
 (0)