llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[MLIR] `remove-dead-values` misses a dead block argument

Open dev-816 opened this issue 3 months ago • 2 comments

In the following example, --remove-dead-values should remove the block argument %0 on line 4 because it is never used. However, the pass fails to remove it, resulting in a missed optimization opportunity.

Input Program

input.mlir

module {
  func.func @func_t8(%arg0: i32) -> i32 {
    cf.br ^bb1(%arg0 : i32)
  ^bb1(%0: i32):  // pred: ^bb0
    return %arg0 : i32
  }
}

Command

mlir-opt --remove-dead-values input.mlir

Version: ef88536bbf62469eb2396d719d237b3191cf4843

dev-816 avatar Aug 17 '26 06:08 dev-816

@llvm/issue-subscribers-mlir

Author: CC_Fans (dev-816)

In the following example, `--remove-dead-values` should remove the block argument `%0` on line 4 because it is never used. However, the pass fails to remove it, resulting in a missed optimization opportunity.

Input Program

input.mlir

module {
  func.func @<!-- -->func_t8(%arg0: i32) -&gt; i32 {
    cf.br ^bb1(%arg0 : i32)
  ^bb1(%0: i32):  // pred: ^bb0
    return %arg0 : i32
  }
}

Command

mlir-opt --remove-dead-values input.mlir

Version: ef88536bbf62469eb2396d719d237b3191cf4843

Hi, I've started working on this issue. Could you please assign this issue to me?

iamaayushrivastava avatar Aug 17 '26 06:08 iamaayushrivastava