LLVM OpenMP
final-values.c
Go to the documentation of this file.
1// RUN: %libomp-compile -fopenmp-version=61 && %libomp-run \
2// RUN: | FileCheck %s --match-full-lines
3
4#include <stdio.h>
5#include <stdlib.h>
6
7int main(void) {
8 int i = -1;
9 int j = -1;
10
11#pragma omp flatten
12 for (i = 0; i < 2; ++i)
13 for (j = 0; j < 3; ++j)
14 if (i == 1 && j == 2)
15 continue;
16
17 printf("i=%d j=%d\n", i, j);
18
19#pragma omp flatten
20 for (i = 5; i > 0; i -= 2)
21 for (j = 7; j > 1; j -= 3)
22 ;
23
24 printf("descending-i=%d descending-j=%d\n", i, j);
25
26 // An empty inner loop executes no body, but the outer loop still runs to
27 // completion, so 'i' reaches its final value while 'j' keeps the value from
28 // its initialization.
29 int Zero = 0;
30#pragma omp flatten
31 for (i = 0; i < 3; ++i)
32 for (j = 0; j < Zero; ++j)
33 ;
34
35 printf("empty-inner-i=%d empty-inner-j=%d\n", i, j);
36 return EXIT_SUCCESS;
37}
38
39// CHECK: i=2 j=3
40// CHECK-NEXT: descending-i=-1 descending-j=1
41// CHECK-NEXT: empty-inner-i=3 empty-inner-j=0
int main(void)
Definition final-values.c:7
#define i
Definition kmp_stub.cpp:88