comparison 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
comparison
equal deleted inserted replaced
18:1830386684a0 19:2b5abeee2509
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 short int a_sources [],
12 vector unsigned short int b_sources [],
13 vector unsigned short int 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 short a = a_sources [i];
19 vector unsigned short b = b_sources [j];
20 vector unsigned short c = c_sources [k];
21 vector unsigned short result = vec_ternarylogic (a, b, c, 0x01);
22 vector unsigned short intended = (a & b & c);
23 if (!vec_all_eq (result, intended))
24 abort ();
25 }
26 }
27
28 void doTests11100101 (vector unsigned short int a_sources [],
29 vector unsigned short int b_sources [],
30 vector unsigned short int c_sources []) {
31 for (int i = 0; i < NumSamples; i++)
32 for (int j = 0; j < NumSamples; j++)
33 for (int k = 0; k < NumSamples; k++)
34 {
35 vector unsigned short a = a_sources [i];
36 vector unsigned short b = b_sources [j];
37 vector unsigned short c = c_sources [k];
38 vector unsigned short result = vec_ternarylogic (a, b, c, 0xe5);
39 vector unsigned short intended =
40 { 0, 0, 0, 0, 0, 0, 0, 0 };
41 // Supposed to be a ? c: nand (b,c)
42 for (int l = 0; l < 8; l++)
43 {
44 for (int m = 0; m < 16; m++)
45 {
46 unsigned short 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 short int a_sources [],
59 vector unsigned short int b_sources [],
60 vector unsigned short 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 short a = a_sources [i];
66 vector unsigned short b = b_sources [j];
67 vector unsigned short c = c_sources [k];
68 vector unsigned short result = vec_ternarylogic (a, b, c, 0xfb);
69 vector unsigned short intended = { 0, 0, 0, 0, 0, 0, 0, 0 };
70 for (int i = 0; i < 8; 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, short *argv [])
78 {
79 vector unsigned short int a_sources [NumSamples] = {
80 { 0x0123, 0x4567, 0x89ab, 0xcdef, 0x1234, 0x5678, 0x9abc, 0xdef0 },
81 { 0x5555, 0x5555, 0x5555, 0x5555, 0xffff, 0xffff, 0xffff, 0xffff },
82 { 0xcccc, 0xcccc, 0x5555, 0x5555, 0x0000, 0x0000, 0x0000, 0x0000 },
83 { 0xe7e7, 0xe7e7, 0xe7e7, 0xe7e7, 0x6969, 0x6969, 0x6969, 0x6969 },
84 };
85 vector unsigned short int b_sources [NumSamples] = {
86 { 0x0123, 0x4567, 0x89ab, 0xcdef, 0x1234, 0x5678, 0x9abc, 0xdef0 },
87 { 0x5555, 0x5555, 0x5555, 0x5555, 0xffff, 0xffff, 0xffff, 0xffff },
88 { 0xcccc, 0xcccc, 0x5555, 0x5555, 0x0000, 0x0000, 0x0000, 0x0000 },
89 { 0xe7e7, 0xe7e7, 0xe7e7, 0xe7e7, 0x6969, 0x6969, 0x6969, 0x6969 },
90 };
91 vector unsigned short int c_sources [NumSamples] = {
92 { 0x0123, 0x4567, 0x89ab, 0xcdef, 0x1234, 0x5678, 0x9abc, 0xdef0 },
93 { 0x5555, 0x5555, 0x5555, 0x5555, 0xffff, 0xffff, 0xffff, 0xffff },
94 { 0xcccc, 0xcccc, 0x5555, 0x5555, 0x0000, 0x0000, 0x0000, 0x0000 },
95 { 0xe7e7, 0xe7e7, 0xe7e7, 0xe7e7, 0x6969, 0x6969, 0x6969, 0x6969 },
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 }
104
105 /* { dg-final { scan-assembler {\mxxeval\M} } } */