[OpenMP] Avoid VLAs for some reductions on array sections
authorJonas Hahnfeld <hahnjo@hahnjo.de>
Fri, 20 Oct 2017 19:40:40 +0000 (19:40 +0000)
committerJonas Hahnfeld <hahnjo@hahnjo.de>
Fri, 20 Oct 2017 19:40:40 +0000 (19:40 +0000)
commitb6229be46046d4e0cf3b8e37165a68cab1db0090
tree7038ae8abeaa63e0f361a49912b6710f904c869b
parent64e5d7d3ae3d138709bca57a972bce4803982b70
[OpenMP] Avoid VLAs for some reductions on array sections

In some cases the compiler can deduce the length of an array section
as constants. With this information, VLAs can be avoided in place of
a constant sized array or even a scalar value if the length is 1.
Example:
int a[4], b[2];
pragma omp parallel reduction(+: a[1:2], b[1:1])
{ }

For chained array sections, this optimization is restricted to cases
where all array sections except the last have a constant length 1.
This trivially guarantees that there are no holes in the memory region
that needs to be privatized.
Example:
int c[3][4];
pragma omp parallel reduction(+: c[1:1][1:2])
{ }

Differential Revision: https://reviews.llvm.org/D39136

llvm-svn: 316229
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/for_reduction_codegen.cpp
clang/test/OpenMP/for_reduction_codegen_UDR.cpp