2 /* { dg-require-effective-target vmx_hw } */
3 /* { dg-options "-maltivec -O3" } */
5 /* This test should run the same on any target that supports altivec/vmx
6 instructions. Intentionally not specifying cpu in order to test
7 all code generation paths. */
11 extern void abort (void);
31 /* Test that indices > length of vector are applied modulo the vector
34 /* Test for vector residing in register. */
35 vector
signed char c0 (vector
signed char v
, signed char x
)
37 return vec_insert (x
, v
, 0);
40 vector
signed char c9 (vector
signed char v
, signed char x
)
42 return vec_insert (x
, v
, 9);
45 vector
signed char c21 (vector
signed char v
, signed char x
)
47 return vec_insert (x
, v
, 21);
50 vector
signed char c30 (vector
signed char v
, signed char x
)
52 return vec_insert (x
, v
, 30);
55 /* Test for vector residing in memory. */
56 vector
signed char mc0 (vector
signed char *vp
, signed char x
)
58 return vec_insert (x
, *vp
, 0);
61 vector
signed char mc9 (vector
signed char *vp
, signed char x
)
63 return vec_insert (x
, *vp
, 9);
66 vector
signed char mc21 (vector
signed char *vp
, signed char x
)
68 return vec_insert (x
, *vp
, 21);
71 vector
signed char mc30 (vector
signed char *vp
, signed char x
)
73 return vec_insert (x
, *vp
, 30);
76 /* Test the same with variable indices. */
78 /* Test for variable selector and vector residing in register. */
79 __attribute__((noinline
))
80 vector
signed char ci (vector
signed char v
, int i
, signed char x
)
82 return vec_insert (x
, v
, i
);
85 /* Test for variable selector and vector residing in memory. */
86 __attribute__((noinline
))
87 vector
signed char mci(vector
signed char *vp
, int i
, signed char x
) {
88 return vec_insert (x
, *vp
, i
);
92 int main (int argc
, char *argv
[]) {
93 vector
signed char cv
= { CONST0
, CONST1
, CONST2
, CONST3
,
94 CONST4
, CONST5
, CONST6
, CONST7
,
95 CONST8
, CONST9
, CONSTA
, CONSTB
,
96 CONSTC
, CONSTD
, CONSTE
, CONSTF
};
100 if (cv
[0] != CONSTF
)
103 cv
= c9 (cv
, CONST7
);
104 if (cv
[9] != CONST7
)
107 cv
= c21 (cv
, CONSTA
);
108 if (cv
[5] != CONSTA
)
111 cv
= c30 (cv
, CONSTC
);
112 if (cv
[14] != CONSTC
)
115 cv
= mc0 (&cv
, CONSTB
);
116 if (cv
[0] != CONSTB
)
119 cv
= mc9 (&cv
, CONST1
);
120 if (cv
[9] != CONST1
)
123 cv
= mc21 (&cv
, CONST7
);
124 if (cv
[5] != CONST7
)
127 cv
= mc30 (&cv
, CONST2
);
128 if (cv
[14] != CONST2
)
131 cv
= ci (cv
, 8, CONST4
);
132 if (cv
[8] != CONST4
)
135 cv
= ci (cv
, 13, CONSTB
);
136 if (cv
[13] != CONSTB
)
139 cv
= ci (cv
, 23, CONST3
);
140 if (cv
[7] != CONST3
)
143 cv
= ci (cv
, 31, CONST2
);
144 if (cv
[15] != CONST2
)
147 cv
= mci (&cv
, 5, CONST1
);
148 if (cv
[5] != CONST1
)
151 cv
= mci (&cv
, 12, CONST3
);
152 if (cv
[12] != CONST3
)
155 cv
= mci (&cv
, 25, CONST5
);
156 if (cv
[9] != CONST5
)
159 cv
= mci (&cv
, 16, CONSTD
);
160 if (cv
[0] != CONSTD
)