1 // Test code generation of hlfir.forall when assignment fusing is enabled
3 // RUN: fir-opt %s --lower-hlfir-ordered-assignments=fuse-assignments=true | FileCheck %s --check-prefix=FUSE
4 // RUN: fir-opt %s --lower-hlfir-ordered-assignments=fuse-assignments=false | FileCheck %s --check-prefix=NOFUSE
6 func.func @test_assignment_fusing(%x: !fir.ref<!fir.array<10xi32>>, %y : !fir.box<!fir.array<?xi32>>) {
7 %c42 = arith.constant 42 : i32
9 %c1 = arith.constant 1 : index
10 hlfir.yield %c1 : index
12 %c10 = arith.constant 10 : index
13 hlfir.yield %c10 : index
16 hlfir.yield %c42 : i32
18 %2 = hlfir.designate %x (%i) : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
19 hlfir.yield %2 : !fir.ref<i32>
22 hlfir.yield %c42 : i32
24 %2 = hlfir.designate %y (%i) : (!fir.box<!fir.array<?xi32>>, index) -> !fir.ref<i32>
25 hlfir.yield %2 : !fir.ref<i32>
30 // FUSE-LABEL: func.func @test_assignment_fusing(
31 // FUSE-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>>,
32 // FUSE-SAME: %[[VAL_1:.*]]: !fir.box<!fir.array<?xi32>>) {
33 // FUSE: %[[VAL_2:.*]] = arith.constant 42 : i32
34 // FUSE: %[[VAL_3:.*]] = arith.constant 1 : index
35 // FUSE: %[[VAL_4:.*]] = arith.constant 10 : index
36 // FUSE: %[[VAL_5:.*]] = arith.constant 1 : index
37 // FUSE: fir.do_loop %[[VAL_6:.*]] = %[[VAL_3]] to %[[VAL_4]] step %[[VAL_5]] {
38 // FUSE-NEXT: %[[VAL_7:.*]] = hlfir.designate %[[VAL_0]] (%[[VAL_6]]) : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
39 // FUSE-NEXT: hlfir.assign %[[VAL_2]] to %[[VAL_7]] : i32, !fir.ref<i32>
40 // FUSE-NEXT: %[[VAL_8:.*]] = hlfir.designate %[[VAL_1]] (%[[VAL_6]]) : (!fir.box<!fir.array<?xi32>>, index) -> !fir.ref<i32>
41 // FUSE-NEXT: hlfir.assign %[[VAL_2]] to %[[VAL_8]] : i32, !fir.ref<i32>
45 // NOFUSE-LABEL: func.func @test_assignment_fusing(
46 // NOFUSE: fir.do_loop
47 // NOFUSE: hlfir.assign
49 // NOFUSE: fir.do_loop
50 // NOFUSE: hlfir.assign