force-parallel-4.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* Autopar with IF conditions. */
  2. void abort();
  3. #define N 10000
  4. #define T 1000
  5. void foo(void)
  6. {
  7. int i;
  8. int A[2*N], B[2*N];
  9. /* Initialize array: carried no dependency. */
  10. for (i = 0; i < 2*N; i++)
  11. B[i] = A[i] = i;
  12. for (i = 0; i < N; i++)
  13. {
  14. if (i < T)
  15. /* loop i1: carried no dependency. */
  16. A[i] = A[i+T];
  17. else
  18. /* loop i2: carried dependency. */
  19. A[i] = A[i+T+1];
  20. }
  21. /* If it runs a wrong answer, abort. */
  22. for (i = 0; i < N; i++)
  23. {
  24. if (i < T)
  25. {
  26. if (A[i] != B[i+T])
  27. abort();
  28. }
  29. else
  30. {
  31. if (A[i] != B[i+T+1])
  32. abort();
  33. }
  34. }
  35. }
  36. int main(void)
  37. {
  38. foo();
  39. return 0;
  40. }
  41. /* Check that parallel code generation part make the right answer. */
  42. /* { dg-final { scan-tree-dump-times "1 loops carried no dependency" 1 "graphite" } } */
  43. /* { dg-final { scan-tree-dump-times "2 loops carried no dependency" 1 "graphite" } } */
  44. /* { dg-final { cleanup-tree-dump "graphite" } } */
  45. /* { dg-final { scan-tree-dump-times "loopfn.0" 4 "optimized" } } */
  46. /* { dg-final { scan-tree-dump-times "loopfn.1" 4 "optimized" } } */
  47. /* { dg-final { cleanup-tree-dump "parloops" } } */
  48. /* { dg-final { cleanup-tree-dump "optimized" } } */