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);
23 /* Test that indices > length of vector are applied modulo the vector
26 /* Test for vector residing in register. */
27 vector
short s3 (vector
short v
, short x
)
29 return vec_insert (x
, v
, 3);
32 vector
short s7 (vector
short v
, short x
)
34 return vec_insert (x
, v
, 7);
37 vector
short s21 (vector
short v
, short x
)
39 return vec_insert (x
, v
, 21);
42 vector
short s30 (vector
short v
, short x
)
44 return vec_insert (x
, v
, 30);
47 /* Test for vector residing in memory. */
48 vector
short ms3 (vector
short *vp
, short x
)
50 return vec_insert (x
, *vp
, 3);
53 vector
short ms7 (vector
short *vp
, short x
)
55 return vec_insert (x
, *vp
, 7);
58 vector
short ms21 (vector
short *vp
, short x
)
60 return vec_insert (x
, *vp
, 21);
63 vector
short ms30 (vector
short *vp
, short x
)
65 return vec_insert (x
, *vp
, 30);
68 /* Test the same with variable indices. */
70 /* Test for variable selector and vector residing in register. */
71 __attribute__((noinline
))
72 vector
short ci (vector
short v
, int i
, short x
)
74 return vec_insert (x
, v
, i
);
77 /* Test for variable selector and vector residing in memory. */
78 __attribute__((noinline
))
79 vector
short mci (vector
short *vp
, int i
, short x
)
81 return vec_insert (x
, *vp
, i
);
85 int main (int argc
, short *argv
[]) {
87 CONST0
, CONST1
, CONST2
, CONST3
, CONST4
, CONST5
, CONST6
, CONST7
};
98 sv
= s21 (sv
, CONST3
);
102 sv
= s30 (sv
, CONST2
);
103 if (sv
[6] != CONST2
)
106 sv
= ms3 (&sv
, CONST5
);
107 if (sv
[3] != CONST5
)
110 sv
= ms7 (&sv
, CONST1
);
111 if (sv
[7] != CONST1
)
114 sv
= ms21 (&sv
, CONST2
);
115 if (sv
[5] != CONST2
)
118 sv
= ms30 (&sv
, CONST0
);
119 if (sv
[6] != CONST0
)
122 sv
= ci (sv
, 5, CONST6
);
123 if (sv
[5] != CONST6
)
126 sv
= ci (sv
, 2, CONST4
);
127 if (sv
[2] != CONST4
)
130 sv
= ci (sv
, 15, CONST3
);
131 if (sv
[7] != CONST3
)
134 sv
= ci (sv
, 28, CONST3
);
135 if (sv
[4] != CONST3
)
138 sv
= mci (&sv
, 5, CONST3
);
139 if (sv
[5] != CONST3
)
142 sv
= mci (&sv
, 12, CONST7
);
143 if (sv
[4] != CONST7
)
146 sv
= mci (&sv
, 25, CONST6
);
147 if (sv
[1] != CONST6
)
150 sv
= mci (&sv
, 16, CONST5
);
151 if (sv
[0] != CONST5
)