diff --git a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td --- a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td +++ b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td @@ -565,12 +565,14 @@ mandatory regions. 1. The initializer region specifies how to initialize the local reduction - value. The region has an argument that contains the value of the + value. The region has a first argument that contains the value of the reduction accumulator at the start of the reduction. It is expected to - `acc.yield` the new value. + `acc.yield` the new value. Extra arguments + can be added to deal with dynamic arrays. 2. The reduction region contains a sequences of operations to combine two - values of the reduction type into one. It has two arguments and it is - expected to `acc.yield` the combined value. + values of the reduction type into one. It has at least two arguments + and it is expected to `acc.yield` the combined value. Extra arguments + can be added to deal with dynamic arrays. Example: diff --git a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp --- a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp +++ b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp @@ -377,10 +377,10 @@ if (region.empty()) return op->emitOpError() << "expects non-empty " << regionName << " region"; Block &firstBlock = region.front(); - if (firstBlock.getNumArguments() != 1 || + if (firstBlock.getNumArguments() < 1 || firstBlock.getArgument(0).getType() != type) return op->emitOpError() << "expects " << regionName - << " region with one " + << " region first " "argument of the " << regionType << " type"; @@ -453,11 +453,11 @@ return emitOpError() << "expects non-empty combiner region"; Block &reductionBlock = getCombinerRegion().front(); - if (reductionBlock.getNumArguments() != 2 || + if (reductionBlock.getNumArguments() < 2 || reductionBlock.getArgument(0).getType() != getType() || reductionBlock.getArgument(1).getType() != getType()) - return emitOpError() << "expects combiner region with two arguments of " - << "the reduction type"; + return emitOpError() << "expects combiner region with the first two " + << "arguments of the reduction type"; for (YieldOp yieldOp : getCombinerRegion().getOps()) { if (yieldOp.getOperands().size() != 1 ||