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 { target { powerpc*-*-linux* } } } */
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 /* { dg-final { scan-assembler-times {\maddi\M} 6 { target ilp32 } } } */
22
23
24 #include <altivec.h>
25
26 unsigned int
testbi_var(vector bool int vbi2,signed int si)27 testbi_var (vector bool int vbi2, signed int si)
28 {
29 return vec_extract (vbi2, si);
30 }
31
32 signed int
testsi_var(vector signed int vsi2,signed int si)33 testsi_var (vector signed int vsi2, signed int si)
34 {
35 return vec_extract (vsi2, si);
36 }
37
38 unsigned int
testui_var(vector unsigned int vui2,signed int si)39 testui_var (vector unsigned int vui2, signed int si)
40 {
41 return vec_extract (vui2, si);
42 }
43
44 unsigned int
testbi_cst(vector bool int vbi2)45 testbi_cst (vector bool int vbi2)
46 {
47 return vec_extract (vbi2, 12);
48 }
49
50 signed int
testsi_cst(vector signed int vsi2)51 testsi_cst (vector signed int vsi2)
52 {
53 return vec_extract (vsi2, 12);
54 }
55
56 unsigned int
testui_cst(vector unsigned int vui2)57 testui_cst (vector unsigned int vui2)
58 {
59 return vec_extract (vui2, 12);
60 }
61
62