diff --git a/mlir/lib/Transforms/Vectorize.cpp b/mlir/lib/Transforms/Vectorize.cpp --- a/mlir/lib/Transforms/Vectorize.cpp +++ b/mlir/lib/Transforms/Vectorize.cpp @@ -1003,7 +1003,10 @@ return nullptr; } // 3. vectorize constant. - if (auto constant = dyn_cast(operand.getDefiningOp())) { + auto operandOp = operand.getDefiningOp(); + if (!operandOp) + return nullptr; + if (auto constant = dyn_cast(operandOp)) { return vectorizeConstant( op, constant, VectorType::get(state->strategy->vectorSizes, operand.getType())); @@ -1037,6 +1040,8 @@ auto memRef = store.getMemRef(); auto value = store.getValueToStore(); auto vectorValue = vectorizeOperand(value, opInst, state); + if (!vectorValue) + return nullptr; ValueRange mapOperands = store.getMapOperands(); SmallVector indices;