[flang-commits] [flang] [llvm] [flang-rt] - Lightweight runtime assignment function (AssignSimple) for intrinsic-type assignments (PR #213704)
Tom Eccles via flang-commits
flang-commits at lists.llvm.org
Thu Aug 6 04:00:42 PDT 2026
tblah wrote:
> The testcase in the bug this addresses still needs it (#203915). It would be worthwhile to examine why `InlineHFLIRAssign` isn't able to inline the assignment in this case.
When I ran flang at this branch with `flang -fc1 -emit-fir issue-203915.f90 -o - -O3 -fopenmp` I can't see any assign runtime call in the copy region of omp.private.
```
./bin/flang --version
flang version 24.0.0git (git at github.com:llvm/llvm-project.git 48505dbcdb9070f6c6c443b9b495dc13bb0cca20)
```
```
omp.private {type = firstprivate} @_QFEsource_firstprivate_box_8xi32 : !fir.box<!fir.array<8xi32>> init {
^bb0(%arg0: !fir.ref<!fir.box<!fir.array<8xi32>>>, %arg1: !fir.ref<!fir.box<!fir.array<8xi32>>>):
%c1 = arith.constant 1 : index
%c8 = arith.constant 8 : index
%0 = fir.shape %c8 : (index) -> !fir.shape<1>
%1 = fir.allocmem !fir.array<8xi32> {bindc_name = ".tmp", uniq_name = ""}
%2 = fir.declare %1(%0) {uniq_name = ".tmp"} : (!fir.heap<!fir.array<8xi32>>, !fir.shape<1>) -> !fir.heap<!fir.array<8xi32>>
%3 = fir.shape_shift %c1, %c8 : (index, index) -> !fir.shapeshift<1>
%4 = fir.embox %2(%3) : (!fir.heap<!fir.array<8xi32>>, !fir.shapeshift<1>) -> !fir.box<!fir.array<8xi32>>
fir.store %4 to %arg1 : !fir.ref<!fir.box<!fir.array<8xi32>>>
omp.yield(%arg1 : !fir.ref<!fir.box<!fir.array<8xi32>>>)
} copy {
^bb0(%arg0: !fir.ref<!fir.box<!fir.array<8xi32>>>, %arg1: !fir.ref<!fir.box<!fir.array<8xi32>>>):
%c0 = arith.constant 0 : index
%c1 = arith.constant 1 : index
%c8 = arith.constant 8 : index
%0 = fir.load %arg0 : !fir.ref<!fir.box<!fir.array<8xi32>>>
%1 = fir.load %arg1 : !fir.ref<!fir.box<!fir.array<8xi32>>>
fir.do_loop %arg2 = %c1 to %c8 step %c1 unordered {
%2:3 = fir.box_dims %0, %c0 : (!fir.box<!fir.array<8xi32>>, index) -> (index, index, index)
%3 = arith.subi %2#0, %c1 : index
%4 = arith.addi %arg2, %3 : index
%c0_0 = arith.constant 0 : index
%5:3 = fir.box_dims %0, %c0_0 : (!fir.box<!fir.array<8xi32>>, index) -> (index, index, index)
%6 = fir.shift %5#0 : (index) -> !fir.shift<1>
%7 = fir.array_coor %0(%6) %4 : (!fir.box<!fir.array<8xi32>>, !fir.shift<1>, index) -> !fir.ref<i32>
%8 = fir.load %7 : !fir.ref<i32>
%9:3 = fir.box_dims %1, %c0 : (!fir.box<!fir.array<8xi32>>, index) -> (index, index, index)
%10 = arith.subi %9#0, %c1 : index
%11 = arith.addi %arg2, %10 : index
%c0_1 = arith.constant 0 : index
%12:3 = fir.box_dims %1, %c0_1 : (!fir.box<!fir.array<8xi32>>, index) -> (index, index, index)
%13 = fir.shift %12#0 : (index) -> !fir.shift<1>
%14 = fir.array_coor %1(%13) %11 : (!fir.box<!fir.array<8xi32>>, !fir.shift<1>, index) -> !fir.ref<i32>
fir.store %8 to %14 : !fir.ref<i32>
}
omp.yield(%arg1 : !fir.ref<!fir.box<!fir.array<8xi32>>>)
} dealloc {
^bb0(%arg0: !fir.ref<!fir.box<!fir.array<8xi32>>>):
%c0_i64 = arith.constant 0 : i64
%0 = fir.load %arg0 : !fir.ref<!fir.box<!fir.array<8xi32>>>
%1 = fir.box_addr %0 : (!fir.box<!fir.array<8xi32>>) -> !fir.ref<!fir.array<8xi32>>
%2 = fir.convert %1 : (!fir.ref<!fir.array<8xi32>>) -> i64
%3 = arith.cmpi ne, %2, %c0_i64 : i64
fir.if %3 {
%4 = fir.convert %1 : (!fir.ref<!fir.array<8xi32>>) -> !fir.heap<!fir.array<8xi32>>
fir.freemem %4 : !fir.heap<!fir.array<8xi32>>
}
omp.yield
}
```
https://github.com/llvm/llvm-project/pull/213704
More information about the flang-commits
mailing list