| ! This test checks lowering of OpenMP DO Directive (Worksharing) | |
| ! with linear clause | |
| ! RUN: %flang_fc1 -fopenmp -emit-hlfir %s -o - 2>&1 | FileCheck %s --check-prefixes=CHECK,DEFAULT | |
| ! RUN: %flang_fc1 -fopenmp -fopenmp-version=52 -emit-hlfir %s -o - 2>&1 | FileCheck %s --check-prefixes=CHECK,OPENMP52 | |
| !CHECK: %[[X_alloca:.*]] = fir.alloca i32 <{bindc_name = "x", uniq_name = "_QFsimple_linearEx"}> | |
| !CHECK: %[[X:.*]]:2 = hlfir.declare %[[X_alloca]] {uniq_name = "_QFsimple_linearEx"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) | |
| !CHECK: %[[const:.*]] = arith.constant 1 : i32 | |
| subroutine simple_linear | |
| implicit none | |
| integer :: x, y, i | |
| !DEFAULT: omp.wsloop linear(%[[X]]#0 : !fir.ref<i32> = %[[const]] : i32) {{.*}} | |
| !OPENMP52: omp.wsloop linear(val(%[[X]]#0 : !fir.ref<i32> = %[[const]] : i32)) {{.*}} | |
| !$omp do linear(x) | |
| !CHECK: %[[LOAD:.*]] = fir.load %[[X]]#0 : !fir.ref<i32> | |
| !CHECK: %[[const:.*]] = arith.constant 2 : i32 | |
| !CHECK: %[[RESULT:.*]] = arith.addi %[[LOAD]], %[[const]] : i32 | |
| do i = 1, 10 | |
| y = x + 2 | |
| end do | |
| !$omp end do | |
| !CHECK: } | |
| end subroutine | |
| !CHECK: %[[X_alloca:.*]] = fir.alloca i32 <{bindc_name = "x", uniq_name = "_QFlinear_stepEx"}> | |
| !CHECK: %[[X:.*]]:2 = hlfir.declare %[[X_alloca]] {uniq_name = "_QFlinear_stepEx"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) | |
| subroutine linear_step | |
| implicit none | |
| integer :: x, y, i | |
| !CHECK: %[[const:.*]] = arith.constant 4 : i32 | |
| !DEFAULT: omp.wsloop linear(%[[X]]#0 : !fir.ref<i32> = %[[const]] : i32) {{.*}} | |
| !OPENMP52: omp.wsloop linear(val(%[[X]]#0 : !fir.ref<i32> = %[[const]] : i32)) {{.*}} | |
| !$omp do linear(x:4) | |
| !CHECK: %[[LOAD:.*]] = fir.load %[[X]]#0 : !fir.ref<i32> | |
| !CHECK: %[[const:.*]] = arith.constant 2 : i32 | |
| !CHECK: %[[RESULT:.*]] = arith.addi %[[LOAD]], %[[const]] : i32 | |
| do i = 1, 10 | |
| y = x + 2 | |
| end do | |
| !$omp end do | |
| !CHECK: } | |
| end subroutine | |
| !CHECK: %[[A_alloca:.*]] = fir.alloca i32 <{bindc_name = "a", uniq_name = "_QFlinear_exprEa"}> | |
| !CHECK: %[[A:.*]]:2 = hlfir.declare %[[A_alloca]] {uniq_name = "_QFlinear_exprEa"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) | |
| !CHECK: %[[X_alloca:.*]] = fir.alloca i32 <{bindc_name = "x", uniq_name = "_QFlinear_exprEx"}> | |
| !CHECK: %[[X:.*]]:2 = hlfir.declare %[[X_alloca]] {uniq_name = "_QFlinear_exprEx"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) | |
| subroutine linear_expr | |
| implicit none | |
| integer :: x, y, i, a | |
| !CHECK: %[[LOAD_A:.*]] = fir.load %[[A]]#0 : !fir.ref<i32> | |
| !CHECK: %[[const:.*]] = arith.constant 4 : i32 | |
| !CHECK: %[[LINEAR_EXPR:.*]] = arith.addi %[[LOAD_A]], %[[const]] : i32 | |
| !DEFAULT: omp.wsloop linear(%[[X]]#0 : !fir.ref<i32> = %[[LINEAR_EXPR]] : i32) {{.*}} | |
| !OPENMP52: omp.wsloop linear(val(%[[X]]#0 : !fir.ref<i32> = %[[LINEAR_EXPR]] : i32)) {{.*}} | |
| !$omp do linear(x:a+4) | |
| do i = 1, 10 | |
| y = x + 2 | |
| end do | |
| !$omp end do | |
| !CHECK: } | |
| end subroutine |