1! Tests for 2.9.3.1 Simd
2
3! RUN: bbc -fopenmp -emit-fir %s -o - | FileCheck %s
4
5!CHECK-LABEL: func @_QPsimdloop()
6subroutine simdloop
7integer :: i
8  !$OMP SIMD
9  ! CHECK: %[[LB:.*]] = arith.constant 1 : i32
10  ! CHECK-NEXT: %[[UB:.*]] = arith.constant 9 : i32
11  ! CHECK-NEXT: %[[STEP:.*]] = arith.constant 1 : i32
12  ! CHECK-NEXT: omp.simdloop for (%[[I:.*]]) : i32 = (%[[LB]]) to (%[[UB]]) inclusive step (%[[STEP]]) {
13  do i=1, 9
14    ! CHECK: fir.store %[[I]] to %[[LOCAL:.*]] : !fir.ref<i32>
15    ! CHECK: %[[LD:.*]] = fir.load %[[LOCAL]] : !fir.ref<i32>
16    ! CHECK: fir.call @_FortranAioOutputInteger32({{.*}}, %[[LD]]) : (!fir.ref<i8>, i32) -> i1
17    print*, i
18  end do
19  !$OMP END SIMD
20end subroutine
21
22!CHECK-LABEL: func @_QPsimdloop_with_if_clause
23subroutine simdloop_with_if_clause(n, threshold)
24integer :: i, n, threshold
25  !$OMP SIMD IF( n .GE. threshold )
26  ! CHECK: %[[LB:.*]] = arith.constant 1 : i32
27  ! CHECK: %[[UB:.*]] = fir.load %arg0
28  ! CHECK: %[[STEP:.*]] = arith.constant 1 : i32
29  ! CHECK: %[[COND:.*]] = arith.cmpi sge
30  ! CHECK: omp.simdloop if(%[[COND:.*]]) for (%[[I:.*]]) : i32 = (%[[LB]]) to (%[[UB]]) inclusive  step (%[[STEP]]) {
31  do i = 1, n
32    ! CHECK: fir.store %[[I]] to %[[LOCAL:.*]] : !fir.ref<i32>
33    ! CHECK: %[[LD:.*]] = fir.load %[[LOCAL]] : !fir.ref<i32>
34    ! CHECK: fir.call @_FortranAioOutputInteger32({{.*}}, %[[LD]]) : (!fir.ref<i8>, i32) -> i1
35    print*, i
36  end do
37  !$OMP END SIMD
38end subroutine
39