[Mlir-commits] [mlir] [mlir] Fix block merging (PR #102038)

Christian Ulmann llvmlistbot at llvm.org
Mon Aug 5 22:57:14 PDT 2024


================
@@ -818,6 +918,108 @@ static LogicalResult mergeIdenticalBlocks(RewriterBase &rewriter,
   return success(anyChanged);
 }
 
+static LogicalResult dropRedundantArguments(RewriterBase &rewriter,
+                                            Block &block) {
+  SmallVector<size_t> argsToErase;
+
+  // Go through the arguments of the block.
+  for (auto [argIdx, blockOperand] : llvm::enumerate(block.getArguments())) {
+    bool sameArg = true;
+    Value commonValue;
+
+    // Go through the block predecessor and flag if they pass to the block
+    // different values for the same argument.
+    for (auto predIt = block.pred_begin(), predE = block.pred_end();
+         predIt != predE; ++predIt) {
----------------
Dinistro wrote:

Can one not iterate over `block.getPredecessors()` with a range based loop?

https://github.com/llvm/llvm-project/pull/102038


More information about the Mlir-commits mailing list