Debian Codegraph @

gcc/testsuite/gcc.target/powerpc/vec-extract.h

raw
1 #include <stdlib.h>
2 #include <stddef.h>
3 #include <altivec.h>
4
5 #ifndef RTYPE
6 #define RTYPE TYPE
7 #endif
8
9 #ifdef DO_TRACE
10 #include <stdio.h>
11
12 #define TRACE(STRING, NUM) \
13 do \
14 { \
15 fprintf (stderr, "%s%s: %2d\n", (NUM == 0) ? "\n" : "", \
16 STRING, (int)NUM); \
17 fflush (stderr); \
18 } \
19 while (0)
20
21 #ifndef FAIL_FORMAT
22 #define FAIL_FORMAT "%ld"
23 #define FAIL_CAST(X) ((long)(X))
24 #endif
25
26 #define FAIL(EXP, GOT) \
27 do \
28 { \
29 fprintf (stderr, "Expected: " FAIL_FORMAT ", got " FAIL_FORMAT "\n", \
30 FAIL_CAST (EXP), FAIL_CAST (GOT)); \
31 fflush (stderr); \
32 abort (); \
33 } \
34 while (0)
35
36 #else
37 #define TRACE(STRING, NUM)
38 #define FAIL(EXP, GOT) abort ()
39 #endif
40
41 static void check (RTYPE, RTYPE) __attribute__((__noinline__));
42 static vector TYPE deoptimize (vector TYPE) __attribute__((__noinline__));
43 static vector TYPE *deoptimize_ptr (vector TYPE *) __attribute__((__noinline__));
44
45 static void
46 check (RTYPE expected, RTYPE got)
47 {
48 if (expected != got)
49 FAIL (expected, got);
50 }
51
52 static vector TYPE
53 deoptimize (vector TYPE a)
54 {
55 __asm__ (" # %x0" : "+wa" (a));
56 return a;
57 }
58
59 static vector TYPE *
60 deoptimize_ptr (vector TYPE *p)
61 {
62 __asm__ (" # %0" : "+r" (p));
63 return p;
64 }
65
66
67 /* Tests for the normal case of vec_extract where the vector is in a register
68 and returning the result in a register as a return value. */
69 RTYPE
70 get_auto_n (vector TYPE a, ssize_t n)
71 {
72 return (RTYPE) vec_extract (a, n);
73 }
74
75 RTYPE
76 get_auto_0 (vector TYPE a)
77 {
78 return (RTYPE) vec_extract (a, 0);
79 }
80
81 RTYPE
82 get_auto_1 (vector TYPE a)
83 {
84 return (RTYPE) vec_extract (a, 1);
85 }
86
87 #if ELEMENTS >= 4
88 RTYPE
89 get_auto_2 (vector TYPE a)
90 {
91 return (RTYPE) vec_extract (a, 2);
92 }
93
94 RTYPE
95 get_auto_3 (vector TYPE a)
96 {
97 return (RTYPE) vec_extract (a, 3);
98 }
99
100 #if ELEMENTS >= 8
101 RTYPE
102 get_auto_4 (vector TYPE a)
103 {
104 return (RTYPE) vec_extract (a, 4);
105 }
106
107 RTYPE
108 get_auto_5 (vector TYPE a)
109 {
110 return (RTYPE) vec_extract (a, 5);
111 }
112
113 RTYPE
114 get_auto_6 (vector TYPE a)
115 {
116 return (RTYPE) vec_extract (a, 6);
117 }
118
119 RTYPE
120 get_auto_7 (vector TYPE a)
121 {
122 return (RTYPE) vec_extract (a, 7);
123 }
124
125 #if ELEMENTS >= 16
126 RTYPE
127 get_auto_8 (vector TYPE a)
128 {
129 return (RTYPE) vec_extract (a, 8);
130 }
131
132 RTYPE
133 get_auto_9 (vector TYPE a)
134 {
135 return (RTYPE) vec_extract (a, 9);
136 }
137
138 RTYPE
139 get_auto_10 (vector TYPE a)
140 {
141 return (RTYPE) vec_extract (a, 10);
142 }
143
144 RTYPE
145 get_auto_11 (vector TYPE a)
146 {
147 return (RTYPE) vec_extract (a, 11);
148 }
149
150 RTYPE
151 get_auto_12 (vector TYPE a)
152 {
153 return (RTYPE) vec_extract (a, 12);
154 }
155
156 RTYPE
157 get_auto_13 (vector TYPE a)
158 {
159 return (RTYPE) vec_extract (a, 13);
160 }
161
162 RTYPE
163 get_auto_14 (vector TYPE a)
164 {
165 return (RTYPE) vec_extract (a, 14);
166 }
167
168 RTYPE
169 get_auto_15 (vector TYPE a)
170 {
171 return (RTYPE) vec_extract (a, 15);
172 }
173
174 #endif
175 #endif
176 #endif
177
178 typedef RTYPE (*auto_func_type) (vector TYPE);
179
180 static auto_func_type get_auto_const[] = {
181 get_auto_0,
182 get_auto_1,
183 #if ELEMENTS >= 4
184 get_auto_2,
185 get_auto_3,
186 #if ELEMENTS >= 8
187 get_auto_4,
188 get_auto_5,
189 get_auto_6,
190 get_auto_7,
191 #if ELEMENTS >= 16
192 get_auto_8,
193 get_auto_9,
194 get_auto_10,
195 get_auto_11,
196 get_auto_12,
197 get_auto_13,
198 get_auto_14,
199 get_auto_15,
200 #endif
201 #endif
202 #endif
203 };
204
205 extern void do_auto (vector TYPE a) __attribute__((__noinline__));
206
207 void
208 do_auto (vector TYPE a)
209 {
210 size_t i;
211
212 for (i = 0; i < sizeof (get_auto_const) / sizeof (get_auto_const[0]); i++)
213 {
214 TRACE ("auto", i);
215 check (get_auto_n (a, i), (get_auto_const[i]) (a));
216 }
217 }
218
219
220 /* Tests for vec_extract of a vector in a register, but storing the result
221 (there is an optimization where an element can be stored to memory if it is
222 in the right position to use a scalar store). */
223
224 void
225 get_store_n (RTYPE *p, vector TYPE a, ssize_t n)
226 {
227 *p = (RTYPE) vec_extract (a, n);
228 }
229
230 void
231 get_store_0 (RTYPE *p, vector TYPE a)
232 {
233 *p = (RTYPE) vec_extract (a, 0);
234 }
235
236 void
237 get_store_1 (RTYPE *p, vector TYPE a)
238 {
239 *p = (RTYPE) vec_extract (a, 1);
240 }
241
242 #if ELEMENTS >= 4
243 void
244 get_store_2 (RTYPE *p, vector TYPE a)
245 {
246 *p = (RTYPE) vec_extract (a, 2);
247 }
248
249 void
250 get_store_3 (RTYPE *p, vector TYPE a)
251 {
252 *p = (RTYPE) vec_extract (a, 3);
253 }
254
255 #if ELEMENTS >= 8
256 void
257 get_store_4 (RTYPE *p, vector TYPE a)
258 {
259 *p = (RTYPE) vec_extract (a, 4);
260 }
261
262 void
263 get_store_5 (RTYPE *p, vector TYPE a)
264 {
265 *p = (RTYPE) vec_extract (a, 5);
266 }
267
268 void
269 get_store_6 (RTYPE *p, vector TYPE a)
270 {
271 *p = (RTYPE) vec_extract (a, 6);
272 }
273
274 void
275 get_store_7 (RTYPE *p, vector TYPE a)
276 {
277 *p = (RTYPE) vec_extract (a, 7);
278 }
279
280 #if ELEMENTS >= 16
281 void
282 get_store_8 (RTYPE *p, vector TYPE a)
283 {
284 *p = (RTYPE) vec_extract (a, 8);
285 }
286
287 void
288 get_store_9 (RTYPE *p, vector TYPE a)
289 {
290 *p = (RTYPE) vec_extract (a, 9);
291 }
292
293 void
294 get_store_10 (RTYPE *p, vector TYPE a)
295 {
296 *p = (RTYPE) vec_extract (a, 10);
297 }
298
299 void
300 get_store_11 (RTYPE *p, vector TYPE a)
301 {
302 *p = (RTYPE) vec_extract (a, 11);
303 }
304
305 void
306 get_store_12 (RTYPE *p, vector TYPE a)
307 {
308 *p = (RTYPE) vec_extract (a, 12);
309 }
310
311 void
312 get_store_13 (RTYPE *p, vector TYPE a)
313 {
314 *p = (RTYPE) vec_extract (a, 13);
315 }
316
317 void
318 get_store_14 (RTYPE *p, vector TYPE a)
319 {
320 *p = (RTYPE) vec_extract (a, 14);
321 }
322
323 void
324 get_store_15 (RTYPE *p, vector TYPE a)
325 {
326 *p = (RTYPE) vec_extract (a, 15);
327 }
328
329 #endif
330 #endif
331 #endif
332
333 typedef void (*store_func_type) (RTYPE *, vector TYPE);
334
335 static store_func_type get_store_const[] = {
336 get_store_0,
337 get_store_1,
338 #if ELEMENTS >= 4
339 get_store_2,
340 get_store_3,
341 #if ELEMENTS >= 8
342 get_store_4,
343 get_store_5,
344 get_store_6,
345 get_store_7,
346 #if ELEMENTS >= 16
347 get_store_8,
348 get_store_9,
349 get_store_10,
350 get_store_11,
351 get_store_12,
352 get_store_13,
353 get_store_14,
354 get_store_15,
355 #endif
356 #endif
357 #endif
358 };
359
360 extern void do_store (vector TYPE a) __attribute__((__noinline__));
361
362 void
363 do_store (vector TYPE a)
364 {
365 size_t i;
366 RTYPE result_var, result_const;
367
368 for (i = 0; i < sizeof (get_store_const) / sizeof (get_store_const[0]); i++)
369 {
370 TRACE ("store", i);
371 get_store_n (&result_var, a, i);
372 (get_store_const[i]) (&result_const, a);
373 check (result_var, result_const);
374 }
375 }
376
377
378 /* Tests for vec_extract where the vector comes from memory (the compiler can
379 optimize this by doing a scalar load without having to load the whole
380 vector). */
381 RTYPE
382 get_pointer_n (vector TYPE *p, ssize_t n)
383 {
384 return (RTYPE) vec_extract (*p, n);
385 }
386
387 RTYPE
388 get_pointer_0 (vector TYPE *p)
389 {
390 return (RTYPE) vec_extract (*p, 0);
391 }
392
393 RTYPE
394 get_pointer_1 (vector TYPE *p)
395 {
396 return (RTYPE) vec_extract (*p, 1);
397 }
398
399 #if ELEMENTS >= 4
400 RTYPE
401 get_pointer_2 (vector TYPE *p)
402 {
403 return (RTYPE) vec_extract (*p, 2);
404 }
405
406 RTYPE
407 get_pointer_3 (vector TYPE *p)
408 {
409 return (RTYPE) vec_extract (*p, 3);
410 }
411
412 #if ELEMENTS >= 8
413 RTYPE
414 get_pointer_4 (vector TYPE *p)
415 {
416 return (RTYPE) vec_extract (*p, 4);
417 }
418
419 RTYPE
420 get_pointer_5 (vector TYPE *p)
421 {
422 return (RTYPE) vec_extract (*p, 5);
423 }
424
425 RTYPE
426 get_pointer_6 (vector TYPE *p)
427 {
428 return (RTYPE) vec_extract (*p, 6);
429 }
430
431 RTYPE
432 get_pointer_7 (vector TYPE *p)
433 {
434 return (RTYPE) vec_extract (*p, 7);
435 }
436
437 #if ELEMENTS >= 16
438 RTYPE
439 get_pointer_8 (vector TYPE *p)
440 {
441 return (RTYPE) vec_extract (*p, 8);
442 }
443
444 RTYPE
445 get_pointer_9 (vector TYPE *p)
446 {
447 return (RTYPE) vec_extract (*p, 9);
448 }
449
450 RTYPE
451 get_pointer_10 (vector TYPE *p)
452 {
453 return (RTYPE) vec_extract (*p, 10);
454 }
455
456 RTYPE
457 get_pointer_11 (vector TYPE *p)
458 {
459 return (RTYPE) vec_extract (*p, 11);
460 }
461
462 RTYPE
463 get_pointer_12 (vector TYPE *p)
464 {
465 return (RTYPE) vec_extract (*p, 12);
466 }
467
468 RTYPE
469 get_pointer_13 (vector TYPE *p)
470 {
471 return (RTYPE) vec_extract (*p, 13);
472 }
473
474 RTYPE
475 get_pointer_14 (vector TYPE *p)
476 {
477 return (RTYPE) vec_extract (*p, 14);
478 }
479
480 RTYPE
481 get_pointer_15 (vector TYPE *p)
482 {
483 return (RTYPE) vec_extract (*p, 15);
484 }
485
486 #endif
487 #endif
488 #endif
489
490 typedef RTYPE (*pointer_func_type) (vector TYPE *);
491
492 static pointer_func_type get_pointer_const[] = {
493 get_pointer_0,
494 get_pointer_1,
495 #if ELEMENTS >= 4
496 get_pointer_2,
497 get_pointer_3,
498 #if ELEMENTS >= 8
499 get_pointer_4,
500 get_pointer_5,
501 get_pointer_6,
502 get_pointer_7,
503 #if ELEMENTS >= 16
504 get_pointer_8,
505 get_pointer_9,
506 get_pointer_10,
507 get_pointer_11,
508 get_pointer_12,
509 get_pointer_13,
510 get_pointer_14,
511 get_pointer_15,
512 #endif
513 #endif
514 #endif
515 };
516
517 extern void do_pointer (vector TYPE *p) __attribute__((__noinline__));
518
519 void
520 do_pointer (vector TYPE *p)
521 {
522 size_t i;
523
524 for (i = 0; i < sizeof (get_pointer_const) / sizeof (get_pointer_const[0]); i++)
525 {
526 TRACE ("pointer", i);
527 check (get_pointer_n (p, i), (get_pointer_const[i]) (p));
528 }
529 }
530
531
532 /* Test for vec_extract where the vector comes from an indexed memory
533 operation. This is to make sure that if the compiler optimizes vec_extract
534 from memory to be a scalar load, the address is correctly adjusted. */
535
536 RTYPE
537 get_indexed_n (vector TYPE *p, size_t x, ssize_t n)
538 {
539 return (RTYPE) vec_extract (p[x], n);
540 }
541
542 RTYPE
543 get_indexed_0 (vector TYPE *p, size_t x)
544 {
545 return (RTYPE) vec_extract (p[x], 0);
546 }
547
548 RTYPE
549 get_indexed_1 (vector TYPE *p, size_t x)
550 {
551 return (RTYPE) vec_extract (p[x], 1);
552 }
553
554 #if ELEMENTS >= 4
555 RTYPE
556 get_indexed_2 (vector TYPE *p, size_t x)
557 {
558 return (RTYPE) vec_extract (p[x], 2);
559 }
560
561 RTYPE
562 get_indexed_3 (vector TYPE *p, size_t x)
563 {
564 return (RTYPE) vec_extract (p[x], 3);
565 }
566
567 #if ELEMENTS >= 8
568 RTYPE
569 get_indexed_4 (vector TYPE *p, size_t x)
570 {
571 return (RTYPE) vec_extract (p[x], 4);
572 }
573
574 RTYPE
575 get_indexed_5 (vector TYPE *p, size_t x)
576 {
577 return (RTYPE) vec_extract (p[x], 5);
578 }
579
580 RTYPE
581 get_indexed_6 (vector TYPE *p, size_t x)
582 {
583 return (RTYPE) vec_extract (p[x], 6);
584 }
585
586 RTYPE
587 get_indexed_7 (vector TYPE *p, size_t x)
588 {
589 return (RTYPE) vec_extract (p[x], 7);
590 }
591
592 #if ELEMENTS >= 16
593 RTYPE
594 get_indexed_8 (vector TYPE *p, size_t x)
595 {
596 return (RTYPE) vec_extract (p[x], 8);
597 }
598
599 RTYPE
600 get_indexed_9 (vector TYPE *p, size_t x)
601 {
602 return (RTYPE) vec_extract (p[x], 9);
603 }
604
605 RTYPE
606 get_indexed_10 (vector TYPE *p, size_t x)
607 {
608 return (RTYPE) vec_extract (p[x], 10);
609 }
610
611 RTYPE
612 get_indexed_11 (vector TYPE *p, size_t x)
613 {
614 return (RTYPE) vec_extract (p[x], 11);
615 }
616
617 RTYPE
618 get_indexed_12 (vector TYPE *p, size_t x)
619 {
620 return (RTYPE) vec_extract (p[x], 12);
621 }
622
623 RTYPE
624 get_indexed_13 (vector TYPE *p, size_t x)
625 {
626 return (RTYPE) vec_extract (p[x], 13);
627 }
628
629 RTYPE
630 get_indexed_14 (vector TYPE *p, size_t x)
631 {
632 return (RTYPE) vec_extract (p[x], 14);
633 }
634
635 RTYPE
636 get_indexed_15 (vector TYPE *p, size_t x)
637 {
638 return (RTYPE) vec_extract (p[x], 15);
639 }
640
641 #endif
642 #endif
643 #endif
644
645 typedef RTYPE (*indexed_func_type) (vector TYPE *, size_t);
646
647 static indexed_func_type get_indexed_const[] = {
648 get_indexed_0,
649 get_indexed_1,
650 #if ELEMENTS >= 4
651 get_indexed_2,
652 get_indexed_3,
653 #if ELEMENTS >= 8
654 get_indexed_4,
655 get_indexed_5,
656 get_indexed_6,
657 get_indexed_7,
658 #if ELEMENTS >= 16
659 get_indexed_8,
660 get_indexed_9,
661 get_indexed_10,
662 get_indexed_11,
663 get_indexed_12,
664 get_indexed_13,
665 get_indexed_14,
666 get_indexed_15,
667 #endif
668 #endif
669 #endif
670 };
671
672 extern void do_indexed (vector TYPE *p, size_t x) __attribute__((__noinline__));
673
674 void
675 do_indexed (vector TYPE *p, size_t x)
676 {
677 size_t i;
678
679 for (i = 0; i < sizeof (get_indexed_const) / sizeof (get_indexed_const[0]); i++)
680 {
681 TRACE ("indexed", i);
682 check (get_indexed_n (p, x, i), (get_indexed_const[i]) (p, x));
683 }
684 }
685
686
687 /* Test for vec_extract where the vector comes from memory using an address
688 with a pointer and a constant offset. This will occur in ISA 3.0 which
689 added d-form memory addressing for vectors. */
690
691 RTYPE
692 get_ptr_plus1_n (vector TYPE *p, ssize_t n)
693 {
694 return (RTYPE) vec_extract (p[1], n);
695 }
696
697 RTYPE
698 get_ptr_plus1_0 (vector TYPE *p)
699 {
700 return (RTYPE) vec_extract (p[1], 0);
701 }
702
703 RTYPE
704 get_ptr_plus1_1 (vector TYPE *p)
705 {
706 return (RTYPE) vec_extract (p[1], 1);
707 }
708
709 #if ELEMENTS >= 4
710 RTYPE
711 get_ptr_plus1_2 (vector TYPE *p)
712 {
713 return (RTYPE) vec_extract (p[1], 2);
714 }
715
716 RTYPE
717 get_ptr_plus1_3 (vector TYPE *p)
718 {
719 return (RTYPE) vec_extract (p[1], 3);
720 }
721
722 #if ELEMENTS >= 8
723 RTYPE
724 get_ptr_plus1_4 (vector TYPE *p)
725 {
726 return (RTYPE) vec_extract (p[1], 4);
727 }
728
729 RTYPE
730 get_ptr_plus1_5 (vector TYPE *p)
731 {
732 return (RTYPE) vec_extract (p[1], 5);
733 }
734
735 RTYPE
736 get_ptr_plus1_6 (vector TYPE *p)
737 {
738 return (RTYPE) vec_extract (p[1], 6);
739 }
740
741 RTYPE
742 get_ptr_plus1_7 (vector TYPE *p)
743 {
744 return (RTYPE) vec_extract (p[1], 7);
745 }
746
747 #if ELEMENTS >= 16
748 RTYPE
749 get_ptr_plus1_8 (vector TYPE *p)
750 {
751 return (RTYPE) vec_extract (p[1], 8);
752 }
753
754 RTYPE
755 get_ptr_plus1_9 (vector TYPE *p)
756 {
757 return (RTYPE) vec_extract (p[1], 9);
758 }
759
760 RTYPE
761 get_ptr_plus1_10 (vector TYPE *p)
762 {
763 return (RTYPE) vec_extract (p[1], 10);
764 }
765
766 RTYPE
767 get_ptr_plus1_11 (vector TYPE *p)
768 {
769 return (RTYPE) vec_extract (p[1], 11);
770 }
771
772 RTYPE
773 get_ptr_plus1_12 (vector TYPE *p)
774 {
775 return (RTYPE) vec_extract (p[1], 12);
776 }
777
778 RTYPE
779 get_ptr_plus1_13 (vector TYPE *p)
780 {
781 return (RTYPE) vec_extract (p[1], 13);
782 }
783
784 RTYPE
785 get_ptr_plus1_14 (vector TYPE *p)
786 {
787 return (RTYPE) vec_extract (p[1], 14);
788 }
789
790 RTYPE
791 get_ptr_plus1_15 (vector TYPE *p)
792 {
793 return (RTYPE) vec_extract (p[1], 15);
794 }
795
796 #endif
797 #endif
798 #endif
799
800 typedef RTYPE (*pointer_func_type) (vector TYPE *);
801
802 static pointer_func_type get_ptr_plus1_const[] = {
803 get_ptr_plus1_0,
804 get_ptr_plus1_1,
805 #if ELEMENTS >= 4
806 get_ptr_plus1_2,
807 get_ptr_plus1_3,
808 #if ELEMENTS >= 8
809 get_ptr_plus1_4,
810 get_ptr_plus1_5,
811 get_ptr_plus1_6,
812 get_ptr_plus1_7,
813 #if ELEMENTS >= 16
814 get_ptr_plus1_8,
815 get_ptr_plus1_9,
816 get_ptr_plus1_10,
817 get_ptr_plus1_11,
818 get_ptr_plus1_12,
819 get_ptr_plus1_13,
820 get_ptr_plus1_14,
821 get_ptr_plus1_15,
822 #endif
823 #endif
824 #endif
825 };
826
827 extern void do_ptr_plus1 (vector TYPE *p) __attribute__((__noinline__));
828
829 void
830 do_ptr_plus1 (vector TYPE *p)
831 {
832 size_t i;
833
834 for (i = 0; i < sizeof (get_ptr_plus1_const) / sizeof (get_ptr_plus1_const[0]); i++)
835 {
836 TRACE ("ptr_plus1", i);
837 check (get_ptr_plus1_n (p, i), (get_ptr_plus1_const[i]) (p));
838 }
839 }
840
841
842 /* Test for vec_extract where the vector comes from a static variable. */
843
844 static vector TYPE s;
845
846 RTYPE
847 get_static_n (ssize_t n)
848 {
849 return (RTYPE) vec_extract (s, n);
850 }
851
852 RTYPE
853 get_static_0 (void)
854 {
855 return (RTYPE) vec_extract (s, 0);
856 }
857
858 RTYPE
859 get_static_1 (void)
860 {
861 return (RTYPE) vec_extract (s, 1);
862 }
863
864 #if ELEMENTS >= 4
865 RTYPE
866 get_static_2 (void)
867 {
868 return (RTYPE) vec_extract (s, 2);
869 }
870
871 RTYPE
872 get_static_3 (void)
873 {
874 return (RTYPE) vec_extract (s, 3);
875 }
876
877 #if ELEMENTS >= 8
878 RTYPE
879 get_static_4 (void)
880 {
881 return (RTYPE) vec_extract (s, 4);
882 }
883
884 RTYPE
885 get_static_5 (void)
886 {
887 return (RTYPE) vec_extract (s, 5);
888 }
889
890 RTYPE
891 get_static_6 (void)
892 {
893 return (RTYPE) vec_extract (s, 6);
894 }
895
896 RTYPE
897 get_static_7 (void)
898 {
899 return (RTYPE) vec_extract (s, 7);
900 }
901
902 #if ELEMENTS >= 16
903 RTYPE
904 get_static_8 (void)
905 {
906 return (RTYPE) vec_extract (s, 8);
907 }
908
909 RTYPE
910 get_static_9 (void)
911 {
912 return (RTYPE) vec_extract (s, 9);
913 }
914
915 RTYPE
916 get_static_10 (void)
917 {
918 return (RTYPE) vec_extract (s, 10);
919 }
920
921 RTYPE
922 get_static_11 (void)
923 {
924 return (RTYPE) vec_extract (s, 11);
925 }
926
927 RTYPE
928 get_static_12 (void)
929 {
930 return (RTYPE) vec_extract (s, 12);
931 }
932
933 RTYPE
934 get_static_13 (void)
935 {
936 return (RTYPE) vec_extract (s, 13);
937 }
938
939 RTYPE
940 get_static_14 (void)
941 {
942 return (RTYPE) vec_extract (s, 14);
943 }
944
945 RTYPE
946 get_static_15 (void)
947 {
948 return (RTYPE) vec_extract (s, 15);
949 }
950
951 #endif
952 #endif
953 #endif
954
955 typedef RTYPE (*static_func_type) (void);
956
957 static static_func_type get_static_const[] = {
958 get_static_0,
959 get_static_1,
960 #if ELEMENTS >= 4
961 get_static_2,
962 get_static_3,
963 #if ELEMENTS >= 8
964 get_static_4,
965 get_static_5,
966 get_static_6,
967 get_static_7,
968 #if ELEMENTS >= 16
969 get_static_8,
970 get_static_9,
971 get_static_10,
972 get_static_11,
973 get_static_12,
974 get_static_13,
975 get_static_14,
976 get_static_15,
977 #endif
978 #endif
979 #endif
980 };
981
982 extern void do_static (void) __attribute__((__noinline__));
983
984 void
985 do_static (void)
986 {
987 size_t i;
988
989 for (i = 0; i < sizeof (get_static_const) / sizeof (get_static_const[0]); i++)
990 {
991 TRACE ("static", i);
992 check (get_static_n (i), (get_static_const[i]) ());
993 }
994 }
995
996
997 /* Test for vec_extract where the vector is in a global variable. */
998
999 vector TYPE g;
1000
1001 RTYPE
1002 get_global_n (ssize_t n)
1003 {
1004 return (RTYPE) vec_extract (g, n);
1005 }
1006
1007 RTYPE
1008 get_global_0 (void)
1009 {
1010 return (RTYPE) vec_extract (g, 0);
1011 }
1012
1013 RTYPE
1014 get_global_1 (void)
1015 {
1016 return (RTYPE) vec_extract (g, 1);
1017 }
1018
1019 #if ELEMENTS >= 4
1020 RTYPE
1021 get_global_2 (void)
1022 {
1023 return (RTYPE) vec_extract (g, 2);
1024 }
1025
1026 RTYPE
1027 get_global_3 (void)
1028 {
1029 return (RTYPE) vec_extract (g, 3);
1030 }
1031
1032 #if ELEMENTS >= 8
1033 RTYPE
1034 get_global_4 (void)
1035 {
1036 return (RTYPE) vec_extract (g, 4);
1037 }
1038
1039 RTYPE
1040 get_global_5 (void)
1041 {
1042 return (RTYPE) vec_extract (g, 5);
1043 }
1044
1045 RTYPE
1046 get_global_6 (void)
1047 {
1048 return (RTYPE) vec_extract (g, 6);
1049 }
1050
1051 RTYPE
1052 get_global_7 (void)
1053 {
1054 return (RTYPE) vec_extract (g, 7);
1055 }
1056
1057 #if ELEMENTS >= 16
1058 RTYPE
1059 get_global_8 (void)
1060 {
1061 return (RTYPE) vec_extract (g, 8);
1062 }
1063
1064 RTYPE
1065 get_global_9 (void)
1066 {
1067 return (RTYPE) vec_extract (g, 9);
1068 }
1069
1070 RTYPE
1071 get_global_10 (void)
1072 {
1073 return (RTYPE) vec_extract (g, 10);
1074 }
1075
1076 RTYPE
1077 get_global_11 (void)
1078 {
1079 return (RTYPE) vec_extract (g, 11);
1080 }
1081
1082 RTYPE
1083 get_global_12 (void)
1084 {
1085 return (RTYPE) vec_extract (g, 12);
1086 }
1087
1088 RTYPE
1089 get_global_13 (void)
1090 {
1091 return (RTYPE) vec_extract (g, 13);
1092 }
1093
1094 RTYPE
1095 get_global_14 (void)
1096 {
1097 return (RTYPE) vec_extract (g, 14);
1098 }
1099
1100 RTYPE
1101 get_global_15 (void)
1102 {
1103 return (RTYPE) vec_extract (g, 15);
1104 }
1105
1106 #endif
1107 #endif
1108 #endif
1109
1110 typedef RTYPE (*global_func_type) (void);
1111
1112 static global_func_type get_global_const[] = {
1113 get_global_0,
1114 get_global_1,
1115 #if ELEMENTS >= 4
1116 get_global_2,
1117 get_global_3,
1118 #if ELEMENTS >= 8
1119 get_global_4,
1120 get_global_5,
1121 get_global_6,
1122 get_global_7,
1123 #if ELEMENTS >= 16
1124 get_global_8,
1125 get_global_9,
1126 get_global_10,
1127 get_global_11,
1128 get_global_12,
1129 get_global_13,
1130 get_global_14,
1131 get_global_15,
1132 #endif
1133 #endif
1134 #endif
1135 };
1136
1137 extern void do_global (void) __attribute__((__noinline__));
1138
1139 void
1140 do_global (void)
1141 {
1142 size_t i;
1143
1144 for (i = 0; i < sizeof (get_global_const) / sizeof (get_global_const[0]); i++)
1145 {
1146 TRACE ("global", i);
1147 check (get_global_n (i), (get_global_const[i]) ());
1148 }
1149 }
1150
1151
1152 /* Main program to test all of the possibilities. */
1153
1154 int
1155 main (void)
1156 {
1157 size_t i;
1158 vector TYPE x = INITIAL;
1159 vector TYPE *p, *p2, a, y;
1160 vector TYPE z[2];
1161
1162 a = deoptimize (x);
1163 s = deoptimize (x);
1164 g = deoptimize (x);
1165 y = deoptimize (x);
1166 z[0] = deoptimize (x);
1167 z[1] = deoptimize (x);
1168 p = deoptimize_ptr (&y);
1169 p2 = deoptimize_ptr (&z[0]);
1170
1171 do_auto (a);
1172 do_store (a);
1173 do_pointer (p);
1174 for (i = 0; i < 2; i++)
1175 do_indexed (p2, i);
1176 do_ptr_plus1 (p2);
1177 do_static ();
1178 do_global ();
1179 return 0;
1180 }