xref: /llvm-project/flang/test/Integration/OpenMP/workshare-scalar-array-mul.f90 (revision 5d38e6e42a90f5d469b5ff9e25e5e8865606776a)
1!===----------------------------------------------------------------------===!
2! This directory can be used to add Integration tests involving multiple
3! stages of the compiler (for eg. from Fortran to LLVM IR). It should not
4! contain executable tests. We should only add tests here sparingly and only
5! if there is no other way to test. Repeat this message in each test that is
6! added to this directory and sub-directories.
7!===----------------------------------------------------------------------===!
8
9!RUN: %flang_fc1 -emit-hlfir -fopenmp -O3 %s -o - | FileCheck %s --check-prefix HLFIR-O3
10!RUN: %flang_fc1 -emit-fir -fopenmp -O3 %s -o - | FileCheck %s --check-prefix FIR-O3
11
12!RUN: %flang_fc1 -emit-hlfir -fopenmp -O0 %s -o - | FileCheck %s --check-prefix HLFIR-O0
13!RUN: %flang_fc1 -emit-fir -fopenmp -O0 %s -o - | FileCheck %s --check-prefix FIR-O0
14
15program test
16  real :: arr_01(10)
17  !$omp parallel workshare
18    arr_01 = arr_01*2
19  !$omp end parallel workshare
20end program
21
22! HLFIR-O3:    omp.parallel {
23! HLFIR-O3:      omp.workshare {
24! HLFIR-O3:        hlfir.elemental
25! HLFIR-O3:        hlfir.assign
26! HLFIR-O3:        hlfir.destroy
27! HLFIR-O3:        omp.terminator
28! HLFIR-O3:      omp.terminator
29
30! FIR-O3:    omp.parallel {
31! FIR-O3:      omp.wsloop nowait {
32! FIR-O3:        omp.loop_nest
33! FIR-O3:      omp.barrier
34! FIR-O3:      omp.terminator
35
36! HLFIR-O0:    omp.parallel {
37! HLFIR-O0:      omp.workshare {
38! HLFIR-O0:        hlfir.elemental
39! HLFIR-O0:        hlfir.assign
40! HLFIR-O0:        hlfir.destroy
41! HLFIR-O0:        omp.terminator
42! HLFIR-O0:      omp.terminator
43
44! Check the copyprivate copy function
45! FIR-O0:  func.func private @_workshare_copy_heap_{{.*}}(%[[DST:.*]]: {{.*}}, %[[SRC:.*]]: {{.*}})
46! FIR-O0:    fir.load %[[SRC]]
47! FIR-O0:    fir.store {{.*}} to %[[DST]]
48
49! Check that we properly handle the temporary array
50! FIR-O0:    omp.parallel {
51! FIR-O0:      %[[CP:.*]] = fir.alloca !fir.heap<!fir.array<10xf32>>
52! FIR-O0:      omp.single copyprivate(%[[CP]] -> @_workshare_copy_heap_
53! FIR-O0:        fir.allocmem
54! FIR-O0:        fir.store
55! FIR-O0:        omp.terminator
56! FIR-O0:      fir.load %[[CP]]
57! FIR-O0:      omp.wsloop {
58! FIR-O0:        omp.loop_nest
59! FIR-O0:          omp.yield
60! FIR-O0:      omp.single nowait {
61! FIR-O0:        fir.call @_FortranAAssign
62! FIR-O0:        fir.freemem
63! FIR-O0:        omp.terminator
64! FIR-O0:      omp.barrier
65! FIR-O0:      omp.terminator
66