1 /* { dg-do compile { target { powerpc*-*-* } } } */
2 /* { dg-skip-if "" { powerpc*-*-darwin* } } */
3 /* { dg-options "-O2 -mdejagnu-cpu=power6 -mavoid-indexed-addresses" } */
4 /* { dg-final { scan-assembler-times "lwbrx" 12 } } */
5 /* { dg-final { scan-assembler-times "stwbrx" 6 } } */
6 
7 /* PR 51399: bswap gets an error if -mavoid-indexed-addresses was used in
8    creating the two lwbrx instructions.  */
9 
10 long long
load64_reverse_1(long long * p)11 load64_reverse_1 (long long *p)
12 {
13   return __builtin_bswap64 (*p);
14 }
15 
16 long long
load64_reverse_2(long long * p)17 load64_reverse_2 (long long *p)
18 {
19   return __builtin_bswap64 (p[1]);
20 }
21 
22 long long
load64_reverse_3(long long * p,int i)23 load64_reverse_3 (long long *p, int i)
24 {
25   return __builtin_bswap64 (p[i]);
26 }
27 
28 long long
load64_reverse_4(long long dummy,long long * p)29 load64_reverse_4 (long long dummy __attribute__ ((unused)), long long *p)
30 {
31   return __builtin_bswap64 (*p);
32 }
33 
34 long long
load64_reverse_5(long long dummy,long long * p)35 load64_reverse_5 (long long dummy __attribute__ ((unused)), long long *p)
36 {
37   return __builtin_bswap64 (p[1]);
38 }
39 
40 long long
load64_reverse_6(long long dummy,long long * p,int i)41 load64_reverse_6 (long long dummy __attribute__ ((unused)), long long *p, int i)
42 {
43   return __builtin_bswap64 (p[i]);
44 }
45 
46 void
store64_reverse_1(long long * p,long long x)47 store64_reverse_1 (long long *p, long long x)
48 {
49   *p = __builtin_bswap64 (x);
50 }
51 
52 void
store64_reverse_2(long long * p,long long x)53 store64_reverse_2 (long long *p, long long x)
54 {
55   p[1] = __builtin_bswap64 (x);
56 }
57 
58 void
store64_reverse_3(long long * p,long long x,int i)59 store64_reverse_3 (long long *p, long long x, int i)
60 {
61   p[i] = __builtin_bswap64 (x);
62 }
63 
64 long long
reg_reverse_1(long long x)65 reg_reverse_1 (long long x)
66 {
67   return __builtin_bswap64 (x);
68 }
69 
70 long long
reg_reverse_2(long long dummy,long long x)71 reg_reverse_2 (long long dummy __attribute__ ((unused)), long long x)
72 {
73   return __builtin_bswap64 (x);
74 }
75