2 /* { dg-require-effective-target vmx_hw } */
3 /* { dg-options "-maltivec" } */
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);
18 /* Test that indices > length of vector are applied modulo the vector
21 /* Test for vector residing in register. */
22 vector
int s3 (vector
int v
, int x
)
24 return vec_insert (x
, v
, 3);
27 vector
int s1 (vector
int v
, int x
)
29 return vec_insert (x
, v
, 1);
32 vector
int s21 (vector
int v
, int x
)
34 return vec_insert (x
, v
, 21);
37 vector
int s30 (vector
int v
, int x
)
39 return vec_insert (x
, v
, 30);
42 /* Test for vector residing in memory. */
43 vector
int ms3 (vector
int *vp
, int x
)
45 return vec_insert (x
, *vp
, 3);
48 vector
int ms1 (vector
int *vp
, int x
)
50 return vec_insert (x
, *vp
, 1);
53 vector
int ms21 (vector
int *vp
, int x
)
55 return vec_insert (x
, *vp
, 21);
58 vector
int ms30 (vector
int *vp
, int x
)
60 return vec_insert (x
, *vp
, 30);
63 /* Test the same with variable indices. */
65 /* Test for variable selector and vector residing in register. */
66 __attribute__((noinline
))
67 vector
int ci (vector
int v
, int i
, int x
)
69 return vec_insert (x
, v
, i
);
72 /* Test for variable selector and vector residing in memory. */
73 __attribute__((noinline
))
74 vector
int mci(vector
int *vp
, int i
, int x
)
76 return vec_insert (x
, *vp
, i
);
80 int main (int argc
, int *argv
[]) {
81 vector
int sv
= { CONST0
, CONST1
, CONST2
, CONST3
};
92 sv
= s21 (sv
, CONST0
);
96 sv
= s30 (sv
, CONST1
);
100 sv
= ms3 (&sv
, CONST2
);
101 if (sv
[3] != CONST2
)
104 sv
= ms1 (&sv
, CONST0
);
105 if (sv
[1] != CONST0
)
108 sv
= ms21 (&sv
, CONST3
);
109 if (sv
[1] != CONST3
)
112 sv
= ms30 (&sv
, CONST0
);
113 if (sv
[2] != CONST0
)
116 sv
= ci (sv
, 5, CONST0
);
117 if (sv
[1] != CONST0
)
120 sv
= ci (sv
, 2, CONST3
);
121 if (sv
[2] != CONST3
)
124 sv
= ci (sv
, 15, CONST1
);
125 if (sv
[3] != CONST1
)
128 sv
= ci (sv
, 28, CONST3
);
129 if (sv
[0] != CONST3
)
132 sv
= mci (&sv
, 5, CONST2
);
133 if (sv
[1] != CONST2
)
136 sv
= mci (&sv
, 12, CONST1
);
137 if (sv
[0] != CONST1
)
140 sv
= mci (&sv
, 25, CONST2
);
141 if (sv
[1] != CONST2
)
144 sv
= mci (&sv
, 16, CONST3
);
145 if (sv
[0] != CONST3
)