1 /* { dg-do compile } */
2 /* { dg-options "-mdejagnu-cpu=power10" } */
6 extern void abort (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
++)
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
))
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
++)
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
++)
44 for (int m
= 0; m
< 16; m
++)
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
;
53 if (!vec_all_eq (result
, intended
))
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
++)
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
))
77 int main (int argc
, short *argv
[])
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 },
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 },
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 },
98 doTests00000001 (a_sources
, b_sources
, c_sources
);
99 doTests11100101 (a_sources
, b_sources
, c_sources
);
100 doTests11110011 (a_sources
, b_sources
, c_sources
);
105 /* { dg-final { scan-assembler {\mxxeval\M} } } */