[flang-commits] [flang] [mlir] [flang][openacc][openmp] Support implicit casting on the atomic interface (PR #114390)
via flang-commits
flang-commits at lists.llvm.org
Sat Nov 2 12:06:24 PDT 2024
khaki3 wrote:
Another idea is to assume a converted reference type on the LHS of `atomic.read`. The verifier checks if `x`s of `read` and `write` are the same, so we cannot convert `x` only for `read`.
```
real :: n
integer :: x
!$acc atomic capture
n = x
x = n * n
!$acc end atomic
```
could become
```
%0 = fir.alloca f32 {bindc_name = "n", uniq_name = "_QFEn"}
%1:2 = hlfir.declare %0 {uniq_name = "_QFEn"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
%2 = fir.convert %1#1 : (!fir.ref<f32>) -> !fir.ref<i32>
%3 = fir.alloca i32 {bindc_name = "x", uniq_name = "_QFEx"}
%4:2 = hlfir.declare %3 {uniq_name = "_QFEx"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
%5 = fir.load %1#0 : !fir.ref<f32>
%6 = fir.load %1#0 : !fir.ref<f32>
%7 = arith.mulf %5, %6 fastmath<contract> : f32
%8 = fir.convert %7 : (f32) -> i32
acc.atomic.capture {
acc.atomic.read %2 = %4#1 : !fir.ref<i32>, f32
acc.atomic.write %4#1 = %8 : !fir.ref<i32>, i32
}
```
My first attempt was to extend the declaration of `read` to accept the original type of `v`. But it was a destructive change. The current change in this PR adds a temp for the `read` LHS.
https://github.com/llvm/llvm-project/pull/114390
More information about the flang-commits
mailing list