This patch extends the existing combine nested if
combination canonicalization to also handle ifs which
yield values
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This needs to properly handle the cases where either the outer or the inner "scf.if" is missing the "else" block.
mlir/lib/Dialect/SCF/SCF.cpp | ||
---|---|---|
1768–1769 | llvm::append_range(elseYield, op.elseYield().getOperands()) should work | |
1771 | Nit: consider putting the operation name in quotes/backticks or prefixing it with scf. to make it easier to differentiate from the regular word that is also used here. | |
1777–1778 | It shouldn't be necessary to loop over operation results, tup.value().cast<OpResult>().getResultNumber() gives you the position of the result in the list. | |
1779 | There doesn't seem to be a check that nestedIf has the "else" block, so this may assert. | |
1780 | elseYield may be empty if op doesn't have an "else" block, which could lead to out-of-bounds access here. |
mlir/lib/Dialect/SCF/SCF.cpp | ||
---|---|---|
1802 | !empty() |
mlir/lib/Dialect/SCF/SCF.cpp | ||
---|---|---|
1779 | Mind adding this to a comment above the "for", it's not obvious from the context? |
llvm::append_range(elseYield, op.elseYield().getOperands()) should work