middle-end: Fix stalled swapped condition code value [PR115836]
[official-gcc.git] / gcc / testsuite / c-c++-common / analyzer / out-of-bounds-const-fn.c
blob7cb8b5f5361189b6237aa0d25b48c9af9d779c36
1 /* Reduced from analyzer ICE seen with git-2.39.0's pack-bitmap.c
2 when bounds-checking the result of __builtin_ctzll. */
4 #include <stdint.h>
5 #include <stddef.h>
7 typedef uint64_t eword_t;
8 struct ewah_bitmap;
9 struct ewah_iterator
11 /* [...] */
13 struct bitmap;
15 void ewah_iterator_init(struct ewah_iterator *it, struct ewah_bitmap *parent);
16 int ewah_iterator_next(eword_t *next, struct ewah_iterator *it);
17 void bitmap_set(struct bitmap *self, size_t pos);
19 int rebuild_bitmap(const uint32_t *reposition,
20 struct ewah_bitmap *source,
21 struct bitmap *dest)
23 uint32_t pos = 0;
24 struct ewah_iterator it;
25 eword_t word;
27 ewah_iterator_init(&it, source);
29 while (ewah_iterator_next(&word, &it)) {
30 uint32_t offset, bit_pos;
32 for (offset = 0; offset < (sizeof(eword_t) * 8); ++offset) {
33 if ((word >> offset) == 0)
34 break;
36 offset += __builtin_ctzll(word >> offset);
38 bit_pos = reposition[pos + offset];
39 if (bit_pos > 0)
40 bitmap_set(dest, bit_pos - 1);
41 else
42 return -1;
45 pos += (sizeof(eword_t) * 8);
47 return 0;