xref: /llvm-project/flang/test/Lower/OpenMP/generic-loop-rewriting.f90 (revision 81f544d4659a96772c7e2ffed1bbe557993f4b34)
1!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
2
3subroutine target_teams_loop
4    implicit none
5    integer :: x, i
6
7    !$omp target teams loop
8    do i = 0, 10
9      x = x + i
10    end do
11end subroutine target_teams_loop
12
13!CHECK-LABEL: func.func @_QPtarget_teams_loop
14!CHECK:         omp.target map_entries(
15!CHECK-SAME:      %{{.*}} -> %[[I_ARG:[^[:space:]]+]],
16!CHECK-SAME:      %{{.*}} -> %[[X_ARG:[^[:space:]]+]] : {{.*}}) {
17
18!CHECK:           %[[I_DECL:.*]]:2 = hlfir.declare %[[I_ARG]]
19!CHECK:           %[[X_DECL:.*]]:2 = hlfir.declare %[[X_ARG]]
20
21!CHECK:           omp.teams {
22
23!CHECK:             %[[LB:.*]] = arith.constant 0 : i32
24!CHECK:             %[[UB:.*]] = arith.constant 10 : i32
25!CHECK:             %[[STEP:.*]] = arith.constant 1 : i32
26
27!CHECK:             omp.parallel private(@{{.*}} %[[I_DECL]]#0
28!CHECK-SAME:          -> %[[I_PRIV_ARG:[^[:space:]]+]] : !fir.ref<i32>) {
29!CHECK:               omp.distribute {
30!CHECK:                 omp.wsloop {
31
32!CHECK:                   omp.loop_nest (%{{.*}}) : i32 =
33!CHECK-SAME:                (%[[LB]]) to (%[[UB]]) inclusive step (%[[STEP]]) {
34!CHECK:                     %[[I_PRIV_DECL:.*]]:2 = hlfir.declare %[[I_PRIV_ARG]]
35!CHECK:                     fir.store %{{.*}} to %[[I_PRIV_DECL]]#1 : !fir.ref<i32>
36!CHECK:                   }
37!CHECK:                 }
38!CHECK:               }
39!CHECK:             }
40!CHECK:           }
41!CHECK:         }
42