diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp --- a/flang/lib/Lower/OpenACC.cpp +++ b/flang/lib/Lower/OpenACC.cpp @@ -649,7 +649,8 @@ op != mlir::acc::ReductionOperator::AccMul && op != mlir::acc::ReductionOperator::AccMin && op != mlir::acc::ReductionOperator::AccMax && - op != mlir::acc::ReductionOperator::AccIand) + op != mlir::acc::ReductionOperator::AccIand && + op != mlir::acc::ReductionOperator::AccIor) TODO(loc, "reduction operator"); if (ty.isIntOrIndex()) @@ -756,6 +757,9 @@ if (op == mlir::acc::ReductionOperator::AccIand) return builder.create(loc, value1, value2); + if (op == mlir::acc::ReductionOperator::AccIor) + return builder.create(loc, value1, value2); + TODO(loc, "reduction operator"); } diff --git a/flang/test/Lower/OpenACC/acc-reduction.f90 b/flang/test/Lower/OpenACC/acc-reduction.f90 --- a/flang/test/Lower/OpenACC/acc-reduction.f90 +++ b/flang/test/Lower/OpenACC/acc-reduction.f90 @@ -2,6 +2,16 @@ ! RUN: bbc -fopenacc -emit-fir %s -o - | FileCheck %s +! CHECK-LABEL: acc.reduction.recipe @reduction_ior_i32 : i32 reduction_operator init { +! CHECK: ^bb0(%{{.*}}: i32): +! CHECK: %[[CST:.*]] = arith.constant 0 : i32 +! CHECK: acc.yield %[[CST]] : i32 +! CHECK: } combiner { +! CHECK: ^bb0(%[[ARG0:.*]]: i32, %[[ARG1:.*]]: i32): +! CHECK: %[[COMBINED:.*]] = arith.ori %[[ARG0]], %[[ARG1]] : i32 +! CHECK: acc.yield %[[COMBINED]] : i32 +! CHECK: } + ! CHECK-LABEL: acc.reduction.recipe @reduction_iand_i32 : i32 reduction_operator init { ! CHECK: ^bb0(%{{.*}}: i32): ! CHECK: %[[CST:.*]] = arith.constant -1 : i32 @@ -597,3 +607,13 @@ ! CHECK-LABEL: func.func @_QPacc_reduction_iand() ! CHECK: %[[RED:.*]] = acc.reduction varPtr(%{{.*}} : !fir.ref) -> !fir.ref {name = "i"} ! CHECK: acc.parallel reduction(@reduction_iand_i32 -> %[[RED]] : !fir.ref) + +subroutine acc_reduction_ior() + integer :: i + !$acc parallel reduction(ior:i) + !$acc end parallel +end subroutine + +! CHECK-LABEL: func.func @_QPacc_reduction_ior() +! CHECK: %[[RED:.*]] = acc.reduction varPtr(%{{.*}} : !fir.ref) -> !fir.ref {name = "i"} +! CHECK: acc.parallel reduction(@reduction_ior_i32 -> %[[RED]] : !fir.ref)