From 2a4e7c3f49d4629bf850ba4a6cb98e82aee12984 Mon Sep 17 00:00:00 2001 From: xlauko Date: Fri, 31 Jan 2025 10:35:18 +0100 Subject: [PATCH] pr: Fix cond yield conversion --- lib/vast/Conversion/Parser/ToParser.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/vast/Conversion/Parser/ToParser.cpp b/lib/vast/Conversion/Parser/ToParser.cpp index 41096d20e1..ade78ee9d5 100644 --- a/lib/vast/Conversion/Parser/ToParser.cpp +++ b/lib/vast/Conversion/Parser/ToParser.cpp @@ -588,14 +588,24 @@ namespace vast::conv { logical_result matchAndRewrite( op_t op, adaptor_t adaptor, conversion_rewriter &rewriter ) const override { - auto operand = adaptor.getResult().getDefiningOp(); - if (auto cast = mlir::dyn_cast< mlir::UnrealizedConversionCastOp >(operand)) { + auto operand = adaptor.getResult(); + + if (auto cast = mlir::dyn_cast< mlir::UnrealizedConversionCastOp >(operand.getDefiningOp())) { if (pr::is_parser_type(cast.getOperand(0).getType())) { rewriter.replaceOpWithNewOp< op_t >(op, cast.getOperand(0)); return mlir::success(); } } + if (pr::is_parser_type(operand.getType())) { + rewriter.replaceOpWithNewOp< op_t >(op, operand); + return mlir::success(); + } + + auto cast = rewriter.create< mlir::UnrealizedConversionCastOp >( + op.getLoc(), pr::MaybeDataType::get(op.getContext()), operand + ); + rewriter.replaceOpWithNewOp< op_t >(op, cast.getResult(0)); return mlir::success(); }