Index: flang/lib/Lower/OpenMP.cpp =================================================================== --- flang/lib/Lower/OpenMP.cpp +++ flang/lib/Lower/OpenMP.cpp @@ -704,8 +704,8 @@ llvm::SmallVector lowerBound, upperBound, step, linearVars, linearStepVars, reductionVars; mlir::Value scheduleChunkClauseOperand; - mlir::Attribute scheduleClauseOperand, collapseClauseOperand, - noWaitClauseOperand, orderedClauseOperand, orderClauseOperand; + mlir::Attribute scheduleClauseOperand, noWaitClauseOperand, + orderedClauseOperand, orderClauseOperand; const auto &loopOpClauseList = std::get( std::get(loopConstruct.t).t); @@ -806,7 +806,6 @@ scheduleClauseOperand.dyn_cast_or_null(), scheduleChunkClauseOperand, /*schedule_modifiers=*/nullptr, /*simd_modifier=*/nullptr, - collapseClauseOperand.dyn_cast_or_null(), noWaitClauseOperand.dyn_cast_or_null(), orderedClauseOperand.dyn_cast_or_null(), orderClauseOperand.dyn_cast_or_null(), @@ -825,13 +824,6 @@ } else { wsLoopOp.ordered_valAttr(firOpBuilder.getI64IntegerAttr(0)); } - } else if (const auto &collapseClause = - std::get_if( - &clause.u)) { - const auto *expr = Fortran::semantics::GetExpr(collapseClause->v); - const std::optional collapseValue = - Fortran::evaluate::ToInt64(*expr); - wsLoopOp.collapse_valAttr(firOpBuilder.getI64IntegerAttr(*collapseValue)); } else if (const auto &scheduleClause = std::get_if( &clause.u)) { Index: flang/test/Lower/OpenMP/omp-wsloop-collapse.f90 =================================================================== --- flang/test/Lower/OpenMP/omp-wsloop-collapse.f90 +++ flang/test/Lower/OpenMP/omp-wsloop-collapse.f90 @@ -39,7 +39,7 @@ do i = 1, a do j= 1, b do k = 1, c -! CHECK: omp.wsloop collapse(3) for (%[[ARG0:.*]], %[[ARG1:.*]], %[[ARG2:.*]]) : i32 = (%[[VAL_20]], %[[VAL_23]], %[[VAL_26]]) to (%[[VAL_21]], %[[VAL_24]], %[[VAL_27]]) inclusive step (%[[VAL_22]], %[[VAL_25]], %[[VAL_28]]) { +! CHECK: omp.wsloop for (%[[ARG0:.*]], %[[ARG1:.*]], %[[ARG2:.*]]) : i32 = (%[[VAL_20]], %[[VAL_23]], %[[VAL_26]]) to (%[[VAL_21]], %[[VAL_24]], %[[VAL_27]]) inclusive step (%[[VAL_22]], %[[VAL_25]], %[[VAL_28]]) { ! CHECK: fir.store %[[ARG0]] to %[[STORE_IV0:.*]] : !fir.ref ! CHECK: fir.store %[[ARG1]] to %[[STORE_IV1:.*]] : !fir.ref ! CHECK: fir.store %[[ARG2]] to %[[STORE_IV2:.*]] : !fir.ref Index: flang/test/Lower/OpenMP/omp-wsloop-variable.f90 =================================================================== --- flang/test/Lower/OpenMP/omp-wsloop-variable.f90 +++ flang/test/Lower/OpenMP/omp-wsloop-variable.f90 @@ -22,7 +22,7 @@ !CHECK: %[[TMP5:.*]] = fir.convert %{{.*}} : (i128) -> i64 !CHECK: %[[TMP6:.*]] = fir.convert %[[TMP1]] : (i32) -> i64 !CHECK: %[[TMP7:.*]] = fir.convert %{{.*}} : (i32) -> i64 -!CHECK: omp.wsloop collapse(2) for (%[[ARG0:.*]], %[[ARG1:.*]]) : i64 = (%[[TMP2]], %[[TMP5]]) to (%[[TMP3]], %[[TMP6]]) inclusive step (%[[TMP4]], %[[TMP7]]) { +!CHECK: omp.wsloop for (%[[ARG0:.*]], %[[ARG1:.*]]) : i64 = (%[[TMP2]], %[[TMP5]]) to (%[[TMP3]], %[[TMP6]]) inclusive step (%[[TMP4]], %[[TMP7]]) { !CHECK: fir.store %[[ARG0]] to %[[STORE_IV0:.*]] : !fir.ref !CHECK: fir.store %[[ARG1]] to %[[STORE_IV1:.*]] : !fir.ref !CHECK: %[[LOAD_IV0:.*]] = fir.load %[[STORE_IV0]] : !fir.ref Index: mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td =================================================================== --- mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td +++ mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td @@ -308,7 +308,7 @@ `linear_step_vars` variadic lists should contain the same number of elements. - Reductions can be performed in a workshare loop by specifying reduction + Reductions can be performed in a worksharing-loop by specifying reduction accumulator variables in `reduction_vars` and symbols referring to reduction declarations in the `reductions` attribute. Each reduction is identified by the accumulator it uses and accumulators must not be repeated in the same @@ -325,9 +325,6 @@ The optional `schedule_chunk_var` associated with this determines further controls this distribution. - The optional `collapse_val` attribute specifies the number of loops which - are collapsed to form the worksharing loop. - The `nowait` attribute, when present, signifies that there should be no implicit barrier at the end of the loop. @@ -351,7 +348,6 @@ Optional:$schedule_chunk_var, OptionalAttr:$schedule_modifier, UnitAttr:$simd_modifier, - Confined, [IntMinValue<0>]>:$collapse_val, UnitAttr:$nowait, Confined, [IntMinValue<0>]>:$ordered_val, OptionalAttr:$order_val, @@ -366,7 +362,7 @@ let regions = (region AnyRegion:$region); let extraClassDeclaration = [{ - /// Returns the number of loops in the workshape loop nest. + /// Returns the number of loops in the worksharing-loop nest. unsigned getNumLoops() { return lowerBound().size(); } /// Returns the number of reduction variables. @@ -386,7 +382,6 @@ custom( $schedule_val, $schedule_modifier, $simd_modifier, $schedule_chunk_var, type($schedule_chunk_var)) `)` - |`collapse` `(` $collapse_val `)` |`nowait` $nowait |`ordered` `(` $ordered_val `)` |`order` `(` custom($order_val) `)` Index: mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp =================================================================== --- mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp +++ mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp @@ -740,8 +740,8 @@ /*linear_step_vars=*/ValueRange(), /*reduction_vars=*/ValueRange(), /*reductions=*/nullptr, /*schedule_val=*/nullptr, /*schedule_chunk_var=*/nullptr, /*schedule_modifier=*/nullptr, - /*simd_modifier=*/false, /*collapse_val=*/nullptr, /*nowait=*/false, - /*ordered_val=*/nullptr, /*order_val=*/nullptr, /*inclusive=*/false); + /*simd_modifier=*/false, /*nowait=*/false, /*ordered_val=*/nullptr, + /*order_val=*/nullptr, /*inclusive=*/false); state.addAttributes(attributes); } Index: mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp =================================================================== --- mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp +++ mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp @@ -696,15 +696,7 @@ if (loop.schedule_chunk_var()) { llvm::Value *chunkVar = moduleTranslation.lookupValue(loop.schedule_chunk_var()); - llvm::Type *chunkVarType = chunkVar->getType(); - assert(chunkVarType->isIntegerTy() && - "chunk size must be one integer expression"); - if (chunkVarType->getIntegerBitWidth() < ivType->getIntegerBitWidth()) - chunk = builder.CreateSExt(chunkVar, ivType); - else if (chunkVarType->getIntegerBitWidth() > ivType->getIntegerBitWidth()) - chunk = builder.CreateTrunc(chunkVar, ivType); - else - chunk = chunkVar; + chunk = builder.CreateSExtOrTrunc(chunkVar, ivType); } SmallVector reductionDecls; Index: mlir/test/Dialect/OpenMP/ops.mlir =================================================================== --- mlir/test/Dialect/OpenMP/ops.mlir +++ mlir/test/Dialect/OpenMP/ops.mlir @@ -136,12 +136,12 @@ // CHECK-LABEL: omp_wsloop func.func @omp_wsloop(%lb : index, %ub : index, %step : index, %data_var : memref, %linear_var : i32, %chunk_var : i32) -> () { - // CHECK: omp.wsloop collapse(2) ordered(1) + // CHECK: omp.wsloop ordered(1) // CHECK-SAME: for (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}}) "omp.wsloop" (%lb, %ub, %step) ({ ^bb0(%iv: index): omp.yield - }) {operand_segment_sizes = dense<[1,1,1,0,0,0,0]> : vector<7xi32>, collapse_val = 2, ordered_val = 1} : + }) {operand_segment_sizes = dense<[1,1,1,0,0,0,0]> : vector<7xi32>, ordered_val = 1} : (index, index, index) -> () // CHECK: omp.wsloop linear(%{{.*}} = %{{.*}} : memref) schedule(static) @@ -160,12 +160,12 @@ }) {operand_segment_sizes = dense<[1,1,1,2,2,0,0]> : vector<7xi32>, schedule_val = #omp<"schedulekind static">} : (index, index, index, memref, memref, i32, i32) -> () - // CHECK: omp.wsloop linear(%{{.*}} = %{{.*}} : memref) schedule(dynamic = %{{.*}}) collapse(3) ordered(2) + // CHECK: omp.wsloop linear(%{{.*}} = %{{.*}} : memref) schedule(dynamic = %{{.*}}) ordered(2) // CHECK-SAME: for (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}}) "omp.wsloop" (%lb, %ub, %step, %data_var, %linear_var, %chunk_var) ({ ^bb0(%iv: index): omp.yield - }) {operand_segment_sizes = dense<[1,1,1,1,1,0,1]> : vector<7xi32>, schedule_val = #omp<"schedulekind dynamic">, collapse_val = 3, ordered_val = 2} : + }) {operand_segment_sizes = dense<[1,1,1,1,1,0,1]> : vector<7xi32>, schedule_val = #omp<"schedulekind dynamic">, ordered_val = 2} : (index, index, index, memref, i32, i32) -> () // CHECK: omp.wsloop schedule(auto) nowait @@ -182,9 +182,9 @@ // CHECK-LABEL: omp_wsloop_pretty func.func @omp_wsloop_pretty(%lb : index, %ub : index, %step : index, %data_var : memref, %linear_var : i32, %chunk_var : i32, %chunk_var2 : i16) -> () { - // CHECK: omp.wsloop collapse(2) ordered(2) + // CHECK: omp.wsloop ordered(2) // CHECK-SAME: for (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}}) - omp.wsloop collapse(2) ordered(2) + omp.wsloop ordered(2) for (%iv) : index = (%lb) to (%ub) step (%step) { omp.yield } @@ -196,23 +196,23 @@ omp.yield } - // CHECK: omp.wsloop linear(%{{.*}} = %{{.*}} : memref) schedule(static = %{{.*}} : i32) collapse(3) ordered(2) + // CHECK: omp.wsloop linear(%{{.*}} = %{{.*}} : memref) schedule(static = %{{.*}} : i32) ordered(2) // CHECK-SAME: for (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}}) - omp.wsloop ordered(2) linear(%data_var = %linear_var : memref) schedule(static = %chunk_var : i32) collapse(3) + omp.wsloop ordered(2) linear(%data_var = %linear_var : memref) schedule(static = %chunk_var : i32) for (%iv) : index = (%lb) to (%ub) step (%step) { omp.yield } - // CHECK: omp.wsloop linear(%{{.*}} = %{{.*}} : memref) schedule(dynamic = %{{.*}} : i32, nonmonotonic) collapse(3) ordered(2) + // CHECK: omp.wsloop linear(%{{.*}} = %{{.*}} : memref) schedule(dynamic = %{{.*}} : i32, nonmonotonic) ordered(2) // CHECK-SAME: for (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}}) - omp.wsloop ordered(2) linear(%data_var = %linear_var : memref) schedule(dynamic = %chunk_var : i32, nonmonotonic) collapse(3) + omp.wsloop ordered(2) linear(%data_var = %linear_var : memref) schedule(dynamic = %chunk_var : i32, nonmonotonic) for (%iv) : index = (%lb) to (%ub) step (%step) { omp.yield } - // CHECK: omp.wsloop linear(%{{.*}} = %{{.*}} : memref) schedule(dynamic = %{{.*}} : i16, monotonic) collapse(3) ordered(2) + // CHECK: omp.wsloop linear(%{{.*}} = %{{.*}} : memref) schedule(dynamic = %{{.*}} : i16, monotonic) ordered(2) // CHECK-SAME: for (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}}) - omp.wsloop ordered(2) linear(%data_var = %linear_var : memref) schedule(dynamic = %chunk_var2 : i16, monotonic) collapse(3) + omp.wsloop ordered(2) linear(%data_var = %linear_var : memref) schedule(dynamic = %chunk_var2 : i16, monotonic) for (%iv) : index = (%lb) to (%ub) step (%step) { omp.yield } Index: mlir/test/Target/LLVMIR/openmp-llvm.mlir =================================================================== --- mlir/test/Target/LLVMIR/openmp-llvm.mlir +++ mlir/test/Target/LLVMIR/openmp-llvm.mlir @@ -1052,7 +1052,7 @@ // CHECK: %[[TOTAL_SUB_1:.*]] = sub i32 %[[TOTAL]], 1 // CHECK: store i32 %[[TOTAL_SUB_1]], ptr // CHECK: call void @__kmpc_for_static_init_4u - omp.wsloop collapse(3) + omp.wsloop for (%arg0, %arg1, %arg2) : i32 = (%0, %1, %2) to (%3, %4, %5) step (%6, %7, %8) { %31 = llvm.load %20 : !llvm.ptr %32 = llvm.add %31, %arg0 : i32 @@ -1113,7 +1113,7 @@ // CHECK: store i32 1, ptr // CHECK: store i32 %[[TOTAL]], ptr // CHECK: call void @__kmpc_dispatch_init_4u - omp.wsloop collapse(3) schedule(dynamic) + omp.wsloop schedule(dynamic) for (%arg0, %arg1, %arg2) : i32 = (%0, %1, %2) to (%3, %4, %5) step (%6, %7, %8) { %31 = llvm.load %20 : !llvm.ptr %32 = llvm.add %31, %arg0 : i32