i386: Adjust rtx cost for imulq and imulw [PR115749]
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / pr94994.c
blob2f598eacd541eafaef02f9aee34fc769dac2a4c6
1 #include <stdint.h>
2 #include "tree-vect.h"
4 #define BLOCK_SIZE (sizeof (uint32_t))
6 struct unaligned {
7 uint32_t x;
8 } __attribute__((packed, may_alias));
10 static inline uint32_t
11 load_unaligned (const char *p)
13 return ((struct unaligned *) p)->x;
16 static inline void
17 store_unaligned (uint32_t x, char *p)
19 ((struct unaligned *) p)->x = x;
22 void __attribute__((noipa))
23 copy (char *dst, const char *src, size_t n)
25 for (size_t i = 0; i < n; i += BLOCK_SIZE)
26 store_unaligned (load_unaligned (src + i), dst + i);
29 #define INPUT_SIZE 64
30 #define MAX_STEP 32
32 char x[INPUT_SIZE + MAX_STEP];
34 int
35 main (void)
37 check_vect ();
39 for (unsigned int i = 1; i < MAX_STEP; ++i)
41 for (unsigned int j = 0; j < INPUT_SIZE + MAX_STEP; ++j)
42 x[j] = j + 10;
43 copy (x + i, x, INPUT_SIZE);
44 #pragma GCC novector
45 for (int j = 0; j < INPUT_SIZE + i; ++j)
47 int expected;
48 if (j < i)
49 expected = j + 10;
50 else if (i >= BLOCK_SIZE)
51 expected = j % i + 10;
52 else if ((j - i) % BLOCK_SIZE < i)
53 expected = x[j - i];
54 else
55 expected = j - i + 10;
56 if (x[j] != expected)
57 __builtin_abort ();
61 return 0;