diff --git a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp index 33a77d7576ba7..2ee314e9fedfe 100644 --- a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp +++ b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp @@ -726,12 +726,14 @@ struct DecomposePrintOpConversion : public VectorToSCFPattern { auto targetVectorType = vectorType.cloneWith({}, legalIntTy); value = rewriter.create(loc, signlessSourceVectorType, value); - if (width == 1 || intTy.isUnsigned()) - value = rewriter.create(loc, signlessTargetVectorType, - value); - else - value = rewriter.create(loc, signlessTargetVectorType, - value); + if (value.getType() != signlessTargetVectorType) { + if (width == 1 || intTy.isUnsigned()) + value = rewriter.create(loc, signlessTargetVectorType, + value); + else + value = rewriter.create(loc, signlessTargetVectorType, + value); + } value = rewriter.create(loc, targetVectorType, value); vectorType = targetVectorType; }