Debian Codegraph @

flang/test/Transforms/loop-versioning-with-repack-arrays.fir

raw
1 // RUN: fir-opt --loop-versioning %s | FileCheck %s
2
3 // Check that LoopVersioning kicks in when there is fir.pack_array
4 // in between fir.declare and the block argument.
5
6 module attributes {dlti.dl_spec = #dlti.dl_spec<>} {
7 func.func @_QPtest(%arg0: !fir.box<!fir.array<?xf32>> {fir.bindc_name = "x"}) {
8 %c1 = arith.constant 1 : index
9 %c0 = arith.constant 0 : index
10 %cst = arith.constant 1.000000e+00 : f32
11 %0 = fir.dummy_scope : !fir.dscope
12 %1 = fir.pack_array %arg0 stack whole : (!fir.box<!fir.array<?xf32>>) -> !fir.box<!fir.array<?xf32>>
13 %2 = fir.declare %1 dummy_scope %0 {uniq_name = "_QFtestEx"} : (!fir.box<!fir.array<?xf32>>, !fir.dscope) -> !fir.box<!fir.array<?xf32>>
14 %3 = fir.rebox %2 : (!fir.box<!fir.array<?xf32>>) -> !fir.box<!fir.array<?xf32>>
15 %4:3 = fir.box_dims %3, %c0 : (!fir.box<!fir.array<?xf32>>, index) -> (index, index, index)
16 fir.do_loop %arg1 = %c1 to %4#1 step %c1 unordered {
17 %5 = fir.array_coor %2 %arg1 : (!fir.box<!fir.array<?xf32>>, index) -> !fir.ref<f32>
18 fir.store %cst to %5 : !fir.ref<f32>
19 }
20 fir.unpack_array %1 to %arg0 stack : !fir.box<!fir.array<?xf32>>
21 return
22 }
23 }
24 // CHECK-LABEL: func.func @_QPtest(
25 // CHECK-SAME: %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.box<!fir.array<?xf32>> {fir.bindc_name = "x"}) {
26 // CHECK: %[[VAL_5:.*]] = fir.pack_array %[[VAL_0]] stack whole : (!fir.box<!fir.array<?xf32>>) -> !fir.box<!fir.array<?xf32>>
27 // CHECK: %[[VAL_6:.*]] = fir.declare %[[VAL_5]] dummy_scope %{{.*}} {uniq_name = "_QFtestEx"} : (!fir.box<!fir.array<?xf32>>, !fir.dscope) -> !fir.box<!fir.array<?xf32>>
28 // CHECK: %[[VAL_10:.*]]:3 = fir.box_dims %[[VAL_6]], %{{.*}} : (!fir.box<!fir.array<?xf32>>, index) -> (index, index, index)
29 // CHECK: %[[VAL_11:.*]] = arith.constant 4 : index
30 // CHECK: %[[VAL_12:.*]] = arith.cmpi eq, %[[VAL_10]]#2, %[[VAL_11]] : index
31 // CHECK: fir.if %[[VAL_12]] {
32 // CHECK: fir.do_loop {{.*}} {
33 // CHECK: fir.coordinate_of {{.*}} : (!fir.ref<!fir.array<?xf32>>, index) -> !fir.ref<f32>
34 // CHECK: }
35 // CHECK: } else {
36 // CHECK: fir.do_loop {{.*}} {
37 // CHECK: fir.array_coor {{.*}} : (!fir.box<!fir.array<?xf32>>, index) -> !fir.ref<f32>
38 // CHECK: }
39 // CHECK: }
40 // CHECK: fir.unpack_array %[[VAL_5]] to %[[VAL_0]] stack : !fir.box<!fir.array<?xf32>>