[flang-commits] [flang] 0ec1ace - [flang][openacc] Support ior reduction operator
Valentin Clement via flang-commits
flang-commits at lists.llvm.org
Tue Jul 11 08:56:23 PDT 2023
Author: Valentin Clement
Date: 2023-07-11T08:56:12-07:00
New Revision: 0ec1acec7894a4bda680e1808a43a799fd295f69
URL: https://github.com/llvm/llvm-project/commit/0ec1acec7894a4bda680e1808a43a799fd295f69
DIFF: https://github.com/llvm/llvm-project/commit/0ec1acec7894a4bda680e1808a43a799fd295f69.diff
LOG: [flang][openacc] Support ior reduction operator
Add support for `ior` reduction operator in
OpenACC lowering.
Depends on D154886
Reviewed By: razvanlupusoru
Differential Revision: https://reviews.llvm.org/D154887
Added:
Modified:
flang/lib/Lower/OpenACC.cpp
flang/test/Lower/OpenACC/acc-reduction.f90
Removed:
################################################################################
diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp
index 3627a1ceb455be..78d36714d35e0c 100644
--- a/flang/lib/Lower/OpenACC.cpp
+++ b/flang/lib/Lower/OpenACC.cpp
@@ -649,7 +649,8 @@ static mlir::Value genReductionInitValue(fir::FirOpBuilder &builder,
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 @@ static mlir::Value genCombiner(fir::FirOpBuilder &builder, mlir::Location loc,
if (op == mlir::acc::ReductionOperator::AccIand)
return builder.create<mlir::arith::AndIOp>(loc, value1, value2);
+ if (op == mlir::acc::ReductionOperator::AccIor)
+ return builder.create<mlir::arith::OrIOp>(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 bdb25619bc5727..9148a302c6a434 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_ior_i32 : i32 reduction_operator <ior> 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 <iand> init {
! CHECK: ^bb0(%{{.*}}: i32):
! CHECK: %[[CST:.*]] = arith.constant -1 : i32
@@ -597,3 +607,13 @@ subroutine acc_reduction_iand()
! CHECK-LABEL: func.func @_QPacc_reduction_iand()
! CHECK: %[[RED:.*]] = acc.reduction varPtr(%{{.*}} : !fir.ref<i32>) -> !fir.ref<i32> {name = "i"}
! CHECK: acc.parallel reduction(@reduction_iand_i32 -> %[[RED]] : !fir.ref<i32>)
+
+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<i32>) -> !fir.ref<i32> {name = "i"}
+! CHECK: acc.parallel reduction(@reduction_ior_i32 -> %[[RED]] : !fir.ref<i32>)
More information about the flang-commits
mailing list