* gcc.target/powerpc/builtins-1-be.c <vclzb>: Rename duplicate test
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / pr65456.c
blob5a645c76f96b9ba460e1f62c1532e2d157c006c7
1 /* { dg-do compile { target { powerpc64le-*-* } } } */
2 /* { dg-skip-if "do not override -mcpu" { powerpc64le-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */
3 /* { dg-options "-mcpu=power8 -O3" } */
5 /* Verify that swap optimization properly removes swaps for unaligned
6 vector stores. See PR65456. */
8 typedef unsigned char UChar;
9 typedef unsigned short UShort;
10 typedef unsigned int UWord;
12 typedef unsigned long SizeT;
13 typedef unsigned long Addr;
15 void *memmove(void *dst, const void *src, SizeT len)
17 const Addr WS = sizeof(UWord);/* 8 or 4 */
18 const Addr WM = WS - 1;/* 7 or 3 */
20 /* Copying backwards. */
21 SizeT n = len;
22 Addr d = (Addr) dst;
23 Addr s = (Addr) src;
25 if (((s ^ d) & WM) == 0) {
26 /* s and d have same UWord alignment. */
27 /* Pull up to a UWord boundary. */
28 while ((s & WM) != 0 && n >= 1) {
29 *(UChar *) d = *(UChar *) s;
30 s += 1;
31 d += 1;
32 n -= 1;
34 /* Copy UWords. */
35 while (n >= WS) {
36 *(UWord *) d = *(UWord *) s;
37 s += WS;
38 d += WS;
39 n -= WS;
41 if (n == 0)
42 return dst;
44 if (((s | d) & 1) == 0) {
45 /* Both are 16-aligned; copy what we can thusly. */
46 while (n >= 2) {
47 *(UShort *) d = *(UShort *) s;
48 s += 2;
49 d += 2;
50 n -= 2;
53 /* Copy leftovers, or everything if misaligned. */
54 while (n >= 1) {
55 *(UChar *) d = *(UChar *) s;
56 s += 1;
57 d += 1;
58 n -= 1;
61 return dst;
64 /* { dg-final { scan-assembler-not "xxpermdi" } } */
65 /* { dg-final { scan-assembler-not "xxswapd" } } */