152
|
1 /* { dg-do compile } */
|
|
2 /* { dg-options "-mdejagnu-cpu=future" } */
|
|
3
|
|
4 #include <altivec.h>
|
|
5
|
|
6 extern void abort (void);
|
|
7
|
|
8 #define NumSamples 4
|
|
9
|
|
10 void
|
|
11 doTests00000001 (vector unsigned char a_sources [],
|
|
12 vector unsigned char b_sources [],
|
|
13 vector unsigned char c_sources []) {
|
|
14 for (int i = 0; i < NumSamples; i++)
|
|
15 for (int j = 0; j < NumSamples; j++)
|
|
16 for (int k = 0; k < NumSamples; k++)
|
|
17 {
|
|
18 vector unsigned char a = a_sources [i];
|
|
19 vector unsigned char b = b_sources [j];
|
|
20 vector unsigned char c = c_sources [k];
|
|
21 vector unsigned char result = vec_ternarylogic (a, b, c, 0x01);
|
|
22 vector unsigned char intended = (a & b & c);
|
|
23 if (!vec_all_eq (result, intended))
|
|
24 abort ();
|
|
25 }
|
|
26 }
|
|
27
|
|
28 void
|
|
29 doTests11100101 (vector unsigned char a_sources [],
|
|
30 vector unsigned char b_sources [],
|
|
31 vector unsigned char c_sources []) {
|
|
32 for (int i = 0; i < NumSamples; i++)
|
|
33 for (int j = 0; j < NumSamples; j++)
|
|
34 for (int k = 0; k < NumSamples; k++)
|
|
35 {
|
|
36 vector unsigned char a = a_sources [i];
|
|
37 vector unsigned char b = b_sources [j];
|
|
38 vector unsigned char c = c_sources [k];
|
|
39 vector unsigned char result = vec_ternarylogic (a, b, c, 0xe5);
|
|
40 vector unsigned char intended =
|
|
41 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
|
42 // Supposed to be a ? c: nand (b,c)
|
|
43 for (int l = 0; l < 16; l++)
|
|
44 {
|
|
45 for (int m = 0; m < 8; m++)
|
|
46 {
|
|
47 unsigned char bit_selector = (0x01 << m);
|
|
48 if (a[l] & bit_selector)
|
|
49 intended [l] |= c [l] & bit_selector;
|
|
50 else if ((b [l] & c [l] & bit_selector) == 0)
|
|
51 intended [l] |= bit_selector;
|
|
52 }
|
|
53 }
|
|
54 if (!vec_all_eq (result, intended))
|
|
55 abort ();
|
|
56 }
|
|
57 }
|
|
58
|
|
59 void
|
|
60 doTests11110011 (vector unsigned char a_sources [],
|
|
61 vector unsigned char b_sources [],
|
|
62 vector unsigned char c_sources []) {
|
|
63 for (int i = 0; i < NumSamples; i++)
|
|
64 for (int j = 0; j < NumSamples; j++)
|
|
65 for (int k = 0; k < NumSamples; k++)
|
|
66 {
|
|
67 vector unsigned char a = a_sources [i];
|
|
68 vector unsigned char b = b_sources [j];
|
|
69 vector unsigned char c = c_sources [k];
|
|
70 vector unsigned char result = vec_ternarylogic (a, b, c, 0xfb);
|
|
71 vector unsigned char intended = {
|
|
72 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
|
73 for (int i = 0; i < 16; i++)
|
|
74 intended [i] = b [i] | ~(a [i] & c [i]);
|
|
75 if (!vec_all_eq (result, intended))
|
|
76 abort ();
|
|
77 }
|
|
78 }
|
|
79
|
|
80 int main (int argc, char *argv [])
|
|
81 {
|
|
82 vector unsigned char a_sources [NumSamples] = {
|
|
83 { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
|
|
84 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0 },
|
|
85 { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
|
|
86 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
|
|
87 { 0xcc, 0xcc, 0xcc, 0xcc, 0x55, 0x55, 0x55, 0x55,
|
|
88 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
|
89 { 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7,
|
|
90 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, 0x69 },
|
|
91 };
|
|
92 vector unsigned char b_sources [NumSamples] = {
|
|
93 { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
|
|
94 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0 },
|
|
95 { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
|
|
96 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
|
|
97 { 0xcc, 0xcc, 0xcc, 0xcc, 0x55, 0x55, 0x55, 0x55,
|
|
98 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
|
99 { 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7,
|
|
100 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, 0x69 },
|
|
101 };
|
|
102 vector unsigned char c_sources [NumSamples] = {
|
|
103 { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
|
|
104 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0 },
|
|
105 { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
|
|
106 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
|
|
107 { 0xcc, 0xcc, 0xcc, 0xcc, 0x55, 0x55, 0x55, 0x55,
|
|
108 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
|
109 { 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7,
|
|
110 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, 0x69 },
|
|
111 };
|
|
112
|
|
113 doTests00000001 (a_sources, b_sources, c_sources);
|
|
114 doTests11100101 (a_sources, b_sources, c_sources);
|
|
115 doTests11110011 (a_sources, b_sources, c_sources);
|
|
116
|
|
117 return 0;
|
|
118 }
|
|
119
|
|
120 /* { dg-final { scan-assembler {\mxxeval\M} } } */
|