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

Subversion Repositories openrisc

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

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

powered by: WebSVN 2.1.0

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