[flang-commits] [flang] [flang][fir] fix fir.if canonicalization pattern from #205353 (PR #205757)
via flang-commits
flang-commits at lists.llvm.org
Thu Jun 25 07:48:19 PDT 2026
================
@@ -5736,7 +5736,11 @@ struct FoldPresentAbsentIfOp : public mlir::OpRewritePattern<fir::IfOp> {
auto elseResult = mlir::dyn_cast<fir::ResultOp>(elseBlock.getTerminator());
if (!elseResult || elseResult.getNumOperands() != 1)
return mlir::failure();
- if (!elseResult.getOperand(0).getDefiningOp<fir::AbsentOp>())
+ auto absentOp = elseResult.getOperand(0).getDefiningOp<fir::AbsentOp>();
+ if (!absentOp)
+ return mlir::failure();
+ if (elseBlock.getOperations().size() == 2 &&
----------------
jeanPerier wrote:
The case where `elseBlock.getOperations().size() > 2` is covered above on line 5734. Here we only need to check that when there are two operations, the first one is the fir.absent (but it is also OK to have only the yield if the fir.absent was csed with another one above for instance).
https://github.com/llvm/llvm-project/pull/205757
More information about the flang-commits
mailing list