annotate gcc/testsuite/gcc.target/powerpc/vec-ternarylogic-5.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 run } */
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
2 /* { dg-require-effective-target powerpc_future_hw } */
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
3 /* { dg-options "-mdejagnu-cpu=future" } */
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
4
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
5 #include <altivec.h>
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
6
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
7 extern void abort (void);
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
8
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
9 #define NumSamples 4
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
10
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
11 void
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
12 doTests00000001 (vector unsigned int a_sources [],
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
13 vector unsigned int b_sources [],
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
14 vector unsigned int c_sources []) {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
15 for (int i = 0; i < NumSamples; i++)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
16 for (int j = 0; j < NumSamples; j++)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
17 for (int k = 0; k < NumSamples; k++)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
18 {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
19 vector unsigned int a = a_sources [i];
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
20 vector unsigned int b = b_sources [j];
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
21 vector unsigned int c = c_sources [k];
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
22 vector unsigned int result = vec_ternarylogic (a, b, c, 0x01);
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
23 vector unsigned int intended = (a & b & c);
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
24 if (!vec_all_eq (result, intended))
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
25 abort ();
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
26 }
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
27 }
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
28
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
29 void doTests11100101 (vector unsigned int a_sources [],
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
30 vector unsigned int b_sources [],
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
31 vector unsigned int c_sources []) {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
32 for (int i = 0; i < NumSamples; i++)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
33 for (int j = 0; j < NumSamples; j++)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
34 for (int k = 0; k < NumSamples; k++)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
35 {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
36 vector unsigned int a = a_sources [i];
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
37 vector unsigned int b = b_sources [j];
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
38 vector unsigned int c = c_sources [k];
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
39 vector unsigned int result = vec_ternarylogic (a, b, c, 0xe5);
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
40 vector unsigned int intended = { 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 < 4; l++)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
43 {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
44 for (int m = 0; m < 32; m++)
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
45 {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
46 unsigned 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 int a_sources [],
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
59 vector unsigned int b_sources [],
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
60 vector unsigned 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 int a = a_sources [i];
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
66 vector unsigned int b = b_sources [j];
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
67 vector unsigned int c = c_sources [k];
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
68 vector unsigned int result = vec_ternarylogic (a, b, c, 0xfb);
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
69 vector unsigned int intended = { 0, 0, 0, 0 };
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
70 for (int i = 0; i < 4; 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, int *argv [])
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
78 {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
79 vector unsigned int a_sources [NumSamples] = {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
80 { 0x01234567, 0x89abcdef, 0x12345678, 0x9abcdef0 },
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
81 { 0x55555555, 0x55555555, 0xffffffff, 0xffffffff },
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
82 { 0xcccccccc, 0x55555555, 0x00000000, 0x00000000 },
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
83 { 0xe7e7e7e7, 0xe7e7e7e7, 0x69696969, 0x69696969 },
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
84 };
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
85 vector unsigned int b_sources [NumSamples] = {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
86 { 0x01234567, 0x89abcdef, 0x12345678, 0x9abcdef0 },
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
87 { 0x55555555, 0x55555555, 0xffffffff, 0xffffffff },
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
88 { 0xcccccccc, 0x55555555, 0x00000000, 0x00000000 },
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
89 { 0xe7e7e7e7, 0xe7e7e7e7, 0x69696969, 0x69696969 },
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
90 };
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
91 vector unsigned int c_sources [NumSamples] = {
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
92 { 0x01234567, 0x89abcdef, 0x12345678, 0x9abcdef0 },
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
93 { 0x55555555, 0x55555555, 0xffffffff, 0xffffffff },
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
94 { 0xcccccccc, 0x55555555, 0x00000000, 0x00000000 },
2b5abeee2509 update gcc11
anatofuz
parents:
diff changeset
95 { 0xe7e7e7e7, 0xe7e7e7e7, 0x69696969, 0x69696969 },
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 }