1 #define N 87 2 #define M 6 3 4 typedef signed char sc; 5 typedef unsigned char uc; 6 typedef signed short ss; 7 typedef unsigned short us; 8 typedef int si; 9 typedef unsigned int ui; 10 typedef signed long long sll; 11 typedef unsigned long long ull; 12 13 #define FOR_EACH_TYPE(M) \ 14 M (sc) M (uc) \ 15 M (ss) M (us) \ 16 M (si) M (ui) \ 17 M (sll) M (ull) \ 18 M (float) M (double) 19 20 #define TEST_VALUE(I) ((I) * 5 / 2) 21 22 #define ADD_TEST(TYPE) \ 23 void __attribute__((noinline, noclone)) \ 24 test_##TYPE (TYPE *a, int step) \ 25 { \ 26 for (int i = 0; i < N; ++i) \ 27 { \ 28 a[i * step + 0] = a[i * step + 0] + 1; \ 29 a[i * step + 1] = a[i * step + 1] + 2; \ 30 a[i * step + 2] = a[i * step + 2] + 4; \ 31 a[i * step + 3] = a[i * step + 3] + 8; \ 32 } \ 33 } \ 34 void __attribute__((noinline, noclone)) \ 35 ref_##TYPE (TYPE *a, int step) \ 36 { \ 37 for (int i = 0; i < N; ++i) \ 38 { \ 39 a[i * step + 0] = a[i * step + 0] + 1; \ 40 a[i * step + 1] = a[i * step + 1] + 2; \ 41 a[i * step + 2] = a[i * step + 2] + 4; \ 42 a[i * step + 3] = a[i * step + 3] + 8; \ 43 asm volatile (""); \ 44 } \ 45 } 46 47 #define DO_TEST(TYPE) \ 48 for (int j = -M; j <= M; ++j) \ 49 { \ 50 TYPE a[N * M], b[N * M]; \ 51 for (int i = 0; i < N * M; ++i) \ 52 a[i] = b[i] = TEST_VALUE (i); \ 53 int offset = (j < 0 ? N * M - 4 : 0); \ 54 test_##TYPE (a + offset, j); \ 55 ref_##TYPE (b + offset, j); \ 56 if (__builtin_memcmp (a, b, sizeof (a)) != 0) \ 57 __builtin_abort (); \ 58 } 59 FOR_EACH_TYPE(ADD_TEST)60FOR_EACH_TYPE (ADD_TEST) 61 62 int 63 main (void) 64 { 65 FOR_EACH_TYPE (DO_TEST) 66 return 0; 67 } 68