1 /* Verify that overloaded built-ins for vec_extract() with int
2 inputs produce the right code with a P8 (LE or BE) target. */
3
4 /* { dg-do compile } */
5 /* { dg-require-effective-target powerpc_p8vector_ok } */
6 /* { dg-options "-mdejagnu-cpu=power8 -O2" } */
7
8 // Targeting P8 (LE) and (BE). 6 tests total.
9 // P8 LE constant: vspltw, mfvsrwz, (1:extsw/2:rldicl)
10 // P8 LE variables: subfic, sldi, mtvsrd, xxpermdi, vslo, mfvsrd, sradi, (1:extsw/5:rldicl))
11 // P8 BE constant: vspltw, mfvsrwz, (1:extsw/2:rldicl)
12 // P8 BE variables: sldi, mtvsrd, xxpermdi, vslo, mfvsrd, sradi, (1:extsw/2:rldicl))
13
14 /* { dg-final { scan-assembler-times {\mvspltw\M} 3 { target lp64 } } } */
15 /* { dg-final { scan-assembler-times {\mmfvsrwz\M} 3 { target lp64 } } } */
16 /* { dg-final { scan-assembler-times {\mrldicl\M} 7 { target { le } } } } */
17 /* { dg-final { scan-assembler-times {\mrldicl\M} 4 { target { lp64 && be } } } } */
18 /* { dg-final { scan-assembler-times {\msubfic\M} 3 { target { le } } } } */
19 /* { dg-final { scan-assembler-times {\msldi\M} 3 { target lp64 } } } */
20 /* { dg-final { scan-assembler-times {\mmtvsrd\M} 3 { target lp64 } } } */
21 /* { dg-final { scan-assembler-times {\mxxpermdi\M} 3 { target lp64 } } } */
22 /* { dg-final { scan-assembler-times {\mvslo\M} 3 { target lp64 } } } */
23 /* { dg-final { scan-assembler-times {\mmfvsrd\M} 3 { target lp64 } } } */
24 /* { dg-final { scan-assembler-times {\msrdi\M} 3 { target lp64 } } } */
25 /* { dg-final { scan-assembler-times {\mextsw\M} 2 { target lp64 } } } */
26
27
28 /* { dg-final { scan-assembler-times {\mli\M} 6 { target ilp32 } } } */
29 /* { dg-final { scan-assembler-times {\mrlwinm\M} 3 { target ilp32 } } } */
30 /* { dg-final { scan-assembler-times {\mstxvw4x\M} 6 { target ilp32 } } } */
31 /* { dg-final { scan-assembler-times {\madd\M} 3 { target ilp32 } } } */
32 /* { dg-final { scan-assembler-times {\mlwz\M} 6 { target ilp32 } } } */
33 /* { dg-final { scan-assembler-times {\maddi\M} 9 { target ilp32 } } } */
34
35
36
37 #include <altivec.h>
38
39 unsigned int
testbi_var(vector bool int vbi2,signed int si)40 testbi_var (vector bool int vbi2, signed int si)
41 {
42 return vec_extract (vbi2, si);
43 }
44
45 signed int
testsi_var(vector signed int vsi2,signed int si)46 testsi_var (vector signed int vsi2, signed int si)
47 {
48 return vec_extract (vsi2, si);
49 }
50
51 unsigned int
testui_var(vector unsigned int vui2,signed int si)52 testui_var (vector unsigned int vui2, signed int si)
53 {
54 return vec_extract (vui2, si);
55 }
56
57 unsigned int
testbi_cst(vector bool int vbi2)58 testbi_cst (vector bool int vbi2)
59 {
60 return vec_extract (vbi2, 12);
61 }
62
63 signed int
testsi_cst(vector signed int vsi2)64 testsi_cst (vector signed int vsi2)
65 {
66 return vec_extract (vsi2, 12);
67 }
68
69 unsigned int
testui_cst(vector unsigned int vui2)70 testui_cst (vector unsigned int vui2)
71 {
72 return vec_extract (vui2, 12);
73 }
74
75