Skip to content

[MLIR][RemoveDeadValues] RemoveDeadValues pass fails due to deleting loop induction variable. #157934

@red1bluelost

Description

@red1bluelost

Running remove-dead-values on the following IR produces the error below. The pass attempts to delete the loop induction variable because it is not used in the body but scf.for requires the block argument be present.

func.func @dead_value_loop_ivs(%lb: index, %ub: index, %step: index, %b : i1) -> i1 {
  %loop_ret = scf.for %iv = %lb to %ub step %step iter_args(%iter = %b) -> (i1) {
    cf.assert %b, "loop not dead"
    scf.yield %b : i1
  }
  return %loop_ret : i1
}
/temp.mlir:2:15: error: 'scf.for' op different number of inits and region iter_args: 1 != 0
  %loop_ret = scf.for %iv = %lb to %ub step %step iter_args(%iter = %b) -> (i1) {
              ^
/temp.mlir:2:15: note: see current operation: 
%0 = "scf.for"(%arg0, %arg1, %arg2, %arg3) ({
^bb0(%arg4: i1):
  "cf.assert"(%arg3) <{msg = "loop not dead"}> : (i1) -> ()
  "scf.yield"(%arg3) : (i1) -> ()
}) : (index, index, index, i1) -> i1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions