1 /* Funtional setmem test. */
4 /* { dg-options "-O3" } */
6 #define MAX_LEN (8 * 1000)
8 __attribute__ ((noinline
))
10 check_mem (char *mem
, int val
, int len
)
16 for (i
= 1; i
<= len
; i
++)
19 if (mem
[len
+ 1] != 0x71 + (len
+ 1) % 4)
23 __attribute__ ((noinline
))
30 p
= (unsigned int *)mem
;
31 for (i
= 0; i
< MAX_LEN
/ sizeof(unsigned int); i
++)
35 #define MEMSET_CHECK(VAL, SIZE) \
37 __builtin_memset (mem1 + 1, 0, (SIZE)); \
38 check_mem (mem1, 0, SIZE); \
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
)
53 1024, 1025, 1026, 1027,
54 1280, 1281, 1282, 1283,
60 for (t
= 0; lens
[t
] != -999; t
++)
62 MEMSET_CHECK (argc
+ 0x10, lens
[t
]);
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);