[flang-commits] [flang] 305ad9a - [Flang][OpenMP] Use typed assignment in Atomic Write lowering
Kiran Chandramohan via flang-commits
flang-commits at lists.llvm.org
Fri Jul 14 02:22:03 PDT 2023
Author: Kiran Chandramohan
Date: 2023-07-14T09:21:34Z
New Revision: 305ad9a6b226063fbefe7650cdd5ed0433368b70
URL: https://github.com/llvm/llvm-project/commit/305ad9a6b226063fbefe7650cdd5ed0433368b70
DIFF: https://github.com/llvm/llvm-project/commit/305ad9a6b226063fbefe7650cdd5ed0433368b70.diff
LOG: [Flang][OpenMP] Use typed assignment in Atomic Write lowering
Use typed assignment in Atomic Write lowering to better handle
type conversions of allowed types.
Note: We should make similar changes for other constructs in
later patches.
Reviewed By: NimishMishra
Differential Revision: https://reviews.llvm.org/D154163
Added:
Modified:
flang/lib/Lower/OpenMP.cpp
flang/test/Lower/OpenMP/atomic-write.f90
Removed:
################################################################################
diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp
index 6cff384077188f..7e21281f145303 100644
--- a/flang/lib/Lower/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP.cpp
@@ -2358,16 +2358,16 @@ genOmpAtomicWrite(Fortran::lower::AbstractConverter &converter,
std::get<2>(atomicWrite.t);
const Fortran::parser::OmpAtomicClauseList &leftHandClauseList =
std::get<0>(atomicWrite.t);
- const auto &assignmentStmtExpr =
- std::get<Fortran::parser::Expr>(std::get<3>(atomicWrite.t).statement.t);
- const auto &assignmentStmtVariable = std::get<Fortran::parser::Variable>(
- std::get<3>(atomicWrite.t).statement.t);
+ const Fortran::parser::AssignmentStmt &stmt =
+ std::get<3>(atomicWrite.t).statement;
+ const Fortran::evaluate::Assignment &assign = *stmt.typedAssignment->v;
Fortran::lower::StatementContext stmtCtx;
// Get the value and address of atomic write operands.
- mlir::Value rhs_expr = fir::getBase(converter.genExprValue(
- *Fortran::semantics::GetExpr(assignmentStmtExpr), stmtCtx));
- mlir::Value lhs_addr = fir::getBase(converter.genExprAddr(
- *Fortran::semantics::GetExpr(assignmentStmtVariable), stmtCtx));
+ mlir::Value rhs_expr =
+ fir::getBase(converter.genExprValue(assign.rhs, stmtCtx));
+
+ mlir::Value lhs_addr =
+ fir::getBase(converter.genExprAddr(assign.lhs, stmtCtx));
genOmpAtomicWriteStatement(converter, eval, lhs_addr, rhs_expr,
&leftHandClauseList, &rightHandClauseList);
}
diff --git a/flang/test/Lower/OpenMP/atomic-write.f90 b/flang/test/Lower/OpenMP/atomic-write.f90
index 81887503b0c52e..949bf0b3cdb539 100644
--- a/flang/test/Lower/OpenMP/atomic-write.f90
+++ b/flang/test/Lower/OpenMP/atomic-write.f90
@@ -63,3 +63,13 @@ subroutine atomic_write_pointer()
x = 2
end
+!CHECK-LABEL: func.func @_QPatomic_write_typed_assign
+!CHECK: %[[VAR:.*]] = fir.alloca f32 {bindc_name = "r2", uniq_name = "{{.*}}r2"}
+!CHECK: %[[CST:.*]] = arith.constant 0.000000e+00 : f32
+!CHECK: omp.atomic.write %[[VAR]] = %[[CST]] : !fir.ref<f32>, f32
+
+subroutine atomic_write_typed_assign
+ real :: r2
+ !$omp atomic write
+ r2 = 0
+end subroutine
More information about the flang-commits
mailing list