parloops-exit-first-loop-alt-2.c 757 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* { dg-do run } */
  2. /* { dg-additional-options "-ftree-parallelize-loops=2" } */
  3. /* Constant bound, vector addition. */
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #define N 1000
  7. unsigned int a[N];
  8. unsigned int b[N];
  9. unsigned int c[N];
  10. void __attribute__((noclone,noinline))
  11. f (void)
  12. {
  13. int i;
  14. for (i = 0; i < N; ++i)
  15. c[i] = a[i] + b[i];
  16. }
  17. int
  18. main (void)
  19. {
  20. int i, j;
  21. /* Complexify loop to inhibit parloops. */
  22. for (j = 0; j < 100; ++j)
  23. for (i = 0; i < 10; i++)
  24. {
  25. int k = i + (10 * j);
  26. a[k] = k;
  27. b[k] = (k * 3) % 7;
  28. c[k] = k * 2;
  29. }
  30. f ();
  31. for (i = 0; i < N; i++)
  32. {
  33. unsigned int actual = c[i];
  34. unsigned int expected = i + ((i * 3) % 7);
  35. if (actual != expected)
  36. abort ();
  37. }
  38. return 0;
  39. }