45 lines · plain
1! RUN: bbc -emit-hlfir -fopenmp -o - %s 2>&1 | FileCheck %s2! RUN: %flang_fc1 -emit-hlfir -fopenmp -o - %s 2>&1 | FileCheck %s3 4program reduce5 integer a(0:1)6 7 call sub(a, 0, 1)8 9contains10 subroutine sub(a, lb, ub)11 integer :: i, lb, ub, a(lb:ub)12 13 !$omp parallel do reduction(+:a)14 do i = 1, 1015 a(0) = a(0) + 116 end do17 !$omp end parallel do18 end subroutine19 20end program21 22! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_Uxi32 : !fir.ref<!fir.box<!fir.array<?xi32>>> {{.*}} alloc {23! CHECK: } combiner {24! CHECK: ^bb0(%[[ARG0:.*]]: !fir.ref<!fir.box<!fir.array<?xi32>>>, %[[ARG1:.*]]: !fir.ref<!fir.box<!fir.array<?xi32>>>):25! CHECK: %[[ARR0:.*]] = fir.load %[[ARG0]] : !fir.ref<!fir.box<!fir.array<?xi32>>>26! CHECK: %[[ARR1:.*]] = fir.load %[[ARG1]] : !fir.ref<!fir.box<!fir.array<?xi32>>>27! CHECK: %[[C0:.*]] = arith.constant 0 : index28! CHECK: %[[DIMS:.*]]:3 = fir.box_dims %[[ARR0]], %[[C0]] : (!fir.box<!fir.array<?xi32>>, index) -> (index, index, index)29! CHECK: %[[C1:.*]] = arith.constant 1 : index30! CHECK: %[[SHAPE_SHIFT:.*]] = fir.shape_shift %[[C1]], %[[DIMS]]#1 : (index, index) -> !fir.shapeshift<1>31! CHECK: %[[C1_0:.*]] = arith.constant 1 : index32! CHECK: fir.do_loop %[[ARG2:.*]] = %[[C1_0]] to %[[DIMS]]#1 step %[[C1_0]] unordered {33! CHECK: %[[COOR0:.*]] = fir.array_coor %[[ARR0]](%[[SHAPE_SHIFT]]) %[[ARG2]] : (!fir.box<!fir.array<?xi32>>, !fir.shapeshift<1>, index) -> !fir.ref<i32>34! CHECK: %[[COOR1:.*]] = fir.array_coor %[[ARR1]](%[[SHAPE_SHIFT]]) %[[ARG2]] : (!fir.box<!fir.array<?xi32>>, !fir.shapeshift<1>, index) -> !fir.ref<i32>35! CHECK: %[[ELEM0:.*]] = fir.load %[[COOR0]] : !fir.ref<i32>36! CHECK: %[[ELEM1:.*]] = fir.load %[[COOR1]] : !fir.ref<i32>37! CHECK: %[[SUM:.*]] = arith.addi %[[ELEM0]], %[[ELEM1]] : i3238! CHECK: fir.store %[[SUM]] to %[[COOR0]] : !fir.ref<i32>39! CHECK: }40! CHECK: omp.yield(%[[ARG0]] : !fir.ref<!fir.box<!fir.array<?xi32>>>)41! CHECK: }42 43! CHECK-LABEL: func.func @_QQmain() attributes {fir.bindc_name = "REDUCE"} {44! CHECK: omp.wsloop {{.*}} reduction(byref @add_reduction_byref_box_Uxi32 %{{.*}} -> %{{.*}} : !fir.ref<!fir.box<!fir.array<?xi32>>>)45