diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-02 12:46:48 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-02 12:46:48 +0000 |
| commit | b5ea630dfd1a0d3e5c08d8959158608dd213d9aa (patch) | |
| tree | 414ded0ca2d2732345c4d423b8f3cd326d9097e8 /test/OpenMP/declare_reduction_codegen.cpp | |
| parent | 4bc3002fe03f32a9d85720bece65eeda40c75742 (diff) | |
Notes
Diffstat (limited to 'test/OpenMP/declare_reduction_codegen.cpp')
| -rw-r--r-- | test/OpenMP/declare_reduction_codegen.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/OpenMP/declare_reduction_codegen.cpp b/test/OpenMP/declare_reduction_codegen.cpp index 11ce4300118c5..ae6e047d94836 100644 --- a/test/OpenMP/declare_reduction_codegen.cpp +++ b/test/OpenMP/declare_reduction_codegen.cpp @@ -9,6 +9,26 @@ // CHECK: [[SSS_INT:.+]] = type { i32 } // CHECK-LOAD: [[SSS_INT:.+]] = type { i32 } +// CHECK: add +void add(short &out, short &in) {} + +#pragma omp declare reduction(my_add : short : add(omp_out, omp_in)) + +// CHECK: define internal void @. +// CHECK: call void @{{.+}}add{{.+}}( +// CHECK: ret void + +// CHECK: foo_reduction_array +void foo_reduction_array() { + short y[1]; + // CHECK: call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call( +#pragma omp parallel for reduction(my_add : y) + for (int i = 0; i < 1; i++) { + } +} + +// CHECK: define internal void @ + #pragma omp declare reduction(+ : int, char : omp_out *= omp_in) // CHECK: define internal {{.*}}void @{{[^(]+}}(i32* noalias, i32* noalias) // CHECK: [[MUL:%.+]] = mul nsw i32 @@ -92,6 +112,22 @@ T foo(T a) { return a; } +struct Summary { + void merge(const Summary& other) {} +}; + +template <typename K> +void work() { + Summary global_summary; +#pragma omp declare reduction(+ : Summary : omp_out.merge(omp_in)) +#pragma omp parallel for reduction(+ : global_summary) + for (int k = 1; k <= 100; ++k) { + } +} + +struct A {}; + + // CHECK-LABEL: @main int main() { int i = 0; @@ -110,6 +146,8 @@ int main() { // CHECK: call {{.*}}void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call( // CHECK: call {{.*}}void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call( // CHECK: call {{.*}}void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call({{[^@]*}} @{{[^@]*}}[[REGION:@[^ ]+]] + // CHECK-LABEL: work + work<A>(); // CHECK-LABEL: foo return foo(15); } |
