[PATCH] D73244: [mlir] Fix vectorize transform crashing on none-op operand

Ahmed S. Taei via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 22 17:59:26 PST 2020


asaadaldien updated this revision to Diff 239752.
asaadaldien added a comment.

use dyn_cast_or_null


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73244/new/

https://reviews.llvm.org/D73244

Files:
  mlir/lib/Transforms/Vectorize.cpp


Index: mlir/lib/Transforms/Vectorize.cpp
===================================================================
--- mlir/lib/Transforms/Vectorize.cpp
+++ mlir/lib/Transforms/Vectorize.cpp
@@ -1003,7 +1003,7 @@
     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 @@
     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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73244.239752.patch
Type: text/x-patch
Size: 849 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200123/1b0eaca4/attachment.bin>


More information about the llvm-commits mailing list