comparison 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
comparison
equal deleted inserted replaced
18:1830386684a0 19:2b5abeee2509
1 /* { dg-do run } */
2 /* { dg-require-effective-target powerpc_future_hw } */
3 /* { dg-options "-mdejagnu-cpu=future" } */
4
5 #include <altivec.h>
6
7 extern void abort (void);
8
9 #define NumSamples 4
10
11 void
12 doTests00000001 (vector unsigned int a_sources [],
13 vector unsigned int b_sources [],
14 vector unsigned int c_sources []) {
15 for (int i = 0; i < NumSamples; i++)
16 for (int j = 0; j < NumSamples; j++)
17 for (int k = 0; k < NumSamples; k++)
18 {
19 vector unsigned int a = a_sources [i];
20 vector unsigned int b = b_sources [j];
21 vector unsigned int c = c_sources [k];
22 vector unsigned int result = vec_ternarylogic (a, b, c, 0x01);
23 vector unsigned int intended = (a & b & c);
24 if (!vec_all_eq (result, intended))
25 abort ();
26 }
27 }
28
29 void doTests11100101 (vector unsigned int a_sources [],
30 vector unsigned int b_sources [],
31 vector unsigned int 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 int a = a_sources [i];
37 vector unsigned int b = b_sources [j];
38 vector unsigned int c = c_sources [k];
39 vector unsigned int result = vec_ternarylogic (a, b, c, 0xe5);
40 vector unsigned int intended = { 0, 0, 0, 0 };
41 // Supposed to be a ? c: nand (b,c)
42 for (int l = 0; l < 4; l++)
43 {
44 for (int m = 0; m < 32; m++)
45 {
46 unsigned int bit_selector = (0x01 << m);
47 if (a[l] & bit_selector)
48 intended [l] |= c [l] & bit_selector;
49 else if ((b [l] & c [l] & bit_selector) == 0)
50 intended [l] |= bit_selector;
51 }
52 }
53 if (!vec_all_eq (result, intended))
54 abort ();
55 }
56 }
57
58 void doTests11110011 (vector unsigned int a_sources [],
59 vector unsigned int b_sources [],
60 vector unsigned int c_sources []) {
61 for (int i = 0; i < NumSamples; i++)
62 for (int j = 0; j < NumSamples; j++)
63 for (int k = 0; k < NumSamples; k++)
64 {
65 vector unsigned int a = a_sources [i];
66 vector unsigned int b = b_sources [j];
67 vector unsigned int c = c_sources [k];
68 vector unsigned int result = vec_ternarylogic (a, b, c, 0xfb);
69 vector unsigned int intended = { 0, 0, 0, 0 };
70 for (int i = 0; i < 4; i++)
71 intended [i] = b [i] | ~(a [i] & c [i]);
72 if (!vec_all_eq (result, intended))
73 abort ();
74 }
75 }
76
77 int main (int argc, int *argv [])
78 {
79 vector unsigned int a_sources [NumSamples] = {
80 { 0x01234567, 0x89abcdef, 0x12345678, 0x9abcdef0 },
81 { 0x55555555, 0x55555555, 0xffffffff, 0xffffffff },
82 { 0xcccccccc, 0x55555555, 0x00000000, 0x00000000 },
83 { 0xe7e7e7e7, 0xe7e7e7e7, 0x69696969, 0x69696969 },
84 };
85 vector unsigned int b_sources [NumSamples] = {
86 { 0x01234567, 0x89abcdef, 0x12345678, 0x9abcdef0 },
87 { 0x55555555, 0x55555555, 0xffffffff, 0xffffffff },
88 { 0xcccccccc, 0x55555555, 0x00000000, 0x00000000 },
89 { 0xe7e7e7e7, 0xe7e7e7e7, 0x69696969, 0x69696969 },
90 };
91 vector unsigned int c_sources [NumSamples] = {
92 { 0x01234567, 0x89abcdef, 0x12345678, 0x9abcdef0 },
93 { 0x55555555, 0x55555555, 0xffffffff, 0xffffffff },
94 { 0xcccccccc, 0x55555555, 0x00000000, 0x00000000 },
95 { 0xe7e7e7e7, 0xe7e7e7e7, 0x69696969, 0x69696969 },
96 };
97
98 doTests00000001 (a_sources, b_sources, c_sources);
99 doTests11100101 (a_sources, b_sources, c_sources);
100 doTests11110011 (a_sources, b_sources, c_sources);
101
102 return 0;
103 }