File: array-value-copy-2.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 (87 lines) | stat: -rw-r--r-- 4,078 bytes parent folder | download | duplicates (14)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// RUN: fir-opt --array-value-copy --cfg-conversion %s | FileCheck %s
// RUN: fir-opt --array-value-copy="optimize-conflicts=true" --cfg-conversion %s | FileCheck %s

// CHECK-LABEL: func @_QPslice1(
// CHECK-NOT: fir.allocmem
// CHECK: ^bb{{[0-9]+}}(%{{[0-9]+}}: index,
// CHECK-NOT: ^bb{{[0-9]+}}(%{{[0-9]+}}: index,
// CHECK: return
func.func @_QPslice1(%arg0: !fir.box<!fir.array<?xf32>>, %arg1: !fir.ref<i32>, %arg2: !fir.ref<i32>) {
  %c1_i64 = arith.constant 1 : i64
  %0 = fir.convert %c1_i64 : (i64) -> index
  %1 = fir.load %arg1 : !fir.ref<i32>
  %2 = fir.convert %1 : (i32) -> i64
  %3 = fir.convert %2 : (i64) -> index
  %c0 = arith.constant 0 : index
  %4 = arith.subi %3, %0 : index
  %5 = arith.addi %4, %0 : index
  %6 = arith.divsi %5, %0 : index
  %7 = arith.cmpi sgt, %6, %c0 : index
  %8 = arith.select %7, %6, %c0 : index
  %9 = fir.slice %0, %3, %0 : (index, index, index) -> !fir.slice<1>
  %10 = fir.array_load %arg0 [%9] : (!fir.box<!fir.array<?xf32>>, !fir.slice<1>) -> !fir.array<?xf32>
  %c1_i32 = arith.constant 1 : i32
  %11 = arith.addi %1, %c1_i32 : i32
  %12 = fir.convert %11 : (i32) -> i64
  %13 = fir.convert %12 : (i64) -> index
  %14 = fir.load %arg2 : !fir.ref<i32>
  %15 = fir.convert %14 : (i32) -> i64
  %16 = fir.convert %15 : (i64) -> index
  %17 = fir.slice %13, %16, %0 : (index, index, index) -> !fir.slice<1>
  %18 = fir.array_load %arg0 [%17] : (!fir.box<!fir.array<?xf32>>, !fir.slice<1>) -> !fir.array<?xf32>
  %c1 = arith.constant 1 : index
  %19 = arith.subi %8, %c1 : index
  %20 = fir.do_loop %arg3 = %c0 to %19 step %c1 unordered iter_args(%arg4 = %10) -> (!fir.array<?xf32>) {
    %21 = fir.array_fetch %18, %arg3 : (!fir.array<?xf32>, index) -> f32
    %22 = fir.array_update %arg4, %21, %arg3 : (!fir.array<?xf32>, f32, index) -> !fir.array<?xf32>
    fir.result %22 : !fir.array<?xf32>
  }
  fir.array_merge_store %10, %20 to %arg0[%9] : !fir.array<?xf32>, !fir.array<?xf32>, !fir.box<!fir.array<?xf32>>, !fir.slice<1>
  return
}

// CHECK-LABEL: func @_QPslice2(
// CHECK: fir.allocmem
// CHECK: ^bb{{[0-9]+}}(%{{[0-9]+}}: index,
// CHECK: ^bb{{[0-9]+}}(%{{[0-9]+}}: index,
// CHECK: fir.freemem
// CHECK: return
func.func @_QPslice2(%arg0: !fir.box<!fir.array<?xf32>>, %arg1: !fir.ref<i32>, %arg2: !fir.ref<i32>) {
  %c1_i64 = arith.constant 1 : i64
  %0 = fir.convert %c1_i64 : (i64) -> index
  %c1_i64_0 = arith.constant 1 : i64
  %1 = fir.convert %c1_i64_0 : (i64) -> index
  %2 = fir.load %arg1 : !fir.ref<i32>
  %3 = fir.convert %2 : (i32) -> i64
  %4 = fir.convert %3 : (i64) -> index
  %c0 = arith.constant 0 : index
  %5 = arith.subi %4, %0 : index
  %6 = arith.addi %5, %1 : index
  %7 = arith.divsi %6, %1 : index
  %8 = arith.cmpi sgt, %7, %c0 : index
  %9 = arith.select %8, %7, %c0 : index
  %10 = fir.slice %0, %4, %1 : (index, index, index) -> !fir.slice<1>
  %11 = fir.array_load %arg0 [%10] : (!fir.box<!fir.array<?xf32>>, !fir.slice<1>) -> !fir.array<?xf32>
  %12 = fir.load %arg1 : !fir.ref<i32>
  %c4_i32 = arith.constant 4 : i32
  %13 = arith.subi %12, %c4_i32 : i32
  %14 = fir.convert %13 : (i32) -> i64
  %15 = fir.convert %14 : (i64) -> index
  %c1_i64_1 = arith.constant 1 : i64
  %16 = fir.convert %c1_i64_1 : (i64) -> index
  %17 = fir.load %arg2 : !fir.ref<i32>
  %18 = fir.convert %17 : (i32) -> i64
  %19 = fir.convert %18 : (i64) -> index
  %20 = fir.slice %15, %19, %16 : (index, index, index) -> !fir.slice<1>
  %21 = fir.array_load %arg0 [%20] : (!fir.box<!fir.array<?xf32>>, !fir.slice<1>) -> !fir.array<?xf32>
  %c1 = arith.constant 1 : index
  %c0_2 = arith.constant 0 : index
  %22 = arith.subi %9, %c1 : index
  %23 = fir.do_loop %arg3 = %c0_2 to %22 step %c1 unordered iter_args(%arg4 = %11) -> (!fir.array<?xf32>) {
    %24 = fir.array_fetch %21, %arg3 : (!fir.array<?xf32>, index) -> f32
    %25 = fir.array_update %arg4, %24, %arg3 : (!fir.array<?xf32>, f32, index) -> !fir.array<?xf32>
    fir.result %25 : !fir.array<?xf32>
  }
  fir.array_merge_store %11, %23 to %arg0[%10] : !fir.array<?xf32>, !fir.array<?xf32>, !fir.box<!fir.array<?xf32>>, !fir.slice<1>
  return
}