Index: flang/test/Lower/OpenMP/simd.f90 =================================================================== --- flang/test/Lower/OpenMP/simd.f90 +++ flang/test/Lower/OpenMP/simd.f90 @@ -89,3 +89,40 @@ end do !$OMP END SIMD end subroutine + +!CHECK-LABEL: func @_QPsimdloop_with_collapse_clause +!CHECK: %[[VAL_0:.*]] = fir.alloca i32 {adapt.valuebyref} +!CHECK: %[[VAL_1:.*]] = fir.alloca i32 {adapt.valuebyref} +!CHECK: %[[LOWER_I:.*]] = arith.constant 1 : i32 +!CHECK: %[[UPPER_I:.*]] = fir.load %[[PARAM_ARG:.*]] : !fir.ref +!CHECK: %[[STEP_I:.*]] = arith.constant 1 : i32 +!CHECK: %[[LOWER_J:.*]] = arith.constant 1 : i32 +!CHECK: %[[UPPER_J:.*]] = fir.load %[[PARAM_ARG:.*]] : !fir.ref +!CHECK: %[[STEP_J:.*]] = arith.constant 1 : i32 +! CHECK-LABEL: omp.simdloop for ( +! CHECK: %[[ARG_0:.*]], %[[ARG_1:.*]]) : i32 = ( +! CHECK: %[[LOWER_I]], +! CHECK: %[[LOWER_J]]) to ( +! CHECK: %[[UPPER_I]], +! CHECK: %[[UPPER_J]]) inclusive step ( +! CHECK: %[[STEP_I]], +! CHECK: %[[STEP_J]]) { +! CHECK: fir.store %[[ARG_0]] to %[[VAL_1]] : !fir.ref +! CHECK: fir.store %[[ARG_1]] to %[[VAL_0]] : !fir.ref +! CHECK: fir.call @_QPfoo(%[[VAL_1]]) : (!fir.ref) -> () +! CHECK: fir.call @_QPbar(%[[VAL_0]]) : (!fir.ref) -> () +! CHECK: omp.yield +! CHECK: } +! CHECK: return + +subroutine simdloop_with_collapse_clause(n) +integer :: i, j, n + !$OMP SIMD collapse(2) + do i = 1, n + do j = 1, n + call foo(i) + call bar(j) + end do + end do + !$OMP END SIMD +end subroutine Index: mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td =================================================================== --- mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td +++ mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td @@ -412,6 +412,9 @@ The body region can contain any number of blocks. The region is terminated by "omp.yield" instruction without operands. + Collapsed loops are represented by the simd-loop having a list of indices, + bounds and steps where the size of the list is equal to the collapse value. + When an if clause is present and evaluates to false, the preferred number of iterations to be executed concurrently is one, regardless of whether a simdlen clause is speciļ¬ed.