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