Index: flang/lib/Lower/OpenMP.cpp =================================================================== --- flang/lib/Lower/OpenMP.cpp +++ flang/lib/Lower/OpenMP.cpp @@ -134,6 +134,9 @@ if constexpr (std::is_same_v) { mlir::ValueRange results; firOpBuilder.create(loc, results); + } else if constexpr (std::is_same_v) { + mlir::ValueRange results; + firOpBuilder.create(loc, results); } else { firOpBuilder.create(loc); } @@ -387,10 +390,13 @@ noWaitClauseOperand, orderedClauseOperand, orderClauseOperand; const auto &wsLoopOpClauseList = std::get( std::get(loopConstruct.t).t); - if (llvm::omp::OMPD_do != + const auto &LoopDirective = std::get( std::get(loopConstruct.t).t) - .v) { + .v; + + if (llvm::omp::OMPD_do != LoopDirective && + llvm::omp::OMPD_simd != LoopDirective) { TODO(converter.getCurrentLocation(), "Combined worksharing loop construct"); } @@ -421,6 +427,16 @@ } iv = bounds->name.thing.symbol; + // 2.9.3.1 SIMD construct + if (llvm::omp::OMPD_simd == LoopDirective) { + TypeRange resultType; + auto SimdLoopOp = firOpBuilder.create( + currentLocation, resultType, lowerBound, upperBound, step); + createBodyOfOp(SimdLoopOp, converter, currentLocation, + &wsLoopOpClauseList, iv); + return; + } + // FIXME: Add support for following clauses: // 1. linear // 2. order Index: flang/test/Lower/OpenMP/simd.f90 =================================================================== --- /dev/null +++ flang/test/Lower/OpenMP/simd.f90 @@ -0,0 +1,24 @@ +! Tests for 2.9.3.1 Simd + +! RUN: bbc -fopenmp -emit-fir %s -o - | tco -o - | FileCheck %s + +program simdloop + integer :: i + +!$OMP SIMD +do i=1, 9 + print*, i +end do +!$OMP END SIMD +end + + +! CHECK: %[[CALL1:.*]] = call i8* @_FortranAioBeginExternalListOutput(i32 -1, i8* getelementptr inbounds {{.*}}, !llvm.access.group ![[META1:[0-9]+]] +! CHECK: %[[CALL2:.*]] = call i1 @_FortranAioOutputInteger32{{.*}}, !llvm.access.group ![[META1:[0-9]+]] +! CHECK: %[[CALL3:.*]] = call i32 @_FortranAioEndIoStatement{{.*}}, !llvm.access.group ![[META1:[0-9]+]] +! CHECK: br label %[[LOOP_HEADER:.*]], !llvm.loop ![[META2:[0-9]+]] + +! CHECK: ![[META1:[0-9]+]] = distinct !{} +! CHECK: ![[META2]] = distinct !{![[META2]], ![[META3:[0-9]+]], ![[META4:[0-9]+]]} +! CHECK-NEXT: ![[META3]] = !{!"llvm.loop.parallel_accesses", ![[META1]]} +! CHECK-NEXT: ![[META4]] = !{!"llvm.loop.vectorize.enable", i1 true} \ No newline at end of file