pr66199-1.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* PR middle-end/66199 */
  2. /* { dg-do run } */
  3. /* { dg-options "-O2 -fopenmp" } */
  4. int u[1024], v[1024], w[1024];
  5. __attribute__((noinline, noclone)) long
  6. f1 (long a, long b)
  7. {
  8. long d;
  9. #pragma omp parallel for simd default(none) firstprivate (a, b) shared(u, v, w)
  10. for (d = a; d < b; d++)
  11. u[d] = v[d] + w[d];
  12. return d;
  13. }
  14. __attribute__((noinline, noclone)) long
  15. f2 (long a, long b, long c)
  16. {
  17. long d, e;
  18. #pragma omp parallel for simd default(none) firstprivate (a, b) shared(u, v, w) linear(d) linear(c:5) lastprivate(e)
  19. for (d = a; d < b; d++)
  20. {
  21. u[d] = v[d] + w[d];
  22. c += 5;
  23. e = c;
  24. }
  25. return d + c + e;
  26. }
  27. __attribute__((noinline, noclone)) long
  28. f3 (long a1, long b1, long a2, long b2)
  29. {
  30. long d1, d2;
  31. #pragma omp parallel for simd default(none) firstprivate (a1, b1, a2, b2) shared(u, v, w) lastprivate(d1, d2) collapse(2)
  32. for (d1 = a1; d1 < b1; d1++)
  33. for (d2 = a2; d2 < b2; d2++)
  34. u[d1 * 32 + d2] = v[d1 * 32 + d2] + w[d1 * 32 + d2];
  35. return d1 + d2;
  36. }
  37. __attribute__((noinline, noclone)) long
  38. f4 (long a1, long b1, long a2, long b2)
  39. {
  40. long d1, d2;
  41. #pragma omp parallel for simd default(none) firstprivate (a1, b1, a2, b2) shared(u, v, w) collapse(2)
  42. for (d1 = a1; d1 < b1; d1++)
  43. for (d2 = a2; d2 < b2; d2++)
  44. u[d1 * 32 + d2] = v[d1 * 32 + d2] + w[d1 * 32 + d2];
  45. return d1 + d2;
  46. }
  47. int
  48. main ()
  49. {
  50. if (f1 (0, 1024) != 1024
  51. || f2 (0, 1024, 17) != 1024 + 2 * (17 + 5 * 1024)
  52. || f3 (0, 32, 0, 32) != 64
  53. || f4 (0, 32, 0, 32) != 64)
  54. __builtin_abort ();
  55. return 0;
  56. }