]> granicus.if.org Git - clang/commit
[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)
commitf20a280b3ba367e83e1c21cfd4366cd55b8d20cb
tree1279d697cb55f69087ec59cb4acb82740d205f5e
parent44c160f916a1b080098b17b466b026aa07475ec2
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316229 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CGOpenMPRuntime.cpp
lib/CodeGen/CGStmtOpenMP.cpp
lib/Sema/SemaOpenMP.cpp
test/OpenMP/for_reduction_codegen.cpp
test/OpenMP/for_reduction_codegen_UDR.cpp