Skip to content

Commit 1663984

Browse files
committed
Adding a test with scf.for and iter_args
1 parent 437db73 commit 1663984

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

mlir/test/Transforms/remove-dead-values.mlir

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,25 @@ func.func @acceptable_ir_has_cleanable_simple_op_with_unconditional_branch_op(%a
6161

6262
// -----
6363

64+
// Checking that iter_args are properly handled
65+
//
66+
func.func @cleanable_loop_iter_args_value(%arg0: index) -> index {
67+
%c0 = arith.constant 0 : index
68+
%c1 = arith.constant 1 : index
69+
%c10 = arith.constant 10 : index
70+
%non_live = arith.constant 0 : index
71+
// CHECK-NOT: non_live
72+
%result, %result_non_live = scf.for %i = %c0 to %c10 step %c1 iter_args(%live_arg = %arg0, %non_live_arg = %non_live) -> (index, index) {
73+
%new_live = arith.addi %live_arg, %i : index
74+
// CHECK-NOT: non_live_arg
75+
scf.yield %new_live, %non_live_arg : index, index
76+
}
77+
// CHECK-NOT: result_non_live
78+
return %result : index
79+
}
80+
81+
// -----
82+
6483
// Note that this cleanup cannot be done by the `canonicalize` pass.
6584
//
6685
// CHECK-LABEL: func.func private @clean_func_op_remove_argument_and_return_value() {

0 commit comments

Comments
 (0)