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