[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / pr65456.c
blob12b48c0b91e3fba2c28a4b5bd907175f03a5e963
1 /* { dg-do compile { target { powerpc64le-*-* } } } */
2 /* { dg-options "-mdejagnu-cpu=power8 -O3" } */
4 /* Verify that swap optimization properly removes swaps for unaligned
5 vector stores. See PR65456. */
7 typedef unsigned char UChar;
8 typedef unsigned short UShort;
9 typedef unsigned int UWord;
11 typedef unsigned long SizeT;
12 typedef unsigned long Addr;
14 void *memmove(void *dst, const void *src, SizeT len)
16 const Addr WS = sizeof(UWord);/* 8 or 4 */
17 const Addr WM = WS - 1;/* 7 or 3 */
19 /* Copying backwards. */
20 SizeT n = len;
21 Addr d = (Addr) dst;
22 Addr s = (Addr) src;
24 if (((s ^ d) & WM) == 0) {
25 /* s and d have same UWord alignment. */
26 /* Pull up to a UWord boundary. */
27 while ((s & WM) != 0 && n >= 1) {
28 *(UChar *) d = *(UChar *) s;
29 s += 1;
30 d += 1;
31 n -= 1;
33 /* Copy UWords. */
34 while (n >= WS) {
35 *(UWord *) d = *(UWord *) s;
36 s += WS;
37 d += WS;
38 n -= WS;
40 if (n == 0)
41 return dst;
43 if (((s | d) & 1) == 0) {
44 /* Both are 16-aligned; copy what we can thusly. */
45 while (n >= 2) {
46 *(UShort *) d = *(UShort *) s;
47 s += 2;
48 d += 2;
49 n -= 2;
52 /* Copy leftovers, or everything if misaligned. */
53 while (n >= 1) {
54 *(UChar *) d = *(UChar *) s;
55 s += 1;
56 d += 1;
57 n -= 1;
60 return dst;
63 /* { dg-final { scan-assembler-not "xxpermdi" } } */
64 /* { dg-final { scan-assembler-not "xxswapd" } } */