15b66987cSKiran Chandramohan! RUN: bbc -emit-hlfir -fopenmp %s -o - | FileCheck %s 25b66987cSKiran Chandramohan! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s 35b66987cSKiran Chandramohan 4d84252e0SSergio Afonso!CHECK: omp.declare_reduction @[[IEOR_DECLARE_I:.*]] : i32 init { 55b66987cSKiran Chandramohan!CHECK: %[[ZERO_VAL_I:.*]] = arith.constant 0 : i32 65b66987cSKiran Chandramohan!CHECK: omp.yield(%[[ZERO_VAL_I]] : i32) 75b66987cSKiran Chandramohan!CHECK: combiner 85b66987cSKiran Chandramohan!CHECK: ^bb0(%[[ARG0_I:.*]]: i32, %[[ARG1_I:.*]]: i32): 95b66987cSKiran Chandramohan!CHECK: %[[IEOR_VAL_I:.*]] = arith.xori %[[ARG0_I]], %[[ARG1_I]] : i32 105b66987cSKiran Chandramohan!CHECK: omp.yield(%[[IEOR_VAL_I]] : i32) 115b66987cSKiran Chandramohan 125b66987cSKiran Chandramohan!CHECK-LABEL: @_QPreduction_ieor 135b66987cSKiran Chandramohan!CHECK-SAME: %[[Y_BOX:.*]]: !fir.box<!fir.array<?xi32>> 145b66987cSKiran Chandramohan!CHECK: %[[X_REF:.*]] = fir.alloca i32 {bindc_name = "x", uniq_name = "_QFreduction_ieorEx"} 155b66987cSKiran Chandramohan!CHECK: %[[X_DECL:.*]]:2 = hlfir.declare %[[X_REF]] {uniq_name = "_QFreduction_ieorEx"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) 161710c8cfSSlava Zakharin!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>>) 175b66987cSKiran Chandramohan 185b66987cSKiran Chandramohan 195b66987cSKiran Chandramohan!CHECK: omp.parallel 20*937cbce1SKareem Ergawy!CHECK: %[[I_REF:.*]] = fir.alloca i32 {bindc_name = "i", pinned, {{.*}}} 216f82408bSKareem Ergawy!CHECK: %[[I_DECL:.*]]:2 = hlfir.declare %[[I_REF]] {uniq_name = "_QFreduction_ieorEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) 22*937cbce1SKareem Ergawy!CHECK: omp.wsloop reduction(@[[IEOR_DECLARE_I]] %[[X_DECL]]#0 -> %[[PRV:.+]] : !fir.ref<i32>) 23*937cbce1SKareem Ergawy!CHECK-NEXT: omp.loop_nest 24be9f8ffdSDavid Truby!CHECK: %[[PRV_DECL:.+]]:2 = hlfir.declare %[[PRV]] {{.*}} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) 25ca4dbc27SSergio Afonso!CHECK: fir.store %{{.*}} to %[[I_DECL]]#1 : !fir.ref<i32> 265b66987cSKiran Chandramohan!CHECK: %[[I_32:.*]] = fir.load %[[I_DECL]]#0 : !fir.ref<i32> 275b66987cSKiran Chandramohan!CHECK: %[[I_64:.*]] = fir.convert %[[I_32]] : (i32) -> i64 285b66987cSKiran Chandramohan!CHECK: %[[Y_I_REF:.*]] = hlfir.designate %[[Y_DECL]]#0 (%[[I_64]]) : (!fir.box<!fir.array<?xi32>>, i64) -> !fir.ref<i32> 29be9f8ffdSDavid Truby!CHECK: %[[LPRV:.+]] = fir.load %[[PRV_DECL]]#0 : !fir.ref<i32> 305b66987cSKiran Chandramohan!CHECK: %[[Y_I:.*]] = fir.load %[[Y_I_REF]] : !fir.ref<i32> 31be9f8ffdSDavid Truby!CHECK: %[[RES:.+]] = arith.xori %[[LPRV]], %[[Y_I]] : i32 32be9f8ffdSDavid Truby!CHECK: hlfir.assign %[[RES]] to %[[PRV_DECL]]#0 : i32, !fir.ref<i32> 335b66987cSKiran Chandramohan!CHECK: omp.yield 345b66987cSKiran Chandramohan!CHECK: omp.terminator 355b66987cSKiran Chandramohan 365b66987cSKiran Chandramohansubroutine reduction_ieor(y) 375b66987cSKiran Chandramohan integer :: x, y(:) 385b66987cSKiran Chandramohan x = 0 395b66987cSKiran Chandramohan !$omp parallel 405b66987cSKiran Chandramohan !$omp do reduction(ieor:x) 415b66987cSKiran Chandramohan do i=1, 100 425b66987cSKiran Chandramohan x = ieor(x, y(i)) 435b66987cSKiran Chandramohan end do 445b66987cSKiran Chandramohan !$omp end do 455b66987cSKiran Chandramohan !$omp end parallel 465b66987cSKiran Chandramohan print *, x 475b66987cSKiran Chandramohanend subroutine 48