1 /* Verify that overloaded built-ins for vec_extract() with int
2 inputs produce the right code with a P9 (LE) target. */
3
4 /* { dg-do compile } */
5 /* { dg-require-effective-target powerpc_p9vector_ok } */
6 /* { dg-options "-mdejagnu-cpu=power9 -O2 " } */
7
8 // Targeting P9 (LE). 6 tests total.
9 // P9 constant: li, vextuwrx, (1:extsw)
10 // P9 variables: slwi, vextuwrx, (1:extsw)
11
12 /* { dg-final { scan-assembler-times {\mli\M} 3 { target lp64 } } } */
13 /* { dg-final { scan-assembler-times {\mslwi\M} 3 { target lp64 } } } */
14 /* { dg-final { scan-assembler-times {\mvextuwrx\M|\mvextuwlx\M} 6 { target lp64 } } } */
15 /* { dg-final { scan-assembler-times {\mextsw\M} 2 { target lp64 } } } */
16
17 /* { dg-final { scan-assembler-times {\mrlwinm\M} 3 { target ilp32 } } } */
18 /* { dg-final { scan-assembler-times {\madd\M} 3 { target ilp32 } } } */
19 /* { dg-final { scan-assembler-times {\mstxv\M} 6 { target ilp32 } } } */
20 /* { dg-final { scan-assembler-times {\mlwz\M} 6 { target ilp32 } } } */
21
22
23 #include <altivec.h>
24
25 unsigned int
testbi_var(vector bool int vbi2,signed int si)26 testbi_var (vector bool int vbi2, signed int si)
27 {
28 return vec_extract (vbi2, si);
29 }
30
31 signed int
testsi_var(vector signed int vsi2,signed int si)32 testsi_var (vector signed int vsi2, signed int si)
33 {
34 return vec_extract (vsi2, si);
35 }
36
37 unsigned int
testui_var(vector unsigned int vui2,signed int si)38 testui_var (vector unsigned int vui2, signed int si)
39 {
40 return vec_extract (vui2, si);
41 }
42
43 unsigned int
testbi_cst(vector bool int vbi2)44 testbi_cst (vector bool int vbi2)
45 {
46 return vec_extract (vbi2, 12);
47 }
48
49 signed int
testsi_cst(vector signed int vsi2)50 testsi_cst (vector signed int vsi2)
51 {
52 return vec_extract (vsi2, 12);
53 }
54
55 unsigned int
testui_cst(vector unsigned int vui2)56 testui_cst (vector unsigned int vui2)
57 {
58 return vec_extract (vui2, 12);
59 }
60
61