1 /* { dg-do run { target vmx_hw } } */
2 /* { dg-do compile { target { ! vmx_hw } } } */
3 /* { dg-require-effective-target powerpc_altivec_ok } */
4 /* { dg-options "-maltivec -mabi=altivec -O2 -save-temps" } */
6 /* Check that "easy" AltiVec constants are correctly synthesized. */
8 extern void abort (void);
9 extern int memcmp (const void *, const void *, __SIZE_TYPE__
);
11 typedef __attribute__ ((vector_size (16))) unsigned char v16qi
;
12 typedef __attribute__ ((vector_size (16))) unsigned short v8hi
;
13 typedef __attribute__ ((vector_size (16))) unsigned int v4si
;
15 typedef __attribute__((aligned(16))) char c16
[16];
16 typedef __attribute__((aligned(16))) short s8
[8];
17 typedef __attribute__((aligned(16))) int i4
[4];
19 #define V16QI(V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11,V12,V13,V14,V15,V16) \
20 v16qi v = {V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11,V12,V13,V14,V15,V16}; \
21 static c16 w = {V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11,V12,V13,V14,V15,V16}; \
24 #define V8HI(V1,V2,V3,V4,V5,V6,V7,V8) \
25 v8hi v = {V1,V2,V3,V4,V5,V6,V7,V8}; \
26 static s8 w = {V1,V2,V3,V4,V5,V6,V7,V8}; \
29 #define V4SI(V1,V2,V3,V4) \
30 v4si v = {V1,V2,V3,V4}; \
31 static i4 w = {V1,V2,V3,V4}; \
35 /* Use three different check functions for each mode-instruction pair.
36 The callers have no typecasting and no addressable vectors, to make
37 the test more robust. */
39 void __attribute__ ((noinline
)) check_v16qi (v16qi v1
, char *v2
)
41 if (memcmp (&v1
, v2
, 16))
45 void __attribute__ ((noinline
)) check_v8hi (v8hi v1
, short *v2
)
47 if (memcmp (&v1
, v2
, 16))
51 void __attribute__ ((noinline
)) check_v4si (v4si v1
, int *v2
)
53 if (memcmp (&v1
, v2
, 16))
60 void v16qi_vspltisb ()
62 V16QI (15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15);
65 void v16qi_vspltisb_neg ()
67 V16QI (-5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5);
70 void v16qi_vspltisb_addself ()
72 V16QI (30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30);
75 void v16qi_vspltisb_neg_addself ()
77 V16QI (-24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24);
80 void v16qi_vspltish ()
82 V16QI (0, 15, 0, 15, 0, 15, 0, 15, 0, 15, 0, 15, 0, 15, 0, 15);
85 void v16qi_vspltish_addself ()
87 V16QI (0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30);
90 void v16qi_vspltish_neg ()
92 V16QI (-1, -5, -1, -5, -1, -5, -1, -5, -1, -5, -1, -5, -1, -5, -1, -5);
95 void v16qi_vspltisw ()
97 V16QI (0, 0, 0, 15, 0, 0, 0, 15, 0, 0, 0, 15, 0, 0, 0, 15);
100 void v16qi_vspltisw_addself ()
102 V16QI (0, 0, 0, 30, 0, 0, 0, 30, 0, 0, 0, 30, 0, 0, 0, 30);
105 void v16qi_vspltisw_neg ()
107 V16QI (-1, -1, -1, -5, -1, -1, -1, -5, -1, -1, -1, -5, -1, -1, -1, -5);
113 void v8hi_vspltisb ()
115 V8HI (0x0F0F, 0x0F0F, 0x0F0F, 0x0F0F, 0x0F0F, 0x0F0F, 0x0F0F, 0x0F0F);
118 void v8hi_vspltisb_addself ()
120 V8HI (0x1E1E, 0x1E1E, 0x1E1E, 0x1E1E, 0x1E1E, 0x1E1E, 0x1E1E, 0x1E1E);
123 void v8hi_vspltisb_neg ()
125 V8HI (0xFBFB, 0xFBFB, 0xFBFB, 0xFBFB, 0xFBFB, 0xFBFB, 0xFBFB, 0xFBFB);
128 void v8hi_vspltish ()
130 V8HI (15, 15, 15, 15, 15, 15, 15, 15);
133 void v8hi_vspltish_neg ()
135 V8HI (-5, -5, -5, -5, -5, -5, -5, -5);
138 void v8hi_vspltish_addself ()
140 V8HI (30, 30, 30, 30, 30, 30, 30, 30);
143 void v8hi_vspltish_neg_addself ()
145 V8HI (-24, -24, -24, -24, -24, -24, -24, -24);
148 void v8hi_vspltisw ()
150 V8HI (0, 15, 0, 15, 0, 15, 0, 15);
153 void v8hi_vspltisw_addself ()
155 V8HI (0, 30, 0, 30, 0, 30, 0, 30);
158 void v8hi_vspltisw_neg ()
160 V8HI (-1, -5, -1, -5, -1, -5, -1, -5);
165 void v4si_vspltisb ()
167 V4SI (0x0F0F0F0F, 0x0F0F0F0F, 0x0F0F0F0F, 0x0F0F0F0F);
170 void v4si_vspltisb_addself ()
172 V4SI (0x1E1E1E1E, 0x1E1E1E1E, 0x1E1E1E1E, 0x1E1E1E1E);
175 void v4si_vspltisb_neg ()
177 V4SI (0xFBFBFBFB, 0xFBFBFBFB, 0xFBFBFBFB, 0xFBFBFBFB);
180 void v4si_vspltish ()
182 V4SI (0x000F000F, 0x000F000F, 0x000F000F, 0x000F000F);
185 void v4si_vspltish_addself ()
187 V4SI (0x001E001E, 0x001E001E, 0x001E001E, 0x001E001E);
190 void v4si_vspltish_neg ()
192 V4SI (0xFFFBFFFB, 0xFFFBFFFB, 0xFFFBFFFB, 0xFFFBFFFB);
195 void v4si_vspltisw ()
197 V4SI (15, 15, 15, 15);
200 void v4si_vspltisw_neg ()
202 V4SI (-5, -5, -5, -5);
205 void v4si_vspltisw_addself ()
207 V4SI (30, 30, 30, 30);
210 void v4si_vspltisw_neg_addself ()
212 V4SI (-24, -24, -24, -24);
220 v16qi_vspltisb_neg ();
221 v16qi_vspltisb_addself ();
222 v16qi_vspltisb_neg_addself ();
224 v16qi_vspltish_addself ();
225 v16qi_vspltish_neg ();
227 v16qi_vspltisw_addself ();
228 v16qi_vspltisw_neg ();
231 v8hi_vspltisb_addself ();
232 v8hi_vspltisb_neg ();
234 v8hi_vspltish_neg ();
235 v8hi_vspltish_addself ();
236 v8hi_vspltish_neg_addself ();
238 v8hi_vspltisw_addself ();
239 v8hi_vspltisw_neg ();
242 v4si_vspltisb_addself ();
243 v4si_vspltisb_neg ();
245 v4si_vspltish_addself ();
246 v4si_vspltish_neg ();
248 v4si_vspltisw_neg ();
249 v4si_vspltisw_addself ();
250 v4si_vspltisw_neg_addself ();
254 /* { dg-final { scan-assembler-not "lvx" { target { ! powerpc*le-*-* } } } } */