]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/gcc.target/powerpc/vec-splati-runnable.c
[RS6000] dg-do !compile and scan-assembler
[thirdparty/gcc.git] / gcc / testsuite / gcc.target / powerpc / vec-splati-runnable.c
CommitLineData
8d8fef19
AM
1/* { dg-do run { target { power10_hw } } } */
2/* { dg-do link { target { ! power10_hw } } } */
3/* { dg-require-effective-target power10_ok } */
ec69fe4e 4/* { dg-options "-mdejagnu-cpu=power10 -save-temps" } */
7f3b1997
CL
5#include <altivec.h>
6
7#define DEBUG 0
8
5c150630 9#if DEBUG
7f3b1997
CL
10#include <stdio.h>
11#endif
12
13extern void abort (void);
14
15int
16main (int argc, char *argv [])
17{
18 int i;
19 vector int vsrc_a_int;
20 vector int vresult_int;
21 vector int expected_vresult_int;
22 int src_a_int = 13;
23
24 vector unsigned int vsrc_a_uint;
25 vector unsigned int vresult_uint;
26 vector unsigned int expected_vresult_uint;
27 unsigned int src_a_uint = 7;
28
29 vector float vresult_f;
30 vector float expected_vresult_f;
31 vector float vsrc_a_f;
32 float src_a_f = 23.0;
33
34 vector double vsrc_a_d;
35 vector double vresult_d;
36 vector double expected_vresult_d;
37
38 /* Vector splati word */
39 vresult_int = (vector signed int) { 1, 2, 3, 4 };
40 expected_vresult_int = (vector signed int) { -13, -13, -13, -13 };
41
42 vresult_int = vec_splati ( -13 );
43
44 if (!vec_all_eq (vresult_int, expected_vresult_int)) {
45#if DEBUG
46 printf("ERROR, vec_splati (src_a_int)\n");
47 for(i = 0; i < 4; i++)
48 printf(" vresult_int[%d] = %d, expected_vresult_int[%d] = %d\n",
49 i, vresult_int[i], i, expected_vresult_int[i]);
50#else
51 abort();
52#endif
53 }
54
55 vresult_f = (vector float) { 1.0, 2.0, 3.0, 4.0 };
56 expected_vresult_f = (vector float) { 23.0, 23.0, 23.0, 23.0 };
57
58 vresult_f = vec_splati (23.0f);
59
60 if (!vec_all_eq (vresult_f, expected_vresult_f)) {
61#if DEBUG
62 printf("ERROR, vec_splati (src_a_f)\n");
63 for(i = 0; i < 4; i++)
64 printf(" vresult_f[%d] = %f, expected_vresult_f[%d] = %f\n",
65 i, vresult_f[i], i, expected_vresult_f[i]);
66#else
67 abort();
68#endif
69 }
70
71 /* Vector splati double */
72 vresult_d = (vector double) { 2.0, 3.0 };
73 expected_vresult_d = (vector double) { -31.0, -31.0 };
74
75 vresult_d = vec_splatid (-31.0f);
76
77 if (!vec_all_eq (vresult_d, expected_vresult_d)) {
78#if DEBUG
79 printf("ERROR, vec_splati (-31.0f)\n");
80 for(i = 0; i < 2; i++)
81 printf(" vresult_d[%i] = %f, expected_vresult_d[%i] = %f\n",
82 i, vresult_d[i], i, expected_vresult_d[i]);
83#else
84 abort();
85#endif
86 }
87
88 /* This test will generate a "note" to the user that the argument
89 is subnormal. It is not an error, but results are not defined. */
90 vresult_d = (vector double) { 2.0, 3.0 };
91 expected_vresult_d = (vector double) { 6.6E-42f, 6.6E-42f };
92
93 vresult_d = vec_splatid (6.6E-42f);
94
95 /* Although the instruction says the results are not defined, it does seem
96 to work, at least on Mambo. But no guarentees! */
97 if (!vec_all_eq (vresult_d, expected_vresult_d)) {
98#if DEBUG
99 printf("ERROR, vec_splati (6.6E-42f)\n");
100 for(i = 0; i < 2; i++)
101 printf(" vresult_d[%i] = %e, expected_vresult_d[%i] = %e\n",
102 i, vresult_d[i], i, expected_vresult_d[i]);
103#else
5c150630 104 ;
7f3b1997
CL
105#endif
106 }
107
108 /* Vector splat immediate */
109 vsrc_a_int = (vector int) { 2, 3, 4, 5 };
110 vresult_int = (vector int) { 1, 1, 1, 1 };
111 expected_vresult_int = (vector int) { 2, 20, 4, 20 };
112
113 vresult_int = vec_splati_ins (vsrc_a_int, 1, 20);
114
115 if (!vec_all_eq (vresult_int, expected_vresult_int)) {
116#if DEBUG
117 printf("ERROR, vec_splati_ins (vsrc_a_int, 1, 20)\n");
118 for(i = 0; i < 4; i++)
119 printf(" vresult_int[%i] = %d, expected_vresult_int[%i] = %d\n",
120 i, vresult_int[i], i, expected_vresult_int[i]);
121#else
122 abort();
123#endif
124 }
125
126 vsrc_a_uint = (vector unsigned int) { 4, 5, 6, 7 };
127 vresult_uint = (vector unsigned int) { 1, 1, 1, 1 };
128 expected_vresult_uint = (vector unsigned int) { 4, 40, 6, 40 };
129
130 vresult_uint = vec_splati_ins (vsrc_a_uint, 1, 40);
131
132 if (!vec_all_eq (vresult_uint, expected_vresult_uint)) {
133#if DEBUG
134 printf("ERROR, vec_splati_ins (vsrc_a_uint, 1, 40)\n");
135 for(i = 0; i < 4; i++)
136 printf(" vresult_uint[%i] = %d, expected_vresult_uint[%i] = %d\n",
137 i, vresult_uint[i], i, expected_vresult_uint[i]);
138#else
139 abort();
140#endif
141 }
142
143 vsrc_a_f = (vector float) { 2.0, 3.0, 4.0, 5.0 };
144 vresult_f = (vector float) { 1.0, 1.0, 1.0, 1.0 };
145 expected_vresult_f = (vector float) { 2.0, 20.1, 4.0, 20.1 };
146
147 vresult_f = vec_splati_ins (vsrc_a_f, 1, 20.1f);
148
149 if (!vec_all_eq (vresult_f, expected_vresult_f)) {
150#if DEBUG
151 printf("ERROR, vec_splati_ins (vsrc_a_f, 1, 20.1)\n");
152 for(i = 0; i < 4; i++)
153 printf(" vresult_f[%i] = %f, expected_vresult_f[%i] = %f\n",
154 i, vresult_f[i], i, expected_vresult_f[i]);
155#else
156 abort();
157#endif
158 }
159
160 return 0;
161}
162
163/* { dg-final { scan-assembler-times {\mxxspltiw\M} 2 } } */
164/* { dg-final { scan-assembler-times {\mxxspltidp\M} 2 } } */
165/* { dg-final { scan-assembler-times {\mxxsplti32dx\M} 3 } } */
166
167