diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp index 78d36714d35e0..b36d81b94114d 100644 --- a/flang/lib/Lower/OpenACC.cpp +++ b/flang/lib/Lower/OpenACC.cpp @@ -650,7 +650,8 @@ static mlir::Value genReductionInitValue(fir::FirOpBuilder &builder, op != mlir::acc::ReductionOperator::AccMin && op != mlir::acc::ReductionOperator::AccMax && op != mlir::acc::ReductionOperator::AccIand && - op != mlir::acc::ReductionOperator::AccIor) + op != mlir::acc::ReductionOperator::AccIor && + op != mlir::acc::ReductionOperator::AccXor) TODO(loc, "reduction operator"); if (ty.isIntOrIndex()) @@ -760,6 +761,9 @@ static mlir::Value genCombiner(fir::FirOpBuilder &builder, mlir::Location loc, if (op == mlir::acc::ReductionOperator::AccIor) return builder.create(loc, value1, value2); + if (op == mlir::acc::ReductionOperator::AccXor) + 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 index 9148a302c6a43..0171ce1fa8445 100644 --- 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_xor_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.xori %[[ARG0]], %[[ARG1]] : i32 +! CHECK: acc.yield %[[COMBINED]] : i32 +! CHECK: } + ! CHECK-LABEL: acc.reduction.recipe @reduction_ior_i32 : i32 reduction_operator init { ! CHECK: ^bb0(%{{.*}}: i32): ! CHECK: %[[CST:.*]] = arith.constant 0 : i32 @@ -617,3 +627,13 @@ subroutine acc_reduction_ior() ! 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) + +subroutine acc_reduction_ieor() + integer :: i + !$acc parallel reduction(ieor:i) + !$acc end parallel +end subroutine + +! CHECK-LABEL: func.func @_QPacc_reduction_ieor() +! CHECK: %[[RED:.*]] = acc.reduction varPtr(%{{.*}} : !fir.ref) -> !fir.ref {name = "i"} +! CHECK: acc.parallel reduction(@reduction_xor_i32 -> %[[RED]] : !fir.ref)