1 /* { dg-do run } */ 2 /* { dg-options "-O2 -ftree-vectorize -std=c99 -fipa-pta" } */ 3 4 5 extern void abort (void); 6 7 #define nEvents 1000 8 9 static void __attribute__((noinline, noclone, optimize("-fno-tree-vectorize"))) init(unsigned * results,unsigned * pData)10init (unsigned *results, unsigned *pData) 11 { 12 unsigned int i; 13 for (i = 0; i < nEvents; ++i) 14 pData[i] = i % 3; 15 } 16 17 static void __attribute__((noinline, noclone, optimize("-fno-tree-vectorize"))) check(unsigned * results)18check (unsigned *results) 19 { 20 unsigned sum = 0; 21 for (int idx = 0; idx < (int)nEvents; idx++) 22 sum += results[idx]; 23 24 if (sum != 1998) 25 abort (); 26 } 27 28 int main(void)29main (void) 30 { 31 unsigned results[nEvents]; 32 unsigned pData[nEvents]; 33 unsigned coeff = 2; 34 35 init (&results[0], &pData[0]); 36 37 #pragma omp parallel for 38 for (int idx = 0; idx < (int)nEvents; idx++) 39 results[idx] = coeff * pData[idx]; 40 41 check (&results[0]); 42 43 return 0; 44 } 45