PR middle-end/77357 - strlen of constant strings not folded
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / 20090113-3.c
blobf67bac241351b522816d8a30f5ee89cdfb6aad28
1 struct obstack {};
2 struct bitmap_head_def;
3 typedef struct bitmap_head_def *bitmap;
4 typedef const struct bitmap_head_def *const_bitmap;
5 typedef unsigned long BITMAP_WORD;
7 typedef struct bitmap_obstack
9 struct bitmap_element_def *elements;
10 struct bitmap_head_def *heads;
11 struct obstack obstack;
12 } bitmap_obstack;
13 typedef struct bitmap_element_def
15 struct bitmap_element_def *next;
16 struct bitmap_element_def *prev;
17 unsigned int indx;
18 BITMAP_WORD bits[(2)];
19 } bitmap_element;
21 struct bitmap_descriptor;
23 typedef struct bitmap_head_def {
24 bitmap_element *first;
25 bitmap_element *current;
26 unsigned int indx;
27 bitmap_obstack *obstack;
28 } bitmap_head;
30 bitmap_element bitmap_zero_bits;
32 typedef struct
34 bitmap_element *elt1;
35 bitmap_element *elt2;
36 unsigned word_no;
37 BITMAP_WORD bits;
38 } bitmap_iterator;
40 static __attribute__((noinline)) void
41 bmp_iter_set_init (bitmap_iterator *bi, const_bitmap map,
42 unsigned start_bit, unsigned *bit_no)
44 bi->elt1 = map->first;
45 bi->elt2 = ((void *)0);
47 while (1)
49 if (!bi->elt1)
51 bi->elt1 = &bitmap_zero_bits;
52 break;
55 if (bi->elt1->indx >= start_bit / (128u))
56 break;
57 bi->elt1 = bi->elt1->next;
60 if (bi->elt1->indx != start_bit / (128u))
61 start_bit = bi->elt1->indx * (128u);
63 bi->word_no = start_bit / 64u % (2);
64 bi->bits = bi->elt1->bits[bi->word_no];
65 bi->bits >>= start_bit % 64u;
67 start_bit += !bi->bits;
69 *bit_no = start_bit;
72 static __inline__ __attribute__((always_inline)) void
73 bmp_iter_next (bitmap_iterator *bi, unsigned *bit_no)
75 bi->bits >>= 1;
76 *bit_no += 1;
79 static __inline__ __attribute__((always_inline)) unsigned char
80 bmp_iter_set (bitmap_iterator *bi, unsigned *bit_no)
82 if (bi->bits)
84 while (!(bi->bits & 1))
86 bi->bits >>= 1;
87 *bit_no += 1;
89 return 1;
92 *bit_no = ((*bit_no + 64u - 1) / 64u * 64u);
93 bi->word_no++;
95 while (1)
97 while (bi->word_no != (2))
99 bi->bits = bi->elt1->bits[bi->word_no];
100 if (bi->bits)
102 while (!(bi->bits & 1))
104 bi->bits >>= 1;
105 *bit_no += 1;
107 return 1;
109 *bit_no += 64u;
110 bi->word_no++;
113 bi->elt1 = bi->elt1->next;
114 if (!bi->elt1)
115 return 0;
116 *bit_no = bi->elt1->indx * (128u);
117 bi->word_no = 0;
121 static void __attribute__((noinline))
122 foobar (bitmap_head *live_throughout)
124 bitmap_iterator rsi;
125 unsigned int regno;
126 for (bmp_iter_set_init (&(rsi), (live_throughout), (0), &(regno));
127 bmp_iter_set (&(rsi), &(regno));
128 bmp_iter_next (&(rsi), &(regno)))
131 int main()
133 bitmap_element elem = { (void *)0, (void *)0, 0, { 1, 1 } };
134 bitmap_head live_throughout = { &elem, &elem, 0, (void *)0 };
135 foobar (&live_throughout);
136 return 0;