[flang-commits] [flang] [flang] Add reduction semantics to fir.do_loop (PR #93934)
via flang-commits
flang-commits at lists.llvm.org
Mon Jun 3 15:03:09 PDT 2024
================
@@ -2238,6 +2285,17 @@ void fir::DoLoopOp::print(mlir::OpAsmPrinter &p) {
<< getUpperBound() << " step " << getStep();
if (getUnordered())
p << " unordered";
+ if (hasReduceOperands()) {
+ p << " reduce(";
+ auto attrs = getReduceAttrsAttr();
+ auto operands = getReduceOperands();
+ llvm::interleaveComma(llvm::zip(attrs, operands), p, [&](auto it) {
+ p << std::get<0>(it) << " -> " << std::get<1>(it) << " : "
+ << std::get<1>(it).getType();
+ });
+ p << ')';
+ printBlockTerminators = true;
+ }
----------------
khaki3 wrote:
`iter_args` affects the result types (e.g. `iter_args(%arg1 = %7) -> (index, i32)`). While we do not expect `reduce` to be coupled with `iter_args`, that is still acceptable. Which one should we choose?
- `iter_args(%arg1 = %7) reduce(...) -> (index, i32)`
- `reduce(...) iter_args(%arg1 = %7) -> (index, i32)`
https://github.com/llvm/llvm-project/pull/93934
More information about the flang-commits
mailing list