81 lines · plain
1// RUN: fir-opt --omp-generic-loop-conversion %s | FileCheck %s2 3omp.private {type = private} @_QFteams_loopEi_private_i32 : i324 5func.func @_QPteams_loop() {6 %i = fir.alloca i327 omp.teams {8 %c0 = arith.constant 0 : i329 %c10 = arith.constant 10 : i3210 %c1 = arith.constant 1 : i3211 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.yield15 }16 }17 omp.terminator18 }19 return20}21 22// CHECK-LABEL: func.func @_QPteams_loop23// CHECK: %[[I:.*]] = fir.alloca i3224// 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 can28// find the backward slices of these bounds that are within the `teams` region29// and move these slices to the `parallel` op.30 31// CHECK: %[[LB:.*]] = arith.constant 0 : i3232// CHECK: %[[UB:.*]] = arith.constant 10 : i3233// CHECK: %[[STEP:.*]] = arith.constant 1 : i3234// 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 49func.func @_QPparallel_loop() {50 %i = fir.alloca i3251 omp.parallel {52 %c0 = arith.constant 0 : i3253 %c10 = arith.constant 10 : i3254 %c1 = arith.constant 1 : i3255 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.yield59 }60 }61 omp.terminator62 }63 return64}65 66// CHECK-LABEL: func.func @_QPparallel_loop67// CHECK: %[[I:.*]] = fir.alloca i3268// CHECK: omp.parallel {69 70// CHECK: %[[LB:.*]] = arith.constant 0 : i3271// CHECK: %[[UB:.*]] = arith.constant 10 : i3272// CHECK: %[[STEP:.*]] = arith.constant 1 : i3273// 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: }81