File: loop02.fir

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (64 lines) | stat: -rw-r--r-- 3,303 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// RUN: fir-opt --cfg-conversion="always-execute-loop-body=true" %s | FileCheck %s
// RUN: fir-opt --cfg-conversion %s | FileCheck %s --check-prefix=NOOPT

func.func @x(%addr : !fir.ref<index>) {
  %bound = arith.constant 452 : index
  %step = arith.constant 1 : index
  fir.do_loop %iv = %bound to %bound step %step {
    fir.call @y(%addr) : (!fir.ref<index>) -> ()
  }
  return
}

func.func private @y(%addr : !fir.ref<index>)


// CHECK-LABEL:   func @x(
// CHECK-SAME:            %[[VAL_0:.*]]: !fir.ref<index>) {
// CHECK:           %[[VAL_1:.*]] = arith.constant 452 : index
// CHECK:           %[[VAL_2:.*]] = arith.constant 1 : index
// CHECK:           %[[VAL_3:.*]] = arith.subi %[[VAL_1]], %[[VAL_1]] : index
// CHECK:           %[[VAL_4:.*]] = arith.addi %[[VAL_3]], %[[VAL_2]] : index
// CHECK:           %[[VAL_5:.*]] = arith.divsi %[[VAL_4]], %[[VAL_2]] : index
// CHECK:           %[[VAL_6:.*]] = arith.constant 0 : index
// CHECK:           %[[VAL_7:.*]] = arith.cmpi sle, %[[VAL_5]], %[[VAL_6]] : index
// CHECK:           %[[VAL_8:.*]] = arith.constant 1 : index
// CHECK:           %[[VAL_9:.*]] = arith.select %[[VAL_7]], %[[VAL_8]], %[[VAL_5]] : index
// CHECK:           br ^bb1(%[[VAL_1]], %[[VAL_9]] : index, index)
// CHECK:         ^bb1(%[[VAL_10:.*]]: index, %[[VAL_11:.*]]: index):
// CHECK:           %[[VAL_12:.*]] = arith.constant 0 : index
// CHECK:           %[[VAL_13:.*]] = arith.cmpi sgt, %[[VAL_11]], %[[VAL_12]] : index
// CHECK:           cond_br %[[VAL_13]], ^bb2, ^bb3
// CHECK:         ^bb2:
// CHECK:           fir.call @y(%[[VAL_0]]) : (!fir.ref<index>) -> ()
// CHECK:           %[[VAL_14:.*]] = arith.addi %[[VAL_10]], %[[VAL_2]] : index
// CHECK:           %[[VAL_15:.*]] = arith.constant 1 : index
// CHECK:           %[[VAL_16:.*]] = arith.subi %[[VAL_11]], %[[VAL_15]] : index
// CHECK:           br ^bb1(%[[VAL_14]], %[[VAL_16]] : index, index)
// CHECK:         ^bb3:
// CHECK:           return
// CHECK:         }
// CHECK:         func private @y(!fir.ref<index>)

// NOOPT-LABEL:   func @x(
// NOOPT-SAME:            %[[VAL_0:.*]]: !fir.ref<index>) {
// NOOPT:           %[[VAL_1:.*]] = arith.constant 452 : index
// NOOPT:           %[[VAL_2:.*]] = arith.constant 1 : index
// NOOPT:           %[[VAL_3:.*]] = arith.subi %[[VAL_1]], %[[VAL_1]] : index
// NOOPT:           %[[VAL_4:.*]] = arith.addi %[[VAL_3]], %[[VAL_2]] : index
// NOOPT:           %[[VAL_5:.*]] = arith.divsi %[[VAL_4]], %[[VAL_2]] : index
// NOOPT:           br ^bb1(%[[VAL_1]], %[[VAL_5]] : index, index)
// NOOPT:         ^bb1(%[[VAL_6:.*]]: index, %[[VAL_7:.*]]: index):
// NOOPT:           %[[VAL_8:.*]] = arith.constant 0 : index
// NOOPT:           %[[VAL_9:.*]] = arith.cmpi sgt, %[[VAL_7]], %[[VAL_8]] : index
// NOOPT:           cond_br %[[VAL_9]], ^bb2, ^bb3
// NOOPT:         ^bb2:
// NOOPT:           fir.call @y(%[[VAL_0]]) : (!fir.ref<index>) -> ()
// NOOPT:           %[[VAL_10:.*]] = arith.addi %[[VAL_6]], %[[VAL_2]] : index
// NOOPT:           %[[VAL_11:.*]] = arith.constant 1 : index
// NOOPT:           %[[VAL_12:.*]] = arith.subi %[[VAL_7]], %[[VAL_11]] : index
// NOOPT:           br ^bb1(%[[VAL_10]], %[[VAL_12]] : index, index)
// NOOPT:         ^bb3:
// NOOPT:           return
// NOOPT:         }
// NOOPT:         func private @y(!fir.ref<index>)