annotate gcc/testsuite/gcc.target/powerpc/vec-ternarylogic-2.c @ 19:2b5abeee2509 default tip

update gcc11
author anatofuz
date Mon, 25 May 2020 07:50:57 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
1 /* { dg-do compile } */
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
2 /* { dg-options "-mdejagnu-cpu=future" } */
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
3
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
4 #include <altivec.h>
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
5
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
6 extern void abort (void);
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
7
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
8 #define NumSamples 4
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
9
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
10 void
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
11 doTests00000001 (vector unsigned short int a_sources [],
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
12 vector unsigned short int b_sources [],
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
13 vector unsigned short int c_sources []) {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
14 for (int i = 0; i < NumSamples; i++)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
15 for (int j = 0; j < NumSamples; j++)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
16 for (int k = 0; k < NumSamples; k++)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
17 {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
18 vector unsigned short a = a_sources [i];
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
19 vector unsigned short b = b_sources [j];
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
20 vector unsigned short c = c_sources [k];
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
21 vector unsigned short result = vec_ternarylogic (a, b, c, 0x01);
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
22 vector unsigned short intended = (a & b & c);
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
23 if (!vec_all_eq (result, intended))
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
24 abort ();
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
25 }
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
26 }
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
27
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
28 void doTests11100101 (vector unsigned short int a_sources [],
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
29 vector unsigned short int b_sources [],
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
30 vector unsigned short int c_sources []) {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
31 for (int i = 0; i < NumSamples; i++)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
32 for (int j = 0; j < NumSamples; j++)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
33 for (int k = 0; k < NumSamples; k++)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
34 {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
35 vector unsigned short a = a_sources [i];
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
36 vector unsigned short b = b_sources [j];
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
37 vector unsigned short c = c_sources [k];
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
38 vector unsigned short result = vec_ternarylogic (a, b, c, 0xe5);
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
39 vector unsigned short intended =
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
40 { 0, 0, 0, 0, 0, 0, 0, 0 };
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
41 // Supposed to be a ? c: nand (b,c)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
42 for (int l = 0; l < 8; l++)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
43 {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
44 for (int m = 0; m < 16; m++)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
45 {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
46 unsigned short int bit_selector = (0x01 << m);
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
47 if (a[l] & bit_selector)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
48 intended [l] |= c [l] & bit_selector;
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
49 else if ((b [l] & c [l] & bit_selector) == 0)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
50 intended [l] |= bit_selector;
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
51 }
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
52 }
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
53 if (!vec_all_eq (result, intended))
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
54 abort ();
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
55 }
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
56 }
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
57
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
58 void doTests11110011 (vector unsigned short int a_sources [],
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
59 vector unsigned short int b_sources [],
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
60 vector unsigned short int c_sources []) {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
61 for (int i = 0; i < NumSamples; i++)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
62 for (int j = 0; j < NumSamples; j++)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
63 for (int k = 0; k < NumSamples; k++)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
64 {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
65 vector unsigned short a = a_sources [i];
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
66 vector unsigned short b = b_sources [j];
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
67 vector unsigned short c = c_sources [k];
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
68 vector unsigned short result = vec_ternarylogic (a, b, c, 0xfb);
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
69 vector unsigned short intended = { 0, 0, 0, 0, 0, 0, 0, 0 };
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
70 for (int i = 0; i < 8; i++)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
71 intended [i] = b [i] | ~(a [i] & c [i]);
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
72 if (!vec_all_eq (result, intended))
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
73 abort ();
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
74 }
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
75 }
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
76
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
77 int main (int argc, short *argv [])
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
78 {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
79 vector unsigned short int a_sources [NumSamples] = {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
80 { 0x0123, 0x4567, 0x89ab, 0xcdef, 0x1234, 0x5678, 0x9abc, 0xdef0 },
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
81 { 0x5555, 0x5555, 0x5555, 0x5555, 0xffff, 0xffff, 0xffff, 0xffff },
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
82 { 0xcccc, 0xcccc, 0x5555, 0x5555, 0x0000, 0x0000, 0x0000, 0x0000 },
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
83 { 0xe7e7, 0xe7e7, 0xe7e7, 0xe7e7, 0x6969, 0x6969, 0x6969, 0x6969 },
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
84 };
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
85 vector unsigned short int b_sources [NumSamples] = {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
86 { 0x0123, 0x4567, 0x89ab, 0xcdef, 0x1234, 0x5678, 0x9abc, 0xdef0 },
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
87 { 0x5555, 0x5555, 0x5555, 0x5555, 0xffff, 0xffff, 0xffff, 0xffff },
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
88 { 0xcccc, 0xcccc, 0x5555, 0x5555, 0x0000, 0x0000, 0x0000, 0x0000 },
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
89 { 0xe7e7, 0xe7e7, 0xe7e7, 0xe7e7, 0x6969, 0x6969, 0x6969, 0x6969 },
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
90 };
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
91 vector unsigned short int c_sources [NumSamples] = {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
92 { 0x0123, 0x4567, 0x89ab, 0xcdef, 0x1234, 0x5678, 0x9abc, 0xdef0 },
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
93 { 0x5555, 0x5555, 0x5555, 0x5555, 0xffff, 0xffff, 0xffff, 0xffff },
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
94 { 0xcccc, 0xcccc, 0x5555, 0x5555, 0x0000, 0x0000, 0x0000, 0x0000 },
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
95 { 0xe7e7, 0xe7e7, 0xe7e7, 0xe7e7, 0x6969, 0x6969, 0x6969, 0x6969 },
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
96 };
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
97
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
98 doTests00000001 (a_sources, b_sources, c_sources);
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
99 doTests11100101 (a_sources, b_sources, c_sources);
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
100 doTests11110011 (a_sources, b_sources, c_sources);
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
101
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
102 return 0;
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
103 }
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
104
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
105 /* { dg-final { scan-assembler {\mxxeval\M} } } */