LLVM OpenMP
nest-zero-trip.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// After flatten of a loop nest, each loop variable must hold the value it
5// would have without the directive. An inner loop variable is only assigned
6// if every enclosing loop has iterations.
7
8#include <stdlib.h>
9#include <stdio.h>
10
11static void flatten(int n, int m) {
12 int i = 77, j = 111;
13#pragma omp flatten
14 for (i = 0; i < n; i++)
15 for (j = 0; j < m; j++)
16 ;
17 printf("flatten n=%d m=%d: i=%d j=%d\n", n, m, i, j);
18}
19
20int main() {
21 // Outer loop never runs: j untouched.
22 flatten(0, 5);
23 // Inner loop never runs: j gets its init value.
24 flatten(6, 0);
25 // All loops run: exit values.
26 flatten(6, 5);
27 return EXIT_SUCCESS;
28}
29
30// CHECK: flatten n=0 m=5: i=0 j=111
31// CHECK-NEXT: flatten n=6 m=0: i=6 j=0
32// CHECK-NEXT: flatten n=6 m=5: i=6 j=5
static void flatten(int n, int m)
int main()
#define i
Definition kmp_stub.cpp:88