Index: flang/lib/Lower/OpenMP.cpp =================================================================== --- flang/lib/Lower/OpenMP.cpp +++ flang/lib/Lower/OpenMP.cpp @@ -1214,7 +1214,9 @@ TypeRange resultType; auto SimdLoopOp = firOpBuilder.create( currentLocation, resultType, lowerBound, upperBound, step, alignedVars, - nullptr, ifClauseOperand, simdlenClauseOperand, safelenClauseOperand, + nullptr, ifClauseOperand, + orderClauseOperand.dyn_cast_or_null(), + simdlenClauseOperand, safelenClauseOperand, /*inclusive=*/firOpBuilder.getUnitAttr()); createBodyOfOp(SimdLoopOp, converter, currentLocation, eval, &loopOpClauseList, iv); Index: mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td =================================================================== --- mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td +++ mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td @@ -393,6 +393,10 @@ iterations to be executed concurrently is one, regardless of whether a simdlen clause is speciļ¬ed. + The optional `order` attribute specifies which order the iterations of the + associate loops are executed in. Currently the only option for this + attribute is "concurrent". + When a simdlen clause is present, the preferred number of iterations to be executed concurrently is the value provided to the simdlen clause. @@ -415,6 +419,7 @@ Variadic:$aligned_vars, OptionalAttr:$alignment_values, Optional:$if_expr, + OptionalAttr:$order_val, ConfinedAttr, [IntPositive]>:$simdlen, ConfinedAttr, [IntPositive]>:$safelen, UnitAttr:$inclusive @@ -426,6 +431,7 @@ custom($aligned_vars, type($aligned_vars), $alignment_values) `)` |`if` `(` $if_expr `)` + |`order` `(` custom($order_val) `)` |`simdlen` `(` $simdlen `)` |`safelen` `(` $safelen `)` ) `for` custom($region, $lowerBound, $upperBound, $step, Index: mlir/test/Dialect/OpenMP/invalid.mlir =================================================================== --- mlir/test/Dialect/OpenMP/invalid.mlir +++ mlir/test/Dialect/OpenMP/invalid.mlir @@ -283,6 +283,16 @@ // ----- +func.func @omp_simdloop_order_value(%lb : index, %ub : index, %step : index) { + // expected-error @below {{invalid clause value: 'default'}} + omp.simdloop order(default) for (%iv): index = (%lb) to (%ub) step (%step) { + omp.yield + } + return +} + +// ----- + func.func @omp_simdloop_pretty_simdlen(%lb : index, %ub : index, %step : index) -> () { // expected-error @below {{op attribute 'simdlen' failed to satisfy constraint: 64-bit signless integer attribute whose value is positive}} omp.simdloop simdlen(0) for (%iv): index = (%lb) to (%ub) step (%step) { Index: mlir/test/Dialect/OpenMP/ops.mlir =================================================================== --- mlir/test/Dialect/OpenMP/ops.mlir +++ mlir/test/Dialect/OpenMP/ops.mlir @@ -398,6 +398,16 @@ return } +// CHECK-LABEL: omp_simdloop_pretty_order +func.func @omp_simdloop_pretty_order(%lb : index, %ub : index, %step : index) -> () { + // CHECK: omp.simdloop order(concurrent) + // CHECK-SAME: for (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}}) + omp.simdloop order(concurrent) for (%iv): index = (%lb) to (%ub) step (%step) { + omp.yield + } + return +} + // CHECK-LABEL: omp_simdloop_pretty_simdlen func.func @omp_simdloop_pretty_simdlen(%lb : index, %ub : index, %step : index) -> () { // CHECK: omp.simdloop simdlen(2) for (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}})