pr66199-1.c 1.5 KB

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