[Openmp-commits] [clang] [llvm] [openmp] [Clang][OpenMP] Add `#pragma omp flatten` loop directive + `depth` clause (PR #206977)

Michael Kruse via Openmp-commits openmp-commits at lists.llvm.org
Wed Aug 12 03:28:48 PDT 2026


https://github.com/Meinersbur commented:

I think we need more tests:

Diagnostics output
 * Diagnostics when applied to a non-perfectly nested loop
 * depth argument diagnostics: `0`, `-1`, insufficient number of loops
 * depth argument is not a constant

Codegen/execution
 * When applied to a non-rectangular loop
 * Applied to the generated loops of other constructs: fuse, reverse, unroll, etc
 * Other loop-associated constructs applied to it, e.g. flatten+for, flatten+unroll, etc.
 * Applied onto itself: flatten + flatten ≈ flatten depth(3)
 * depth argument is a template parameter
 * Degenerate loop: `for (int i = 0; i < -1; ++i)`

Optional: A warning diagnostic if `depth` is omitted (so the default of 2 applies), but there are 3 or more loops that could be flattened

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


More information about the Openmp-commits mailing list