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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [g++.dg/] [opt/] [pr23454-2.C] - Blame information for rev 316

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

Line No. Rev Author Line
1 301 jeremybenn
/* PR rtl-optimization/23454 */
2
/* Submitted by Matthias Klose  */
3
 
4
/* { dg-do compile } */
5
/* { dg-options "-O3" } */
6
 
7
typedef unsigned long long int ulonglong;
8
typedef long long int longlong;
9
typedef unsigned int uint32;
10
typedef unsigned int uint;
11
typedef unsigned long int ulong;
12
 
13
class Item {
14
public:
15
  bool null_value;
16
  virtual longlong val_int()=0;
17
};
18
 
19
typedef struct st_tree_element {
20
  struct st_tree_element *left,*right;
21
  uint32 count;
22
} TREE_ELEMENT;
23
 
24
typedef struct st_tree {
25
  uint offset_to_key,elements_in_tree,size_of_element,memory_limit,allocated;
26
  void *custom_arg;
27
  bool with_delete;
28
  uint flag;
29
} TREE;
30
 
31
class field_info
32
{
33
public:
34
  ulong treemem, tree_elements, empty, nulls, min_length, max_length;
35
  uint room_in_tree;
36
  bool found;
37
  TREE tree;
38
  Item *item;
39
};
40
 
41
class field_ulonglong: public field_info
42
{
43
  ulonglong min_arg, max_arg;
44
  ulonglong sum, sum_sqr;
45
  void add();
46
};
47
 
48
extern char *longlong10_to_str(longlong val,char *dst,int radix);
49
extern void delete_tree(TREE*);
50
extern TREE_ELEMENT *tree_insert(TREE *tree,void *custom_arg);
51
 
52
static int compare_ulonglong(const ulonglong *s, const ulonglong *t)
53
{
54
  return ((*s < *t) ? -1 : *s > *t ? 1 : 0);
55
}
56
 
57
void field_ulonglong::add()
58
{
59
  char buff[(255*3 +1)];
60
  longlong num = item->val_int();
61
  uint length = (uint) (longlong10_to_str(num, buff, 10) - buff);
62
  TREE_ELEMENT *element;
63
 
64
  if (item->null_value)
65
  {
66
    nulls++;
67
    return;
68
  }
69
  if (num == 0)
70
    empty++;
71
 
72
  if (room_in_tree)
73
  {
74
    if (!(element = tree_insert(&tree, tree.custom_arg)))
75
    {
76
      room_in_tree = 0;
77
      delete_tree(&tree);
78
    }
79
    else if (element->count == 1)
80
    {
81
      room_in_tree = 0;
82
      delete_tree(&tree);
83
    }
84
  }
85
 
86
  if (!found)
87
  {
88
    found = 1;
89
    min_arg = max_arg = sum = num;
90
    sum_sqr = num * num;
91
    min_length = max_length = length;
92
  }
93
  else if (num != 0)
94
  {
95
    sum += num;
96
    sum_sqr += num * num;
97
    if (length < min_length)
98
      min_length = length;
99
    if (length > max_length)
100
      max_length = length;
101
    if (compare_ulonglong((ulonglong*) &num, &min_arg) < 0)
102
      min_arg = num;
103
    if (compare_ulonglong((ulonglong*) &num, &max_arg) > 0)
104
      max_arg = num;
105
  }
106
}

powered by: WebSVN 2.1.0

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