aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorkhaki3 <47756807+khaki3@users.noreply.github.com>2025-08-26 21:26:58 -0700
committerGitHub <noreply@github.com>2025-08-26 21:26:58 -0700
commit9a81d853cee219af05ee58959ea9c5e9ac69980e (patch)
tree7edb470a0ee9d7d41422c97019d1b5c6902ba0c5 /clang/lib/CodeGen/CodeGenModule.cpp
parentf44eaf47dc1357959d14cbf5f278c82e554689b2 (diff)
downloadllvm-9a81d853cee219af05ee58959ea9c5e9ac69980e.zip
llvm-9a81d853cee219af05ee58959ea9c5e9ac69980e.tar.gz
llvm-9a81d853cee219af05ee58959ea9c5e9ac69980e.tar.bz2
[flang][acc] Fix the indexing of the reduction combiner for multidimensional static arrays (#155536)
In the following example of reducing a static 2D array, we have incorrect coordinates for array access in the reduction combiner. This PR reverses the order of the induction variables used for such array indexing. For other cases of static arrays, we reverse the loop order as well so that the innermost loop can handle the innermost dimension. ```Fortran program main implicit none integer, parameter :: m = 2 integer, parameter :: n = 10 integer :: r(n,m), i r = 0 !$acc parallel loop reduction(+:r(:n,:m)) do i = 1, n r(i, 1) = i enddo print *, r end program main ``` Currently, we have: ```mlir fir.do_loop %arg2 = %c0 to %c1 step %c1 { fir.do_loop %arg3 = %c0 to %c9 step %c1 { %0 = fir.coordinate_of %arg0, %arg2, %arg3 : (!fir.ref<!fir.array<10x2xi32>>, index, index) -> !fir.ref<i32> %1 = fir.coordinate_of %arg1, %arg2, %arg3 : (!fir.ref<!fir.array<10x2xi32>>, index, index) -> !fir.ref<i32> ``` We'll obtain: ```mlir fir.do_loop %arg2 = %c0 to %c1 step %c1 { fir.do_loop %arg3 = %c0 to %c9 step %c1 { %0 = fir.coordinate_of %arg0, %arg3, %arg2 : (!fir.ref<!fir.array<10x2xi32>>, index, index) -> !fir.ref<i32> %1 = fir.coordinate_of %arg1, %arg3, %arg2 : (!fir.ref<!fir.array<10x2xi32>>, index, index) -> !fir.ref<i32> ```
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
0 files changed, 0 insertions, 0 deletions