master_taskloop_simd_in_reduction_codegen.cpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c++ -emit-llvm %s -o - | FileCheck %s
  2. // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
  3. // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
  4. // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd -x c++ -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
  5. // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
  6. // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
  7. // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
  8. // expected-no-diagnostics
  9. #ifndef HEADER
  10. #define HEADER
  11. // CHECK: [[PRIVATES:%.+]] = type { i8*, i8* }
  12. struct S {
  13. int a;
  14. S() : a(0) {}
  15. S(const S&) {}
  16. S& operator=(const S&) {return *this;}
  17. ~S() {}
  18. friend S operator+(const S&a, const S&b) {return a;}
  19. };
  20. int main(int argc, char **argv) {
  21. int a;
  22. float b;
  23. S c[5];
  24. short d[argc];
  25. #pragma omp taskgroup task_reduction(+: a, b, argc)
  26. {
  27. #pragma omp taskgroup task_reduction(-:c, d)
  28. #pragma omp parallel
  29. #pragma omp master taskloop simd in_reduction(+:a) in_reduction(-:d)
  30. for (int i = 0; i < 5; ++i)
  31. a += d[a];
  32. }
  33. return 0;
  34. }
  35. // CHECK-LABEL: @main
  36. // CHECK: void @__kmpc_taskgroup(%struct.ident_t* @0, i32 [[GTID:%.+]])
  37. // CHECK: [[TD1:%.+]] = call i8* @__kmpc_task_reduction_init(i32 [[GTID]], i32 3, i8* %
  38. // CHECK-NEXT: store i8* [[TD1]], i8** [[TD1_ADDR:%[^,]+]],
  39. // CHECK-NEXT: call void @__kmpc_taskgroup(%struct.ident_t* @0, i32 [[GTID]])
  40. // CHECK: [[TD2:%.+]] = call i8* @__kmpc_task_reduction_init(i32 [[GTID]], i32 2, i8* %
  41. // CHECK-NEXT: store i8* [[TD2]], i8** [[TD2_ADDR:%[^,]+]],
  42. // CHECK-NEXT: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @0, i32 5, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i32*, i64, i16*, i8**, i8**)* [[OMP_PARALLEL:@.+]] to void (i32*, i32*, ...)*), i32* %{{.+}}, i64 %{{.+}}, i16* %{{.+}}, i8** [[TD1_ADDR]], i8** [[TD2_ADDR]])
  43. // CHECK-NEXT: call void @__kmpc_end_taskgroup(%struct.ident_t* @0, i32 [[GTID]])
  44. // CHECK-NEXT: call void @__kmpc_end_taskgroup(%struct.ident_t* @0, i32 [[GTID]])
  45. // CHECK: define internal void [[OMP_PARALLEL]](
  46. // CHECK: [[TASK_T:%.+]] = call i8* @__kmpc_omp_task_alloc(%struct.ident_t* @0, i32 [[GTID:%.+]], i32 1, i64 96, i64 40, i32 (i32, i8*)* bitcast (i32 (i32, [[T:%.+]]*)* [[OMP_TASK:@.+]] to i32 (i32, i8*)*))
  47. // CHECK-NEXT: [[TASK_T_WITH_PRIVS:%.+]] = bitcast i8* [[TASK_T]] to [[T]]*
  48. // CHECK: [[PRIVS:%.+]] = getelementptr inbounds [[T]], [[T]]* [[TASK_T_WITH_PRIVS]], i32 0, i32 1
  49. // CHECK: [[TD1_REF:%.+]] = getelementptr inbounds [[PRIVATES]], [[PRIVATES]]* [[PRIVS]], i32 0, i32 0
  50. // CHECK-NEXT: [[TD1_SHAR:%.+]] = getelementptr inbounds %
  51. // CHECK-NEXT: [[TD1_ADDR:%.+]] = load i8**, i8*** [[TD1_SHAR]],
  52. // CHECK-NEXT: [[TD1:%.+]] = load i8*, i8** [[TD1_ADDR]],
  53. // CHECK-NEXT: store i8* [[TD1]], i8** [[TD1_REF]],
  54. // CHECK-NEXT: [[TD2_REF:%.+]] = getelementptr inbounds [[PRIVATES]], [[PRIVATES]]* [[PRIVS]], i32 0, i32 1
  55. // CHECK-NEXT: [[TD2_SHAR:%.+]] = getelementptr inbounds %
  56. // CHECK-NEXT: [[TD2_ADDR:%.+]] = load i8**, i8*** [[TD2_SHAR]],
  57. // CHECK-NEXT: [[TD2:%.+]] = load i8*, i8** [[TD2_ADDR]],
  58. // CHECK-NEXT: store i8* [[TD2]], i8** [[TD2_REF]],
  59. // CHECK: call void @__kmpc_taskloop(%struct.ident_t* @0, i32 [[GTID]], i8* [[TASK_T]], i32 1,
  60. // CHECK: ret void
  61. // CHECK-NEXT: }
  62. // CHECK: define internal {{.*}} [[OMP_TASK]](
  63. // CHECK: call void (i8*, ...) %{{[^(]+}}(i8* %{{.+}}, i8*** [[TD1_REF:%[^,]+]], i8*** [[TD2_REF:%[^,]+]])
  64. // CHECK-NEXT: [[TD1_ADDR:%.+]] = load i8**, i8*** [[TD1_REF]],
  65. // CHECK-NEXT: [[TD2_ADDR:%.+]] = load i8**, i8*** [[TD2_REF]],
  66. // CHECK-NEXT: [[A_REF:%.+]] = getelementptr inbounds %
  67. // CHECK-NEXT: [[A_ADDR:%.+]] = load i32*, i32** [[A_REF]],
  68. // CHECK-NEXT: [[TD1:%.+]] = load i8*, i8** [[TD1_ADDR]],
  69. // CHECK-NEXT: [[GTID:%.+]] = load i32, i32* %
  70. // CHECK-NEXT: [[A_PTR:%.+]] = bitcast i32* [[A_ADDR]] to i8*
  71. // CHECK-NEXT: call i8* @__kmpc_task_reduction_get_th_data(i32 [[GTID]], i8* [[TD1]], i8* [[A_PTR]])
  72. // CHECK: [[D_REF:%.+]] = getelementptr inbounds %
  73. // CHECK-NEXT: [[D_ADDR:%.+]] = load i16*, i16** [[D_REF]],
  74. // CHECK: [[TD2:%.+]] = load i8*, i8** [[TD2_ADDR]],
  75. // CHECK-NEXT: [[D_PTR:%.+]] = bitcast i16* [[D_ADDR]] to i8*
  76. // CHECK-NEXT: call i8* @__kmpc_task_reduction_get_th_data(i32 [[GTID]], i8* [[TD2]], i8* [[D_PTR]])
  77. // CHECK: add nsw i32
  78. // CHECK: store i32 %
  79. #endif