[Mlir-commits] [mlir] [mlir][cf] Canonicalize block args with uniform incoming values (PR #183966)
Matthias Springer
llvmlistbot at llvm.org
Tue Mar 3 08:21:13 PST 2026
================
@@ -204,9 +204,81 @@ static LogicalResult simplifyPassThroughBr(BranchOp op,
return success();
}
+/// If all incoming values for a block argument from all predecessors are the
+/// same SSA value, replace uses of the block argument with that value. This
+/// allows the block argument to be removed by dead code elimination.
+///
+/// %c = arith.constant 0 : i32
+/// cf.br ^bb1(%c : i32) // pred 1
+/// cf.br ^bb1(%c : i32) // pred 2
+/// ^bb1(%arg0: i32):
+/// use(%arg0)
+/// ->
+/// ^bb1(%arg0: i32):
+/// use(%c) // %arg0 has no uses and can be removed
+///
+static bool simplifyUniformBlockArgs(Block *dest, PatternRewriter &rewriter) {
----------------
matthias-springer wrote:
For consistency, this should return `LogicalResult` like the other functions.
https://github.com/llvm/llvm-project/pull/183966
More information about the Mlir-commits
mailing list