[Mlir-commits] [mlir] [mlir][scf] Align `scf.while` `before` block args in canonicalizer (PR #76195)
Ivan Butygin
llvmlistbot at llvm.org
Fri Dec 22 12:29:04 PST 2023
================
@@ -3872,14 +3872,89 @@ struct WhileRemoveDuplicatedResults : public OpRewritePattern<WhileOp> {
return success();
}
};
+
+/// If both ranges contain same values return mappping indices from args1 to
+/// args2. Otherwise return std::nullopt
+static std::optional<SmallVector<unsigned>> getArgsMapping(ValueRange args1,
+ ValueRange args2) {
+ if (args1.size() != args2.size())
+ return std::nullopt;
+
+ SmallVector<unsigned> ret(args1.size());
+ for (auto &&[i, arg1] : llvm::enumerate(args1)) {
+ auto it = llvm::find(args2, arg1);
----------------
Hardcode84 wrote:
One of the args is block args so it will never contain duplicates, the other is `scf.condition` args. There is a pattern to cleanup duplicated `scf.condition` args, but order in which patterns are applied is undetermined. I can add a code to check for duplicated `scf.condition` args and bail out.
https://github.com/llvm/llvm-project/pull/76195
More information about the Mlir-commits
mailing list