Home | History | Annotate | Download | only in OpenMP
      1 // RUN: %clang_cc1 -fopenmp=libiomp5 -emit-llvm %s -o - | FileCheck %s
      2 
      3 void h1(float *c, float *a, float *b, int size)
      4 {
      5 // CHECK-LABEL: define void @h1
      6   int t = 0;
      7 #pragma omp simd safelen(16) linear(t)
      8   for (int i = 0; i < size; ++i) {
      9     c[i] = a[i] * a[i] + b[i] * b[t];
     10     ++t;
     11 // do not emit parallel_loop_access metadata due to usage of safelen clause.
     12 // CHECK-NOT: store float {{.+}}, float* {{.+}}, align {{.+}}, !llvm.mem.parallel_loop_access {{![0-9]+}}
     13   }
     14 }
     15 
     16 void h2(float *c, float *a, float *b, int size)
     17 {
     18 // CHECK-LABEL: define void @h2
     19   int t = 0;
     20 #pragma omp simd linear(t)
     21   for (int i = 0; i < size; ++i) {
     22     c[i] = a[i] * a[i] + b[i] * b[t];
     23     ++t;
     24 // CHECK: store float {{.+}}, float* {{.+}}, align {{.+}}, !llvm.mem.parallel_loop_access [[LOOP_H2_HEADER:![0-9]+]]
     25   }
     26 }
     27 
     28 void h3(float *c, float *a, float *b, int size)
     29 {
     30 // CHECK-LABEL: define void @h3
     31 #pragma omp simd
     32   for (int i = 0; i < size; ++i) {
     33     for (int j = 0; j < size; ++j) {
     34       c[j*i] = a[i] * b[j];
     35     }
     36   }
     37 // do not emit parallel_loop_access for nested loop.
     38 // CHECK-NOT: store float {{.+}}, float* {{.+}}, align {{.+}}, !llvm.mem.parallel_loop_access {{![0-9]+}}
     39 }
     40 
     41 // Metadata for h1:
     42 // CHECK: [[LOOP_H1_HEADER:![0-9]+]] = metadata !{metadata [[LOOP_H1_HEADER]], metadata [[LOOP_WIDTH_16:![0-9]+]], metadata [[LOOP_VEC_ENABLE:![0-9]+]]}
     43 // CHECK: [[LOOP_WIDTH_16]] = metadata !{metadata !"llvm.loop.vectorize.width", i32 16}
     44 // CHECK: [[LOOP_VEC_ENABLE]] = metadata !{metadata !"llvm.loop.vectorize.enable", i1 true}
     45 //
     46 // Metadata for h2:
     47 // CHECK: [[LOOP_H2_HEADER]] = metadata !{metadata [[LOOP_H2_HEADER]], metadata [[LOOP_VEC_ENABLE]]}
     48 //
     49 // Metadata for h3:
     50 // CHECK: [[LOOP_H3_HEADER:![0-9]+]] = metadata !{metadata [[LOOP_H3_HEADER]], metadata [[LOOP_VEC_ENABLE]]}
     51 //
     52