Handle peeling for alignment with masking
[official-gcc.git] / gcc / testsuite / gcc.dg / pr44699.c
blobbd2b1a87aaa7571594ca7de99c74fb7088785af2
1 /* { dg-do compile } */
2 /* { dg-options "-O2" } */
3 typedef long unsigned int size_t;
4 typedef long int intmax_t;
5 typedef long unsigned int uintmax_t;
6 extern void *xmalloc (size_t) __attribute__ ((__malloc__));
7 extern const char *trim_filename (const char *);
8 extern void error (const char *, ...);
10 static __inline void *
11 __inline_memcpy_chk (void *__dest, const void *__src, size_t __len)
13 return __builtin___memcpy_chk (__dest, __src, __len, __builtin_object_size (__dest, 0));
16 typedef unsigned int hashval_t;
17 typedef hashval_t (*htab_hash) (const void *);
18 typedef int (*htab_eq) (const void *, const void *);
19 typedef void (*htab_del) (void *);
20 typedef int (*htab_trav) (void **, void *);
21 typedef void *(*htab_alloc) (size_t, size_t);
22 typedef void (*htab_free) (void *);
24 typedef void *(*htab_alloc_with_arg) (void *, size_t, size_t);
25 typedef void (*htab_free_with_arg) (void *, void *);
26 struct htab {
27 htab_hash hash_f;
28 htab_eq eq_f;
29 htab_del del_f;
30 void ** entries;
31 size_t size;
32 size_t n_elements;
33 size_t n_deleted;
34 unsigned int searches;
35 unsigned int collisions;
36 htab_alloc alloc_f;
37 htab_free free_f;
38 void * alloc_arg;
39 htab_alloc_with_arg alloc_with_arg_f;
40 htab_free_with_arg free_with_arg_f;
41 unsigned int size_prime_index;
44 typedef struct htab *htab_t;
45 enum insert_option {NO_INSERT, INSERT};
46 extern void * htab_find (htab_t, const void *);
47 extern void ** htab_find_slot (htab_t, const void *, enum insert_option);
49 enum mode_class { MODE_RANDOM, MODE_CC, MODE_INT, MODE_PARTIAL_INT, MODE_FRACT, MODE_UFRACT, MODE_ACCUM, MODE_UACCUM, MODE_FLOAT, MODE_DECIMAL_FLOAT, MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MODE_VECTOR_INT, MODE_VECTOR_FRACT, MODE_VECTOR_UFRACT, MODE_VECTOR_ACCUM, MODE_VECTOR_UACCUM, MODE_VECTOR_FLOAT, MAX_MODE_CLASS };
51 static const char *const mode_class_names[MAX_MODE_CLASS] =
53 "MODE_RANDOM", "MODE_CC", "MODE_INT", "MODE_PARTIAL_INT", "MODE_FRACT", "MODE_UFRACT", "MODE_ACCUM", "MODE_UACCUM", "MODE_FLOAT", "MODE_DECIMAL_FLOAT", "MODE_COMPLEX_INT", "MODE_COMPLEX_FLOAT", "MODE_VECTOR_INT", "MODE_VECTOR_FRACT", "MODE_VECTOR_UFRACT", "MODE_VECTOR_ACCUM", "MODE_VECTOR_UACCUM", "MODE_VECTOR_FLOAT"
55 struct mode_data
57 struct mode_data *next;
59 const char *name;
60 enum mode_class cl;
61 unsigned int precision;
62 unsigned int bytesize;
63 unsigned int ncomponents;
64 unsigned int alignment;
65 const char *format;
67 struct mode_data *component;
68 struct mode_data *wider;
69 struct mode_data *wider_2x;
71 struct mode_data *contained;
73 struct mode_data *next_cont;
75 const char *file;
76 unsigned int line;
77 unsigned int counter;
78 unsigned int ibit;
79 unsigned int fbit;
82 static struct mode_data *modes[MAX_MODE_CLASS];
83 static unsigned int n_modes[MAX_MODE_CLASS];
84 static struct mode_data *void_mode;
86 static const struct mode_data blank_mode = {
87 0, "<unknown>", MAX_MODE_CLASS,
88 -1U, -1U, -1U, -1U,
89 0, 0, 0, 0, 0, 0,
90 "<unknown>", 0, 0, 0, 0
93 static htab_t modes_by_name;
95 static __inline__ struct mode_data *
96 find_mode (const char *name)
98 struct mode_data key;
100 key.name = name;
101 return (struct mode_data *) htab_find (modes_by_name, &key);
104 static struct mode_data *
105 new_mode (enum mode_class cl, const char *name,
106 const char *file, unsigned int line)
108 struct mode_data *m;
109 static unsigned int count = 0;
111 m = find_mode (name);
112 if (m)
114 error ("%s:%d: duplicate definition of mode \"%s\"",
115 trim_filename (file), line, name);
116 error ("%s:%d: previous definition here", m->file, m->line);
117 return m;
120 m = ((struct mode_data *) xmalloc (sizeof (struct mode_data)));
121 ((__builtin_object_size (m, 0) != (size_t) -1) ? __builtin___memcpy_chk (m, &blank_mode, sizeof (struct mode_data), __builtin_object_size (m, 0)) : __inline_memcpy_chk (m, &blank_mode, sizeof (struct mode_data)));
122 m->cl = cl;
123 m->name = name;
124 if (file)
125 m->file = trim_filename (file);
126 m->line = line;
127 m->counter = count++;
129 m->next = modes[cl];
130 modes[cl] = m;
131 n_modes[cl]++;
133 *htab_find_slot (modes_by_name, m, INSERT) = m;
135 return m;
138 static void
139 make_int_mode (const char *name,
140 unsigned int precision, unsigned int bytesize,
141 const char *file, unsigned int line)
143 struct mode_data *m = new_mode (MODE_INT, name, file, line);
144 m->bytesize = bytesize;
145 m->precision = precision;
148 static void
149 create_modes (void)
151 make_int_mode ("HI", -1U, 2, "../../work/gcc/machmode.def", 182);
155 main (int argc, char **argv)
157 create_modes ();