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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [autopar/] [reduc-2short.c] - Blame information for rev 801

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 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 242
9
 
10
short b[N] = {1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
11
short c[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
12
 
13
__attribute__ ((noinline))
14
void main1 (short x, short max_result, short min_result)
15
{
16
  int i;
17
  short diff = 2;
18
  short max = x;
19
  short min = x;
20
 
21
  for (i = 0; i < N; i++) {
22
    diff += (short)(b[i] - c[i]);
23
  }
24
  for (i = 0; i < N; i++) {
25
    max = max < c[i] ? c[i] : max;
26
  }
27
 
28
  for (i = 0; i < N; i++) {
29
    min = min > c[i] ? c[i] : min;
30
  }
31
 
32
  /* check results:  */
33
  if (diff != DIFF)
34
    abort ();
35
  if (max != max_result)
36
    abort ();
37
  if (min != min_result)
38
    abort ();
39
}
40
 
41
 __attribute__((noinline))
42
 void init_arrays ()
43
 {
44
   int i;
45
 
46
   for (i=16; i<N; i++)
47
     {
48
       b[i] = 1;
49
       c[i] = 1;
50
     }
51
}
52
 
53
int main (void)
54
{
55
  init_arrays();
56
  main1 (100, 100, 1);
57
  main1 (0, 15, 0);
58
  return 0;
59
}
60
 
61
 
62
/* { dg-final { scan-tree-dump-times "Detected reduction" 2 "parloops" } } */
63
/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 3 "parloops" } } */
64
/* { dg-final { cleanup-tree-dump "parloops" } } */
65
/* { dg-final { cleanup-tree-dump "optimized" } } */
66
 

powered by: WebSVN 2.1.0

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