Issue 145300
Summary [mlir] How to test folding an op "once"
Labels mlir
Assignees
Reporter yangtetris
    This issue originates from [PR #142124](https://github.com/llvm/llvm-project/pull/142124). Currently, the canonicalizer is the most widely used approach for testing folders. However, when people want to test the specific behavior of a folder, such as ensuring its efficiency, the canonicalizer seems somewhat inappropriate because it will repeatedly apply the folder until the corresponding op can no longer be folded. I have tried the `max-iterations` option, but it doesn't seem to work for folding. The reason might be in this [code](https://github.com/llvm/llvm-project/blob/714b2fdf3a385e5b9a95c435f56b1696ec3ec9e8/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp#L499-L508) - when an op is folded in place, it gets re-added to the worklist, so it can still be folded multiple times within a single iteration.
```cpp
if (foldResults.empty()) {
    // Op was modified in-place.
 notifyOperationModified(op);
```
PR #142124 worked around this testing issue by renaming the existing TestConstantFold pass to TestSingleFold. But I'm wondering if there are better ways to achieve the "fold once" purpose. Any thoughts or suggestions on would be greatly appreciated.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to