ast-print-pragmas.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // RUN: %clang_cc1 -ast-print %s -o - | FileCheck %s
  2. // FIXME: A bug in ParsedAttributes causes the order of the attributes to be
  3. // reversed. The checks are consequently in the reverse order below.
  4. // CHECK: #pragma clang loop interleave_count(8)
  5. // CHECK-NEXT: #pragma clang loop vectorize_width(4)
  6. void test(int *List, int Length) {
  7. int i = 0;
  8. #pragma clang loop vectorize_width(4)
  9. #pragma clang loop interleave_count(8)
  10. // CHECK-NEXT: while (i < Length)
  11. while (i < Length) {
  12. List[i] = i * 2;
  13. i++;
  14. }
  15. // CHECK: #pragma clang loop interleave(disable)
  16. // CHECK-NEXT: #pragma clang loop vectorize(enable)
  17. #pragma clang loop vectorize(enable)
  18. #pragma clang loop interleave(disable)
  19. // CHECK-NEXT: while (i - 1 < Length)
  20. while (i - 1 < Length) {
  21. List[i] = i * 2;
  22. i++;
  23. }
  24. // CHECK: #pragma clang loop interleave(enable)
  25. // CHECK-NEXT: #pragma clang loop vectorize(disable)
  26. #pragma clang loop vectorize(disable)
  27. #pragma clang loop interleave(enable)
  28. // CHECK-NEXT: while (i - 2 < Length)
  29. while (i - 2 < Length) {
  30. List[i] = i * 2;
  31. i++;
  32. }
  33. }
  34. template <int V, int I>
  35. void test_nontype_template_param(int *List, int Length) {
  36. #pragma clang loop vectorize_width(V) interleave_count(I)
  37. for (int i = 0; i < Length; i++) {
  38. List[i] = i;
  39. }
  40. }
  41. // CHECK: #pragma clang loop interleave_count(I)
  42. // CHECK: #pragma clang loop vectorize_width(V)
  43. void test_templates(int *List, int Length) {
  44. test_nontype_template_param<2, 4>(List, Length);
  45. }