[mlir] Fix vectorize transform crashing on none-op operand
authorAhmed Taei <ataei@google.com>
Thu, 23 Jan 2020 01:52:16 +0000 (17:52 -0800)
committerAhmed Taei <ataei@google.com>
Thu, 23 Jan 2020 17:57:16 +0000 (09:57 -0800)
mlir/lib/Transforms/Vectorize.cpp

index 9b64311..617a753 100644 (file)
@@ -1003,7 +1003,7 @@ static Value vectorizeOperand(Value operand, Operation *op,
     return nullptr;
   }
   // 3. vectorize constant.
-  if (auto constant = dyn_cast<ConstantOp>(operand.getDefiningOp())) {
+  if (auto constant = dyn_cast_or_null<ConstantOp>(operand.getDefiningOp())) {
     return vectorizeConstant(
         op, constant,
         VectorType::get(state->strategy->vectorSizes, operand.getType()));
@@ -1037,6 +1037,8 @@ static Operation *vectorizeOneOperation(Operation *opInst,
     auto memRef = store.getMemRef();
     auto value = store.getValueToStore();
     auto vectorValue = vectorizeOperand(value, opInst, state);
+    if (!vectorValue)
+      return nullptr;
 
     ValueRange mapOperands = store.getMapOperands();
     SmallVector<Value, 8> indices;