1 /* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
2 /* { dg-skip-if "" { powerpc*-*-darwin* } } */
3 /* { dg-require-effective-target powerpc_p8vector_ok } */
4 /* { dg-options "-O2 -mdejagnu-cpu=power8" } */
5 
6 #include <altivec.h>
7 
8 short
add_short_0(vector short * p)9 add_short_0 (vector short *p)
10 {
11   return vec_extract (*p, 0) + 1;
12 }
13 
14 short
add_short_1(vector short * p)15 add_short_1 (vector short *p)
16 {
17   return vec_extract (*p, 1) + 1;
18 }
19 
20 short
add_short_2(vector short * p)21 add_short_2 (vector short *p)
22 {
23   return vec_extract (*p, 2) + 1;
24 }
25 
26 short
add_short_3(vector short * p)27 add_short_3 (vector short *p)
28 {
29   return vec_extract (*p, 3) + 1;
30 }
31 
32 short
add_short_4(vector short * p)33 add_short_4 (vector short *p)
34 {
35   return vec_extract (*p, 4) + 1;
36 }
37 
38 short
add_short_5(vector short * p)39 add_short_5 (vector short *p)
40 {
41   return vec_extract (*p, 5) + 1;
42 }
43 
44 short
add_short_6(vector short * p)45 add_short_6 (vector short *p)
46 {
47   return vec_extract (*p, 6) + 1;
48 }
49 
50 short
add_short_7(vector short * p)51 add_short_7 (vector short *p)
52 {
53   return vec_extract (*p, 7) + 1;
54 }
55 
56 short
add_short_n(vector short * p,int n)57 add_short_n (vector short *p, int n)
58 {
59   return vec_extract (*p, n) + 1;
60 }
61 
62 /* { dg-final { scan-assembler-not "lxvd2x"   } } */
63 /* { dg-final { scan-assembler-not "lxvw4x"   } } */
64 /* { dg-final { scan-assembler-not "lxvx"     } } */
65 /* { dg-final { scan-assembler-not "lxv"      } } */
66 
67 /* With recent enhancements to the code generator, it is considered
68  * legal to implement vec_extract with lvx and xxpermdi.  Previous
69  * versions of this test forbid both instructions.  */
70