| 1 |
! RUN: bbc -emit-hlfir -fopenmp %s -o - | FileCheck %s |
| 2 |
! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s |
| 3 |
|
| 4 |
!CHECK: omp.declare_reduction @[[IEOR_DECLARE_I:.*]] : i32 init { |
| 5 |
!CHECK: %[[ZERO_VAL_I:.*]] = arith.constant 0 : i32 |
| 6 |
!CHECK: omp.yield(%[[ZERO_VAL_I]] : i32) |
| 7 |
!CHECK: combiner |
| 8 |
!CHECK: ^bb0(%[[ARG0_I:.*]]: i32, %[[ARG1_I:.*]]: i32): |
| 9 |
!CHECK: %[[IEOR_VAL_I:.*]] = arith.xori %[[ARG0_I]], %[[ARG1_I]] : i32 |
| 10 |
!CHECK: omp.yield(%[[IEOR_VAL_I]] : i32) |
| 11 |
|
| 12 |
!CHECK-LABEL: @_QPreduction_ieor |
| 13 |
!CHECK-SAME: %[[Y_BOX:.*]]: !fir.box<!fir.array<?xi32>> |
| 14 |
!CHECK: %[[X_REF:.*]] = fir.alloca i32 {bindc_name = "x", uniq_name = "_QFreduction_ieorEx"} |
| 15 |
!CHECK: %[[X_DECL:.*]]:2 = hlfir.declare %[[X_REF]] {uniq_name = "_QFreduction_ieorEx"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 16 |
!CHECK: %[[Y_DECL:.*]]:2 = hlfir.declare %[[Y_BOX]] dummy_scope %{{[0-9]+}} {uniq_name = "_QFreduction_ieorEy"} : (!fir.box<!fir.array<?xi32>>, !fir.dscope) -> (!fir.box<!fir.array<?xi32>>, !fir.box<!fir.array<?xi32>>) |
| 17 |
|
| 18 |
|
| 19 |
!CHECK: omp.parallel |
| 20 |
!CHECK: %[[I_REF:.*]] = fir.alloca i32 {bindc_name = "i", pinned, {{.*}}} |
| 21 |
!CHECK: %[[I_DECL:.*]]:2 = hlfir.declare %[[I_REF]] {uniq_name = "_QFreduction_ieorEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 22 |
!CHECK: omp.wsloop reduction(@[[IEOR_DECLARE_I]] %[[X_DECL]]#0 -> %[[PRV:.+]] : !fir.ref<i32>) |
| 23 |
!CHECK-NEXT: omp.loop_nest |
| 24 |
!CHECK: %[[PRV_DECL:.+]]:2 = hlfir.declare %[[PRV]] {{.*}} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 25 |
!CHECK: fir.store %{{.*}} to %[[I_DECL]]#1 : !fir.ref<i32> |
| 26 |
!CHECK: %[[I_32:.*]] = fir.load %[[I_DECL]]#0 : !fir.ref<i32> |
| 27 |
!CHECK: %[[I_64:.*]] = fir.convert %[[I_32]] : (i32) -> i64 |
| 28 |
!CHECK: %[[Y_I_REF:.*]] = hlfir.designate %[[Y_DECL]]#0 (%[[I_64]]) : (!fir.box<!fir.array<?xi32>>, i64) -> !fir.ref<i32> |
| 29 |
!CHECK: %[[LPRV:.+]] = fir.load %[[PRV_DECL]]#0 : !fir.ref<i32> |
| 30 |
!CHECK: %[[Y_I:.*]] = fir.load %[[Y_I_REF]] : !fir.ref<i32> |
| 31 |
!CHECK: %[[RES:.+]] = arith.xori %[[LPRV]], %[[Y_I]] : i32 |
| 32 |
!CHECK: hlfir.assign %[[RES]] to %[[PRV_DECL]]#0 : i32, !fir.ref<i32> |
| 33 |
!CHECK: omp.yield |
| 34 |
!CHECK: omp.terminator |
| 35 |
!CHECK: omp.terminator |
| 36 |
|
| 37 |
subroutine reduction_ieor(y) |
| 38 |
integer :: x, y(:) |
| 39 |
x = 0 |
| 40 |
!$omp parallel |
| 41 |
!$omp do reduction(ieor:x) |
| 42 |
do i=1, 100 |
| 43 |
x = ieor(x, y(i)) |
| 44 |
end do |
| 45 |
!$omp end do |
| 46 |
!$omp end parallel |
| 47 |
print *, x |
| 48 |
end subroutine |