1 /* Make sure that short memset's with constant length are emitted
2 without loop statements. */
4 /* { dg-do compile } */
5 /* { dg-options "-O3 -mzarch -march=z13" } */
9 *memset0(void *s
, int c
)
11 return __builtin_memset (s
, c
, 1);
16 *memset1(void *s
, int c
)
18 return __builtin_memset (s
, c
, 42);
23 *memset2(void *s
, int c
)
25 return __builtin_memset (s
, c
, 700);
30 *memset3(void *s
, int c
)
32 return __builtin_memset (s
, c
, 0);
37 *memset4(void *s
, int c
)
39 return __builtin_memset (s
, c
, 256);
44 *memset5(void *s
, int c
)
46 return __builtin_memset (s
, c
, 512);
49 /* 2 stc 2 mvc - still due to the stc bytes */
51 *memset6(void *s
, int c
)
53 return __builtin_memset (s
, c
, 514);
58 *memset7(void *s
, int c
)
60 return __builtin_memset (s
, c
, 515);
63 /* 4 stc 4 mvc - 4 * 256 + 4 stc bytes */
65 *memset8(void *s
, int c
)
67 return __builtin_memset (s
, c
, 1028);
70 /* 2 stc 1 pfd 2 mvc - start using mvc loop */
72 *memset9(void *s
, int c
)
74 return __builtin_memset (s
, c
, 1029);
77 /* 3 stc 3 mvc - displacement overflow after the first */
79 *memset10(void *s
, int c
)
81 return __builtin_memset ((char*)s
+ 4000, c
, 700);
88 return __builtin_memset (s
, 0, 1);
95 return __builtin_memset (s
, 0, 42);
102 return __builtin_memset (s
, 0, 700);
109 return __builtin_memset (s
, 0, 0);
116 return __builtin_memset (s
, 0, 256);
123 return __builtin_memset (s
, 0, 512);
130 return __builtin_memset (s
, 0, 1024);
133 /* 2 xc - start using xc loop*/
137 return __builtin_memset (s
, 0, 1025);
140 /* 5 xc - on z10 PFD would be used in the loop body so the unrolled
141 variant would still be shorter. */
142 __attribute__ ((target("tune=z10")))
144 *clrmem7_z10(void *s
)
146 return __builtin_memset (s
, 0, 1025);
150 __attribute__ ((target("tune=z10")))
152 *clrmem8_z10(void *s
)
154 return __builtin_memset (s
, 0, 1280);
157 /* 1 pfd 2 xc - start using xc loop also on z10 */
158 __attribute__ ((target("tune=z10")))
160 *clrmem9_z10(void *s
)
162 return __builtin_memset (s
, 0, 1281);
165 /* 3 xc - displacement overflow after the first */
169 return __builtin_memset (s
+ 4000, 0, 700);
172 /* { dg-final { scan-assembler-times "mvi\\s" 1 } } */
173 /* { dg-final { scan-assembler-times "mvc\\s" 19 } } */
174 /* { dg-final { scan-assembler-times "xc\\s" 28 } } */
175 /* { dg-final { scan-assembler-times "stc\\s" 21 } } */
176 /* { dg-final { scan-assembler-times "stcy\\s" 0 } } */
177 /* { dg-final { scan-assembler-times "pfd\\s" 2 } } */
178 /* { dg-final { scan-assembler-times "vst\\s" 3 } } */