PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.target / s390 / memset-2.c
blobe1af7fe30d877391aa642ace1c653bdb5d14c5e7
1 /* Funtional setmem test. */
3 /* { dg-do run } */
4 /* { dg-options "-O3" } */
6 #define MAX_LEN (8 * 1000)
8 __attribute__ ((noinline))
9 int
10 check_mem (char *mem, int val, int len)
12 int i;
14 if (mem[0] != 0x71)
15 __builtin_abort();
16 for (i = 1; i <= len; i++)
17 if (mem[i] != val)
18 __builtin_abort();
19 if (mem[len + 1] != 0x71 + (len + 1) % 4)
20 __builtin_abort();
23 __attribute__ ((noinline))
24 void
25 init_mem (char *mem)
27 unsigned int *p;
28 int i;
30 p = (unsigned int *)mem;
31 for (i = 0; i < MAX_LEN / sizeof(unsigned int); i++)
32 p[i] = 0x71727374;
35 #define MEMSET_CHECK(VAL, SIZE) \
36 init_mem (mem1); \
37 __builtin_memset (mem1 + 1, 0, (SIZE)); \
38 check_mem (mem1, 0, SIZE); \
39 init_mem (mem2); \
40 __builtin_memset (mem2 + 1, (VAL), (SIZE)); \
41 check_mem (mem2, VAL, SIZE);
43 char mem1[MAX_LEN + 2];
44 char mem2[MAX_LEN + 2];
46 int main(int argc, char **argv)
48 int lens[] =
50 256, 257, 258, 259,
51 512, 513, 514, 515,
52 768, 769, 770, 771,
53 1024, 1025, 1026, 1027,
54 1280, 1281, 1282, 1283,
55 -999
57 int t;
59 /* variable length */
60 for (t = 0; lens[t] != -999; t++)
62 MEMSET_CHECK (argc + 0x10, lens[t]);
65 /* constant length */
66 MEMSET_CHECK (argc + 0x10, 0);
67 MEMSET_CHECK (argc + 0x10, 1);
68 MEMSET_CHECK (argc + 0x10, 2);
69 MEMSET_CHECK (argc + 0x10, 3);
70 MEMSET_CHECK (argc + 0x10, 256);
71 MEMSET_CHECK (argc + 0x10, 257);
72 MEMSET_CHECK (argc + 0x10, 258);
73 MEMSET_CHECK (argc + 0x10, 259);
74 MEMSET_CHECK (argc + 0x10, 512);
75 MEMSET_CHECK (argc + 0x10, 513);
76 MEMSET_CHECK (argc + 0x10, 514);
77 MEMSET_CHECK (argc + 0x10, 515);
78 MEMSET_CHECK (argc + 0x10, 768);
79 MEMSET_CHECK (argc + 0x10, 769);
80 MEMSET_CHECK (argc + 0x10, 770);
81 MEMSET_CHECK (argc + 0x10, 771);
82 MEMSET_CHECK (argc + 0x10, 1024);
83 MEMSET_CHECK (argc + 0x10, 1025);
84 MEMSET_CHECK (argc + 0x10, 1026);
85 MEMSET_CHECK (argc + 0x10, 1027);
86 MEMSET_CHECK (argc + 0x10, 1280);
87 MEMSET_CHECK (argc + 0x10, 1281);
88 MEMSET_CHECK (argc + 0x10, 1282);
89 MEMSET_CHECK (argc + 0x10, 1283);
91 return 0;