[MLIR][Standard] Fix use of `dyn_cast_or_null`
authorFrederik Gossen <frgossen@google.com>
Tue, 16 Jun 2020 21:04:57 +0000 (21:04 +0000)
committerFrederik Gossen <frgossen@google.com>
Tue, 16 Jun 2020 21:06:15 +0000 (21:06 +0000)
The value may be a function argument in which case `getDefiningOp` will return a
`nullptr`.

Differential Revision: https://reviews.llvm.org/D81965

mlir/lib/Dialect/StandardOps/IR/Ops.cpp

index dd67f2d..ca4fe83 100644 (file)
@@ -1703,8 +1703,8 @@ struct ExtractElementFromTensorFromElements
     if (extract.indices().size() != 1)
       return failure();
 
-    auto tensor_from_elements =
-        dyn_cast<TensorFromElementsOp>(extract.aggregate().getDefiningOp());
+    auto tensor_from_elements = dyn_cast_or_null<TensorFromElementsOp>(
+        extract.aggregate().getDefiningOp());
     if (tensor_from_elements == nullptr)
       return failure();