OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [autopar/] [reduc-1.c] - Blame information for rev 826

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 298 jeremybenn
/* { dg-do compile } */
2
/* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details -fdump-tree-optimized" } */
3
 
4
#include <stdarg.h>
5
#include <stdlib.h>
6
 
7
 #define N 1600
8
 #define DIFF 2558402
9
 
10
unsigned int ub[N];
11
unsigned int uc[N];
12
 
13
 /* Reduction of unsigned-int.  */
14
 
15
 void main1 (unsigned int x, unsigned int max_result, unsigned int min_result)
16
 {
17
   int i;
18
   unsigned int udiff = 2;
19
   unsigned int umax = x;
20
   unsigned int umin = x;
21
 
22
   /* Summation.  */
23
   for (i = 0; i < N; i++) {
24
     udiff += (ub[i] - uc[i]);
25
   }
26
 
27
   /* Maximum.  */
28
   for (i = 0; i < N; i++) {
29
     umax = umax < uc[i] ? uc[i] : umax;
30
   }
31
 
32
   /* Minimum.  */
33
   for (i = 0; i < N; i++) {
34
     umin = umin > uc[i] ? uc[i] : umin;
35
   }
36
 
37
   /* check results:  */
38
   if (udiff != DIFF)
39
     abort ();
40
   if (umax != max_result)
41
     abort ();
42
   if (umin != min_result)
43
     abort ();
44
 }
45
 
46
 __attribute__((noinline))
47
 void init_arrays ()
48
 {
49
   int i;
50
 
51
   ub[0] = 1;
52
   uc[0] = 1;
53
   for (i=1; i<N; i++)
54
     {
55
       ub[i] = i * 3;
56
       uc[i] = i;
57
     }
58
}
59
 
60
int main (void)
61
{
62
  init_arrays ();
63
  main1 (2000, 2000, 1);
64
  main1 (0, 1599, 0);
65
  return 0;
66
}
67
 
68
 
69
/* { dg-final { scan-tree-dump-times "Detected reduction" 3 "parloops" } } */
70
/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 4 "parloops" } } */
71
/* { dg-final { cleanup-tree-dump "parloops" } } */
72
/* { dg-final { cleanup-tree-dump "optimized" } } */
73
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.