Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / openmp / runtime / test / worksharing / sections / omp_parallel_sections_lastprivate.c
blob9b775ecd8af1ed665e7cc3181f534d5f770ae596
1 // RUN: %libomp-compile-and-run
2 #include <stdio.h>
3 #include "omp_testsuite.h"
5 int test_omp_parallel_sections_lastprivate()
7 int sum;
8 int sum0;
9 int i;
10 int i0;
11 int known_sum;
12 sum =0;
13 sum0 = 0;
14 i0 = -1;
16 #pragma omp parallel sections private(i,sum0) lastprivate(i0)
18 #pragma omp section
20 sum0=0;
21 for (i=1;i<400;i++) {
22 sum0=sum0+i;
23 i0=i;
25 #pragma omp critical
27 sum= sum+sum0;
30 #pragma omp section
32 sum0=0;
33 for(i=400;i<700;i++) {
34 sum0=sum0+i;
35 i0=i;
37 #pragma omp critical
39 sum= sum+sum0;
42 #pragma omp section
44 sum0=0;
45 for(i=700;i<1000;i++) {
46 sum0=sum0+i;
47 i0=i;
49 #pragma omp critical
51 sum= sum+sum0;
56 known_sum=(999*1000)/2;
57 return ((known_sum==sum) && (i0==999) );
60 int main()
62 int i;
63 int num_failed=0;
65 for(i = 0; i < REPETITIONS; i++) {
66 if(!test_omp_parallel_sections_lastprivate()) {
67 num_failed++;
70 return num_failed;