[Mlir-commits] [mlir] [mlir][SCF] Add `RecursiveMemoryEffects` to `scf.reduce` (PR #75314)

Mehdi Amini llvmlistbot at llvm.org
Wed Dec 13 22:27:21 PST 2023


joker-eph wrote:

> I think it would be OK to CSE two identical reduce ops. The same reduce op token would be passed to the yield twice, indicating that there are two reductions. scf.reduce is just like a C++ lambda. (In theory, scf.reduce could even be allowed outside of scf.parallel ops then.)


It does not seems entirely safe to me: we can't structurally guarantee that the use-def chain can be tracked back to the reduce op (think "function outlining" for example).

>  I believe at the moment the reductions are guaranteed to be performed in the order in which they appear in the loop body

Is this documented? I'm not sure otherwise where would the guarantee come from?

> we could also just use scf.reduce as a terminator, with one region per reduction.

Seems like the most robust option to me?

https://github.com/llvm/llvm-project/pull/75314


More information about the Mlir-commits mailing list