[PATCH] D39136: [OpenMP] Avoid VLAs for some reductions on array sections

Jonas Hahnfeld via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 20 12:27:08 PDT 2017


Hahnfeld created this revision.

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])
  { }


https://reviews.llvm.org/D39136

Files:
  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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39136.119687.patch
Type: text/x-patch
Size: 52429 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171020/00b9d0c0/attachment-0001.bin>


More information about the cfe-commits mailing list