1 // RUN: fir-opt --cfg-conversion="always-execute-loop-body=true" %s | FileCheck %s
2 // RUN: fir-opt --cfg-conversion %s | FileCheck %s --check-prefix=NOOPT
4 func.func @x(%addr : !fir.ref<index>) {
5 %bound = arith.constant 452 : index
6 %step = arith.constant 1 : index
7 fir.do_loop %iv = %bound to %bound step %step {
8 fir.call @y(%addr) : (!fir.ref<index>) -> ()
13 func.func private @y(%addr : !fir.ref<index>)
16 // CHECK-LABEL: func @x(
17 // CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<index>) {
18 // CHECK: %[[VAL_1:.*]] = arith.constant 452 : index
19 // CHECK: %[[VAL_2:.*]] = arith.constant 1 : index
20 // CHECK: %[[VAL_3:.*]] = arith.subi %[[VAL_1]], %[[VAL_1]] : index
21 // CHECK: %[[VAL_4:.*]] = arith.addi %[[VAL_3]], %[[VAL_2]] : index
22 // CHECK: %[[VAL_5:.*]] = arith.divsi %[[VAL_4]], %[[VAL_2]] : index
23 // CHECK: %[[VAL_6:.*]] = arith.constant 0 : index
24 // CHECK: %[[VAL_7:.*]] = arith.cmpi sle, %[[VAL_5]], %[[VAL_6]] : index
25 // CHECK: %[[VAL_8:.*]] = arith.constant 1 : index
26 // CHECK: %[[VAL_9:.*]] = arith.select %[[VAL_7]], %[[VAL_8]], %[[VAL_5]] : index
27 // CHECK: br ^bb1(%[[VAL_1]], %[[VAL_9]] : index, index)
28 // CHECK: ^bb1(%[[VAL_10:.*]]: index, %[[VAL_11:.*]]: index):
29 // CHECK: %[[VAL_12:.*]] = arith.constant 0 : index
30 // CHECK: %[[VAL_13:.*]] = arith.cmpi sgt, %[[VAL_11]], %[[VAL_12]] : index
31 // CHECK: cond_br %[[VAL_13]], ^bb2, ^bb3
33 // CHECK: fir.call @y(%[[VAL_0]]) : (!fir.ref<index>) -> ()
34 // CHECK: %[[VAL_14:.*]] = arith.addi %[[VAL_10]], %[[VAL_2]] : index
35 // CHECK: %[[VAL_15:.*]] = arith.constant 1 : index
36 // CHECK: %[[VAL_16:.*]] = arith.subi %[[VAL_11]], %[[VAL_15]] : index
37 // CHECK: br ^bb1(%[[VAL_14]], %[[VAL_16]] : index, index)
41 // CHECK: func private @y(!fir.ref<index>)
43 // NOOPT-LABEL: func @x(
44 // NOOPT-SAME: %[[VAL_0:.*]]: !fir.ref<index>) {
45 // NOOPT: %[[VAL_1:.*]] = arith.constant 452 : index
46 // NOOPT: %[[VAL_2:.*]] = arith.constant 1 : index
47 // NOOPT: %[[VAL_3:.*]] = arith.subi %[[VAL_1]], %[[VAL_1]] : index
48 // NOOPT: %[[VAL_4:.*]] = arith.addi %[[VAL_3]], %[[VAL_2]] : index
49 // NOOPT: %[[VAL_5:.*]] = arith.divsi %[[VAL_4]], %[[VAL_2]] : index
50 // NOOPT: br ^bb1(%[[VAL_1]], %[[VAL_5]] : index, index)
51 // NOOPT: ^bb1(%[[VAL_6:.*]]: index, %[[VAL_7:.*]]: index):
52 // NOOPT: %[[VAL_8:.*]] = arith.constant 0 : index
53 // NOOPT: %[[VAL_9:.*]] = arith.cmpi sgt, %[[VAL_7]], %[[VAL_8]] : index
54 // NOOPT: cond_br %[[VAL_9]], ^bb2, ^bb3
56 // NOOPT: fir.call @y(%[[VAL_0]]) : (!fir.ref<index>) -> ()
57 // NOOPT: %[[VAL_10:.*]] = arith.addi %[[VAL_6]], %[[VAL_2]] : index
58 // NOOPT: %[[VAL_11:.*]] = arith.constant 1 : index
59 // NOOPT: %[[VAL_12:.*]] = arith.subi %[[VAL_7]], %[[VAL_11]] : index
60 // NOOPT: br ^bb1(%[[VAL_10]], %[[VAL_12]] : index, index)
64 // NOOPT: func private @y(!fir.ref<index>)