1 /* PR rtl-optimization/23454 */
2 /* Submitted by Matthias Klose <doko@debian.org> */
4 /* { dg-do compile } */
5 /* { dg-options "-O3" } */
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;
16 virtual longlong val_int()=0;
19 typedef struct st_tree_element {
20 struct st_tree_element *left,*right;
24 typedef struct st_tree {
25 uint offset_to_key,elements_in_tree,size_of_element,memory_limit,allocated;
34 ulong treemem, tree_elements, empty, nulls, min_length, max_length;
41 class field_ulonglong: public field_info
43 ulonglong min_arg, max_arg;
44 ulonglong sum, sum_sqr;
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);
52 static int compare_ulonglong(const ulonglong *s, const ulonglong *t)
54 return ((*s < *t) ? -1 : *s > *t ? 1 : 0);
57 void field_ulonglong::add()
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;
74 if (!(element = tree_insert(&tree, tree.custom_arg)))
79 else if (element->count == 1)
89 min_arg = max_arg = sum = num;
91 min_length = max_length = length;
97 if (length < min_length)
99 if (length > max_length)
101 if (compare_ulonglong((ulonglong*) &num, &min_arg) < 0)
103 if (compare_ulonglong((ulonglong*) &num, &max_arg) > 0)