[flang-commits] [flang] [flang][acc] Fix crash on collapse(force:N) with non-tightly nested loops (PR #191310)
Razvan Lupusoru via flang-commits
flang-commits at lists.llvm.org
Thu Apr 16 20:06:44 PDT 2026
================
@@ -22,7 +23,47 @@ subroutine collapse_force_non_tight(a, n)
!$acc end parallel loop
end subroutine
-! CHECK: func.func @_QPcollapse_force_non_tight
+! CHECK-LABEL: func.func @_QPcollapse_force_non_tight
! CHECK: acc.parallel
-! CHECK: acc.loop
+! Only one acc.loop with 3 IVs
+! CHECK: acc.loop combined(parallel)
+! Prologue (tmp = i + j) inside the loop body
+! CHECK: arith.addi
+! Body assignment inside the loop body
+! CHECK: hlfir.designate
+! CHECK: hlfir.assign
! CHECK: collapse = [3]
+
+! -----
+
+! Test 2: collapse(force:2) with a non-collapsed inner !$acc loop.
+! The do k loop has its own !$acc loop directive and should NOT be
+! absorbed by the collapse — it must remain as a separate acc.loop.
+
+subroutine collapse_force_with_inner_acc_loop(a, n)
+ implicit none
+ integer, intent(in) :: n
+ real, intent(inout) :: a(n, n, n)
+ integer :: i, j, k
+
+ !$acc parallel loop collapse(force:2) copy(a)
----------------
razvanlupusoru wrote:
I would like to know if collapse(force:3) works for this case. And have some statements right before the inner acc loop.
https://github.com/llvm/llvm-project/pull/191310
More information about the flang-commits
mailing list