aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.apple/apple-altivec-10.c
blob: 12afefa4c1c1bcf6ec3da44ec54d19c0424e1c67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* APPLE LOCAL file AltiVec */
/* { dg-do run { target powerpc*-*-* } } */
/* { dg-options "-faltivec" } */
extern void abort();

#include <stdio.h>

int main()
{
  char str[128];
  vector unsigned char
  vuchar = (vector unsigned char)((vector unsigned int)(0x001f001d, 0x001f001d, 0x001f001d, 0x001f001d));

  vector unsigned short
  vushort =  (vector unsigned short)((vector unsigned int)(0x001f001d, 0x001f001d, 0x001f001d, 0x001f001d));

  vector unsigned char
  vushort_to_char = (vector unsigned char)
		     ((vector unsigned short)(0x001f,0x001d, 0x001f,0x001d, 0x001f,0x001d, 0x001f,0x001d));

  vector signed char
  vschar = (vector signed char)((vector signed int)(0x001f001d, 0x001f001d, 0x001f001d, 0x001f001d));

  vector signed short
  vsshort =  (vector signed short)((vector signed int)(0x001f001d, 0x001f001d, 0x001f001d, 0x001f001d));

  vector signed char
  vsshort_to_char = (vector signed char)
		     ((vector signed short)(0x001f,0x001d, 0x001f,0x001d, 0x001f,0x001d, 0x001f,0x001d));

  vector unsigned int
  vui = (vector unsigned int)((vector unsigned short)(0x011f,0x021d, 0x031f,0x041d, 0x051f,0x061d, 0x071f,0x081d));

  vector unsigned int
  vui1 = (vector unsigned int)
          ((vector unsigned char)(0x01,0x1f,0x02,0x1d, 0x03,0x1f,0x04,0x1d, 
				  0x05,0x1f,0x06,0x1d, 0x07,0x1f,0x08,0x1d));

   vector unsigned short
   vus = (vector unsigned short)
	  ((vector unsigned char)(0x01,0x1f,0x02,0x1d, 0x03,0x1f,0x04,0x1d, 
	  0x05,0x1f,0x06,0x1d, 0x07,0x1f,0x08,0x1d));

   vector float
   vf =   (vector float)
           ((vector unsigned int)(0x001f001d, 0x001f001d, 0x001f001d, 0x001f001d));

   sprintf(str, "%vhu", vuchar);
   if (strcmp (str, "31 29 31 29 31 29 31 29"))
     abort();
   sprintf(str, "%vhu", vushort);
   if (strcmp (str, "31 29 31 29 31 29 31 29"))
     abort();
   sprintf(str, "%vhu", vushort_to_char);
   if (strcmp (str, "31 29 31 29 31 29 31 29"))
     abort();
   sprintf(str, "%vhu", vschar);
   if (strcmp (str, "31 29 31 29 31 29 31 29"))
     abort();
   sprintf(str, "%vhu", vsshort);
   if (strcmp (str, "31 29 31 29 31 29 31 29"))
     abort();
   sprintf(str, "%vhu", vsshort_to_char);
   if (strcmp (str, "31 29 31 29 31 29 31 29"))
     abort();
   sprintf(str, "%vd", vui);
   if (strcmp (str, "1 31 2 29 3 31 4 29 5 31 6 29 7 31 8 29"))
     abort();
   sprintf(str, "%vd", vui1);
   if (strcmp (str, "1 31 2 29 3 31 4 29 5 31 6 29 7 31 8 29"))
     abort();
   sprintf(str, "%vd", vus);
   if (strcmp (str, "1 31 2 29 3 31 4 29 5 31 6 29 7 31 8 29"))
     abort();
   sprintf(str, "%vhu", vf);
   if (strcmp (str, "31 29 31 29 31 29 31 29"))
     abort();
   return 0;
}