[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / vec-ternarylogic-5.c
blob4d4344b58a9ee1a5ba12016f12a679f1a3f8ab91
1 /* { dg-do run { target { power10_hw } } } */
2 /* { dg-do link { target { ! power10_hw } } } */
3 /* { dg-require-effective-target power10_ok } */
4 /* { dg-options "-mdejagnu-cpu=power10" } */
6 #include <altivec.h>
8 extern void abort (void);
10 #define NumSamples 4
12 void
13 doTests00000001 (vector unsigned int a_sources [],
14 vector unsigned int b_sources [],
15 vector unsigned int c_sources []) {
16 for (int i = 0; i < NumSamples; i++)
17 for (int j = 0; j < NumSamples; j++)
18 for (int k = 0; k < NumSamples; k++)
20 vector unsigned int a = a_sources [i];
21 vector unsigned int b = b_sources [j];
22 vector unsigned int c = c_sources [k];
23 vector unsigned int result = vec_ternarylogic (a, b, c, 0x01);
24 vector unsigned int intended = (a & b & c);
25 if (!vec_all_eq (result, intended))
26 abort ();
30 void doTests11100101 (vector unsigned int a_sources [],
31 vector unsigned int b_sources [],
32 vector unsigned int c_sources []) {
33 for (int i = 0; i < NumSamples; i++)
34 for (int j = 0; j < NumSamples; j++)
35 for (int k = 0; k < NumSamples; k++)
37 vector unsigned int a = a_sources [i];
38 vector unsigned int b = b_sources [j];
39 vector unsigned int c = c_sources [k];
40 vector unsigned int result = vec_ternarylogic (a, b, c, 0xe5);
41 vector unsigned int intended = { 0, 0, 0, 0 };
42 // Supposed to be a ? c: nand (b,c)
43 for (int l = 0; l < 4; l++)
45 for (int m = 0; m < 32; m++)
47 unsigned int bit_selector = (0x01 << m);
48 if (a[l] & bit_selector)
49 intended [l] |= c [l] & bit_selector;
50 else if ((b [l] & c [l] & bit_selector) == 0)
51 intended [l] |= bit_selector;
54 if (!vec_all_eq (result, intended))
55 abort ();
59 void doTests11110011 (vector unsigned int a_sources [],
60 vector unsigned int b_sources [],
61 vector unsigned int c_sources []) {
62 for (int i = 0; i < NumSamples; i++)
63 for (int j = 0; j < NumSamples; j++)
64 for (int k = 0; k < NumSamples; k++)
66 vector unsigned int a = a_sources [i];
67 vector unsigned int b = b_sources [j];
68 vector unsigned int c = c_sources [k];
69 vector unsigned int result = vec_ternarylogic (a, b, c, 0xfb);
70 vector unsigned int intended = { 0, 0, 0, 0 };
71 for (int i = 0; i < 4; i++)
72 intended [i] = b [i] | ~(a [i] & c [i]);
73 if (!vec_all_eq (result, intended))
74 abort ();
78 int main (int argc, int *argv [])
80 vector unsigned int a_sources [NumSamples] = {
81 { 0x01234567, 0x89abcdef, 0x12345678, 0x9abcdef0 },
82 { 0x55555555, 0x55555555, 0xffffffff, 0xffffffff },
83 { 0xcccccccc, 0x55555555, 0x00000000, 0x00000000 },
84 { 0xe7e7e7e7, 0xe7e7e7e7, 0x69696969, 0x69696969 },
86 vector unsigned int b_sources [NumSamples] = {
87 { 0x01234567, 0x89abcdef, 0x12345678, 0x9abcdef0 },
88 { 0x55555555, 0x55555555, 0xffffffff, 0xffffffff },
89 { 0xcccccccc, 0x55555555, 0x00000000, 0x00000000 },
90 { 0xe7e7e7e7, 0xe7e7e7e7, 0x69696969, 0x69696969 },
92 vector unsigned int c_sources [NumSamples] = {
93 { 0x01234567, 0x89abcdef, 0x12345678, 0x9abcdef0 },
94 { 0x55555555, 0x55555555, 0xffffffff, 0xffffffff },
95 { 0xcccccccc, 0x55555555, 0x00000000, 0x00000000 },
96 { 0xe7e7e7e7, 0xe7e7e7e7, 0x69696969, 0x69696969 },
99 doTests00000001 (a_sources, b_sources, c_sources);
100 doTests11100101 (a_sources, b_sources, c_sources);
101 doTests11110011 (a_sources, b_sources, c_sources);
103 return 0;