[Mlir-commits] [mlir] [mlir] [scf] fix crash when conversion from scf to control flow (PR #107221)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Sep 4 04:07:50 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: donald chen (cxy-1993)
<details>
<summary>Changes</summary>
This patch fixed a crash when scf.parallel's region donesn't terminate with reduce op. This can happend in dialect conversion.
---
Full diff: https://github.com/llvm/llvm-project/pull/107221.diff
1 Files Affected:
- (modified) mlir/lib/Conversion/SCFToControlFlow/SCFToControlFlow.cpp (+4-1)
``````````diff
diff --git a/mlir/lib/Conversion/SCFToControlFlow/SCFToControlFlow.cpp b/mlir/lib/Conversion/SCFToControlFlow/SCFToControlFlow.cpp
index 2372ab5b82a772..45f3bcfa393be8 100644
--- a/mlir/lib/Conversion/SCFToControlFlow/SCFToControlFlow.cpp
+++ b/mlir/lib/Conversion/SCFToControlFlow/SCFToControlFlow.cpp
@@ -482,7 +482,10 @@ LogicalResult
ParallelLowering::matchAndRewrite(ParallelOp parallelOp,
PatternRewriter &rewriter) const {
Location loc = parallelOp.getLoc();
- auto reductionOp = cast<ReduceOp>(parallelOp.getBody()->getTerminator());
+ auto reductionOp = dyn_cast<ReduceOp>(parallelOp.getBody()->getTerminator());
+ if (!reductionOp) {
+ return failure();
+ }
// For a parallel loop, we essentially need to create an n-dimensional loop
// nest. We do this by translating to scf.for ops and have those lowered in
``````````
</details>
https://github.com/llvm/llvm-project/pull/107221
More information about the Mlir-commits
mailing list