[clang] [llvm] [openmp] [Clang][OpenMP] Add `#pragma omp flatten` loop directive + `depth` clause (PR #206977)
Amit Tiwari via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 18 05:46:08 PDT 2026
loopacino wrote:
> I think we need more tests:
>
> Diagnostics output
>
> * Diagnostics when applied to a non-perfectly nested loop
clang/test/OpenMP/flatten_messages.cpp
> * depth argument diagnostics: `0`, `-1`, insufficient number of loops
> * depth argument is not a constant
clang/test/OpenMP/flatten_depth_messages.cpp
>
> Codegen/execution
>
> * When applied to a non-rectangular loop
It would be a Sema error. There is no IR or run test, because the code is not allowed to compile. Kept diag test only at clang/test/OpenMP/flatten_messages.cpp
> * Applied to the generated loops of other constructs: fuse, reverse, unroll, etc
Flatten around reverse/unroll/another flatten does not compile (flatten_messages.cpp). reverse on flatten AST only: flatten_ast_print.cpp.
> * Other loop-associated constructs applied to it, e.g. flatten+for, flatten+unroll, etc.
unroll/tile codegen (flatten_codegen.cpp), runtime: unroll-on-flatten.c/tile-on-flatten.c/reverse-on-flatten.c, interchange is an error
> * Applied onto itself: flatten + flatten ≈ flatten depth(3)
openmp/runtime/test/transform/flatten/depth-intfor.c
> * depth argument is a template parameter
clang/test/OpenMP/flatten_depth_codegen.cpp
> * Degenerate loop: `for (int i = 0; i < -1; ++i)`
openmp/runtime/test/transform/flatten/empty.c,
>
> 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
Done in SemaOpenMP.cpp
https://github.com/llvm/llvm-project/pull/206977
More information about the cfe-commits
mailing list