| 1 |
// RUN: fir-opt --omp-generic-loop-conversion %s | FileCheck %s |
| 2 |
|
| 3 |
omp.private {type = private} @_QFteams_loopEi_private_i32 : i32 |
| 4 |
|
| 5 |
func.func @_QPteams_loop() { |
| 6 |
%i = fir.alloca i32 |
| 7 |
omp.teams { |
| 8 |
%c0 = arith.constant 0 : i32 |
| 9 |
%c10 = arith.constant 10 : i32 |
| 10 |
%c1 = arith.constant 1 : i32 |
| 11 |
omp.loop private(@_QFteams_loopEi_private_i32 %i -> %arg2 : !fir.ref<i32>) { |
| 12 |
omp.loop_nest (%arg3) : i32 = (%c0) to (%c10) inclusive step (%c1) { |
| 13 |
fir.store %arg3 to %arg2 : !fir.ref<i32> |
| 14 |
omp.yield |
| 15 |
} |
| 16 |
} |
| 17 |
omp.terminator |
| 18 |
} |
| 19 |
return |
| 20 |
} |
| 21 |
|
| 22 |
// CHECK-LABEL: func.func @_QPteams_loop |
| 23 |
// CHECK: %[[I:.*]] = fir.alloca i32 |
| 24 |
// CHECK: omp.teams { |
| 25 |
// |
| 26 |
// TODO we probably need to move the `loop_nest` bounds ops from the `teams` |
| 27 |
// region to the `parallel` region to avoid making these values `shared`. We can |
| 28 |
// find the backward slices of these bounds that are within the `teams` region |
| 29 |
// and move these slices to the `parallel` op. |
| 30 |
|
| 31 |
// CHECK: %[[LB:.*]] = arith.constant 0 : i32 |
| 32 |
// CHECK: %[[UB:.*]] = arith.constant 10 : i32 |
| 33 |
// CHECK: %[[STEP:.*]] = arith.constant 1 : i32 |
| 34 |
// |
| 35 |
// CHECK: omp.parallel private(@{{.*}} %[[I]] |
| 36 |
// CHECK-SAME: -> %[[I_PRIV_ARG:[^[:space:]]+]] : !fir.ref<i32>) { |
| 37 |
// CHECK: omp.distribute { |
| 38 |
// CHECK: omp.wsloop { |
| 39 |
// |
| 40 |
// CHECK: omp.loop_nest (%{{.*}}) : i32 = |
| 41 |
// CHECK-SAME: (%[[LB]]) to (%[[UB]]) inclusive step (%[[STEP]]) { |
| 42 |
// CHECK: fir.store %{{.*}} to %[[I_PRIV_ARG]] : !fir.ref<i32> |
| 43 |
// CHECK: } |
| 44 |
// CHECK: } |
| 45 |
// CHECK: } |
| 46 |
// CHECK: } |
| 47 |
// CHECK: } |
| 48 |
|
| 49 |
func.func @_QPparallel_loop() { |
| 50 |
%i = fir.alloca i32 |
| 51 |
omp.parallel { |
| 52 |
%c0 = arith.constant 0 : i32 |
| 53 |
%c10 = arith.constant 10 : i32 |
| 54 |
%c1 = arith.constant 1 : i32 |
| 55 |
omp.loop private(@_QFteams_loopEi_private_i32 %i -> %arg2 : !fir.ref<i32>) { |
| 56 |
omp.loop_nest (%arg3) : i32 = (%c0) to (%c10) inclusive step (%c1) { |
| 57 |
fir.store %arg3 to %arg2 : !fir.ref<i32> |
| 58 |
omp.yield |
| 59 |
} |
| 60 |
} |
| 61 |
omp.terminator |
| 62 |
} |
| 63 |
return |
| 64 |
} |
| 65 |
|
| 66 |
// CHECK-LABEL: func.func @_QPparallel_loop |
| 67 |
// CHECK: %[[I:.*]] = fir.alloca i32 |
| 68 |
// CHECK: omp.parallel { |
| 69 |
|
| 70 |
// CHECK: %[[LB:.*]] = arith.constant 0 : i32 |
| 71 |
// CHECK: %[[UB:.*]] = arith.constant 10 : i32 |
| 72 |
// CHECK: %[[STEP:.*]] = arith.constant 1 : i32 |
| 73 |
// CHECK: omp.wsloop private(@{{.*}} %[[I]] |
| 74 |
// CHECK-SAME: -> %[[I_PRIV_ARG:[^[:space:]]+]] : !fir.ref<i32>) { |
| 75 |
// CHECK: omp.loop_nest (%{{.*}}) : i32 = |
| 76 |
// CHECK-SAME: (%[[LB]]) to (%[[UB]]) inclusive step (%[[STEP]]) { |
| 77 |
// CHECK: fir.store %{{.*}} to %[[I_PRIV_ARG]] : !fir.ref<i32> |
| 78 |
// CHECK: } |
| 79 |
// CHECK: } |
| 80 |
// CHECK: } |