[flang] [llvm] [flang][llvm][OpenMP][OpenACC] Add implicit casts to omp.atomic and acc.atomic (PR #131603)

via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 17 07:40:35 PDT 2025


================
@@ -386,6 +442,7 @@ void genOmpAccAtomicRead(Fortran::lower::AbstractConverter &converter,
       fir::getBase(converter.genExprAddr(fromExpr, stmtCtx));
   mlir::Value toAddress = fir::getBase(converter.genExprAddr(
       *Fortran::semantics::GetExpr(assignmentStmtVariable), stmtCtx));
+  emitImplicitCast(converter, loc, fromAddress, toAddress, elementType);
----------------
NimishMishra wrote:

@kiranchandramohan Thanks. I'll check the use of `typedAssignmentStatement`.

@tblah Okay, I see your concern. The read is no longer atomic. We will then be emitting two atomic reads, something like (for atomic read `y = x`):

```
%0 = x
%1 = y
%2 = fir.alloca i32
omp.atomic.read %3 = %0 : !fir.ref<f32>, !fir.ref<f32>, f32
%4 = fir.convert %3 : (f32) -> i32
fir.store %4 to %2: !fir.ref<i32>
omp.atomic.read %1 = %2 : !fir.ref<i32>, !fir.ref<i32>, i32
```

https://github.com/llvm/llvm-project/pull/131603


More information about the llvm-commits mailing list