File tree Expand file tree Collapse file tree 2 files changed +48
-7
lines changed
Expand file tree Collapse file tree 2 files changed +48
-7
lines changed Original file line number Diff line number Diff line change @@ -3274,19 +3274,19 @@ class FirConverter : public Fortran::lower::AbstractConverter {
32743274 for (auto *e : prologue) sunk.insert (e);
32753275 for (auto *e : epilogue) sunk.insert (e);
32763276
3277- auto emit = [&](llvm::SmallVector<Fortran::lower::pft::Evaluation *> &lst) {
3278- for (auto *e : lst) genFIR (*e);
3279- };
3277+ auto sink =
3278+ [&](llvm::SmallVector<Fortran::lower::pft::Evaluation *> &lst) {
3279+ for (auto *e : lst)
3280+ genFIR (*e);
3281+ };
32803282
3281- // Sink prologue
3282- emit (prologue);
3283+ sink (prologue);
32833284
32843285 // Lower innermost loop body, skipping sunk
32853286 for (Fortran::lower::pft::Evaluation &e : innermostLoopEval->getNestedEvaluations ())
32863287 if (!sunk.contains (&e)) genFIR (e);
32873288
3288- // Sink epilogue
3289- emit (epilogue);
3289+ sink (epilogue);
32903290 } else {
32913291 // Normal lowering
32923292 for (Fortran::lower::pft::Evaluation &e : curEval->getNestedEvaluations ())
Original file line number Diff line number Diff line change 1+ ! RUN: bbc -fopenacc -emit-hlfir %s -o - | FileCheck %s
2+
3+ ! Verify collapse(force:2) sinks prologue (between loops) and epilogue (after inner loop)
4+ ! into the acc.loop region body.
5+
6+ subroutine collapse_force_sink (n , m )
7+ integer , intent (in ) :: n, m
8+ real , dimension (n,m) :: a
9+ real , dimension (n) :: bb, cc
10+ integer :: i, j
11+
12+ ! $acc parallel loop collapse(force:2)
13+ do i = 1 , n
14+ bb(i) = 4.2 ! prologue (between loops)
15+ do j = 1 , m
16+ a(i,j) = a(i,j) + 2.0
17+ end do
18+ cc(i) = 7.3 ! epilogue (after inner loop)
19+ end do
20+ ! $acc end parallel loop
21+ end subroutine
22+
23+ ! CHECK: func.func @_QPcollapse_force_sink(
24+ ! CHECK: acc.parallel
25+ ! Ensure outer acc.loop is combined(parallel)
26+ ! CHECK: acc.loop combined(parallel)
27+ ! Prologue: constant 4.2 and an assign before inner loop
28+ ! CHECK: arith.constant 4.200000e+00
29+ ! CHECK: hlfir.assign
30+ ! Inner loop and its body include 2.0 add and an assign
31+ ! CHECK: acc.loop
32+ ! CHECK: arith.constant 2.000000e+00
33+ ! CHECK: arith.addf
34+ ! CHECK: hlfir.assign
35+ ! Epilogue: constant 7.3 and an assign after inner loop
36+ ! CHECK: arith.constant 7.300000e+00
37+ ! CHECK: hlfir.assign
38+ ! And the outer acc.loop has collapse = [2]
39+ ! CHECK: } attributes {collapse = [2]
40+
41+
You can’t perform that action at this time.
0 commit comments