xref: /llvm-project/flang/test/Driver/omp-cse-region-boundary.f90 (revision fb4bdf361feecfd0863c1553ec14ef9928027a24)
1!This test checks that when compiling an OpenMP program for the target device
2!CSE is not done across target op region boundaries. It also checks that when
3!compiling for the host CSE is done.
4!RUN: %flang_fc1 -fopenmp-is-target-device -emit-mlir -fopenmp %s -o - | fir-opt -cse | FileCheck %s -check-prefix=CHECK-DEVICE
5!RUN: %flang_fc1 -emit-mlir -fopenmp %s -o - | fir-opt -cse | FileCheck %s -check-prefix=CHECK-HOST
6!RUN: bbc -fopenmp-is-target-device -emit-fir -fopenmp %s -o - | fir-opt -cse | FileCheck %s -check-prefix=CHECK-DEVICE
7!RUN: bbc -emit-fir -fopenmp %s -o - | fir-opt -cse | FileCheck %s -check-prefix=CHECK-HOST
8
9!Constant should be present inside target region.
10!CHECK-DEVICE: omp.target
11!CHECK-DEVICE: arith.constant 10
12!CHECK-DEVICE: omp.terminator
13
14!Constant should not be present inside target region.
15!CHECK-HOST: omp.target
16!CHECK-NOT-HOST: arith.constant 10
17!CHECK-HOST: omp.terminator
18
19subroutine writeIndex(sum)
20        integer :: sum
21        integer :: myconst1
22        integer :: myconst2
23        myconst1 = 10
24!$omp target map(from:myconst2)
25        myconst2 = 10
26!$omp end target
27        sum = myconst2 + myconst2
28end subroutine writeIndex
29