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 @@ -645,9 +645,6 @@ static mlir::Value genReductionInitValue(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Type ty, mlir::acc::ReductionOperator op) { - if (op == mlir::acc::ReductionOperator::AccNeqv) - TODO(loc, "reduction operator"); - if (ty.isIntOrIndex()) return builder.create( loc, ty, @@ -797,6 +794,10 @@ if (op == mlir::acc::ReductionOperator::AccEqv) return genComparisonCombiner(builder, loc, mlir::arith::CmpIPredicate::eq, value1, value2); + if (op == mlir::acc::ReductionOperator::AccNeqv) + return genComparisonCombiner(builder, loc, mlir::arith::CmpIPredicate::ne, + 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,19 @@ ! RUN: bbc -fopenacc -emit-fir %s -o - | FileCheck %s +! CHECK-LABEL: acc.reduction.recipe @reduction_neqv_l32 : !fir.logical<4> reduction_operator init { +! CHECK: ^bb0(%{{.*}}: !fir.logical<4>): +! CHECK: %[[CST:.*]] = arith.constant false +! CHECK: acc.yield %[[CST]] : i1 +! CHECK: } combiner { +! CHECK: ^bb0(%[[ARG0:.*]]: !fir.logical<4>, %[[ARG1:.*]]: !fir.logical<4>): +! CHECK: %[[V1:.*]] = fir.convert %[[ARG0]] : (!fir.logical<4>) -> i1 +! CHECK: %[[V2:.*]] = fir.convert %[[ARG1]] : (!fir.logical<4>) -> i1 +! CHECK: %[[NEQV:.*]] = arith.cmpi ne, %[[V1]], %[[V2]] : i1 +! CHECK: %[[CONV:.*]] = fir.convert %[[NEQV]] : (i1) -> !fir.logical<4> +! CHECK: acc.yield %[[CONV]] : !fir.logical<4> +! CHECK: } + ! CHECK-LABEL: acc.reduction.recipe @reduction_eqv_l32 : !fir.logical<4> reduction_operator init { ! CHECK: ^bb0(%{{.*}}: !fir.logical<4>): ! CHECK: %[[CST:.*]] = arith.constant true @@ -706,3 +719,13 @@ ! CHECK-LABEL: func.func @_QPacc_reduction_eqv() ! CHECK: %[[RED:.*]] = acc.reduction varPtr(%{{.*}} : !fir.ref>) -> !fir.ref> {name = "l"} ! CHECK: acc.parallel reduction(@reduction_eqv_l32 -> %[[RED]] : !fir.ref>) + +subroutine acc_reduction_neqv() + logical :: l + !$acc parallel reduction(.neqv.:l) + !$acc end parallel +end subroutine + +! CHECK-LABEL: func.func @_QPacc_reduction_neqv() +! CHECK: %[[RED:.*]] = acc.reduction varPtr(%{{.*}} : !fir.ref>) -> !fir.ref> {name = "l"} +! CHECK: acc.parallel reduction(@reduction_neqv_l32 -> %[[RED]] : !fir.ref>)