|
1 | | -// RUN: fir-opt %s --fir-to-scf | FileCheck %s |
| 1 | +// RUN: fir-opt %s --fir-to-scf --allow-unregistered-dialect | FileCheck %s |
2 | 2 |
|
3 | 3 | // CHECK-LABEL: func.func @test_simple_iterate_while_1() -> (index, i1, i16, i32) { |
4 | 4 | // CHECK: %[[VAL_0:.*]] = arith.constant 11 : index |
@@ -97,3 +97,30 @@ func.func @test_zero_iterations() -> (index, i1, i8) { |
97 | 97 |
|
98 | 98 | return %res#0, %res#1, %res#2 : index, i1, i8 |
99 | 99 | } |
| 100 | + |
| 101 | +// CHECK-LABEL: func.func @test_without_final_value( |
| 102 | +// CHECK-SAME: %[[ARG0:.*]]: index, |
| 103 | +// CHECK-SAME: %[[ARG1:.*]]: index) -> i1 { |
| 104 | +// CHECK: %[[CONSTANT_0:.*]] = arith.constant 1 : index |
| 105 | +// CHECK: %[[CONSTANT_1:.*]] = arith.constant true |
| 106 | +// CHECK: %[[WHILE_0:.*]]:2 = scf.while (%[[VAL_0:.*]] = %[[ARG0]], %[[VAL_1:.*]] = %[[CONSTANT_1]]) : (index, i1) -> (index, i1) { |
| 107 | +// CHECK: %[[CMPI_0:.*]] = arith.cmpi sle, %[[VAL_0]], %[[ARG1]] : index |
| 108 | +// CHECK: %[[ANDI_0:.*]] = arith.andi %[[CMPI_0]], %[[VAL_1]] : i1 |
| 109 | +// CHECK: scf.condition(%[[ANDI_0]]) %[[VAL_0]], %[[VAL_1]] : index, i1 |
| 110 | +// CHECK: } do { |
| 111 | +// CHECK: ^bb0(%[[VAL_2:.*]]: index, %[[VAL_3:.*]]: i1): |
| 112 | +// CHECK: %[[ADDI_0:.*]] = arith.addi %[[VAL_2]], %[[CONSTANT_0]] : index |
| 113 | +// CHECK: %[[VAL_4:.*]] = "test.get_some_value"() : () -> i1 |
| 114 | +// CHECK: scf.yield %[[ADDI_0]], %[[VAL_4]] : index, i1 |
| 115 | +// CHECK: } |
| 116 | +// CHECK: return %[[VAL_5:.*]]#1 : i1 |
| 117 | +// CHECK: } |
| 118 | +func.func @test_without_final_value(%lo : index, %up : index) -> i1 { |
| 119 | + %c1 = arith.constant 1 : index |
| 120 | + %ok1 = arith.constant true |
| 121 | + %ok2 = fir.iterate_while (%i = %lo to %up step %c1) and (%j = %ok1) { |
| 122 | + %ok = "test.get_some_value"() : () -> i1 |
| 123 | + fir.result %ok : i1 |
| 124 | + } |
| 125 | + return %ok2 : i1 |
| 126 | +} |
0 commit comments