[RISC-V] Avoid unnecessary extensions when value is already extended
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / slp-20.c
blobea19095f9fa06db508cfedda68ca2c65769b35b0
1 /* { dg-require-effective-target vect_int } */
3 #include <stdarg.h>
4 #include "tree-vect.h"
6 #define N 128
8 int
9 main1 (unsigned short a0, unsigned short a1, unsigned short a2,
10 unsigned short a3, unsigned short a4, unsigned short a5,
11 unsigned short a6, unsigned short a7, unsigned short a8)
13 int i;
14 unsigned short out[N*8], out2[N*8], b0, b1, b2, b3, b4, b5, b6, b7, b8;
16 for (i = 0; i < N; i++)
18 b0 = a0 + 8;
19 b1 = a1 + 7;
20 b2 = a2 + 6;
21 b3 = a3 + 5;
22 b4 = a4 + 4;
23 b5 = a5 + 3;
25 out[i*4] = b0;
26 out[i*4 + 1] = b1;
27 out[i*4 + 2] = b2;
28 out[i*4 + 3] = b3;
30 out2[i*4] = b0;
31 out2[i*4 + 1] = b1;
32 out2[i*4 + 2] = b4;
33 out2[i*4 + 3] = b5;
36 /* check results: */
37 #pragma GCC novector
38 for (i = 0; i < N; i++)
40 if (out[i*4] != b0
41 || out[i*4 + 1] != b1
42 || out[i*4 + 2] != b2
43 || out[i*4 + 3] != b3)
44 abort ();
46 if (out2[i*4] != b0
47 || out2[i*4 + 1] != b1
48 || out2[i*4 + 2] != b4
49 || out2[i*4 + 3] != b5)
50 abort ();
53 for (i = 0; i < N; i++)
55 b0 = a0 + 8;
56 b1 = a1 + 7;
57 b2 = a2 + 6;
58 b3 = a3 + 5;
59 b4 = a4 + 4;
60 b5 = a5 + 3;
61 b6 = a6 + 2;
62 b7 = a7 + 1;
63 b8 = a8 + 9;
65 out[i*4] = b0;
66 out[i*4 + 1] = b1;
67 out[i*4 + 2] = b2;
68 out[i*4 + 3] = b3;
70 out2[i*8] = b0;
71 out2[i*8 + 1] = b1;
72 out2[i*8 + 2] = b4;
73 out2[i*8 + 3] = b5;
74 out2[i*8 + 4] = b6;
75 out2[i*8 + 5] = b2;
76 out2[i*8 + 6] = b7;
77 out2[i*8 + 7] = b8;
80 /* check results: */
81 #pragma GCC novector
82 for (i = 0; i < N; i++)
84 if (out[i*4] != b0
85 || out[i*4 + 1] != b1
86 || out[i*4 + 2] != b2
87 || out[i*4 + 3] != b3)
88 abort ();
90 if (out2[i*8] != b0
91 || out2[i*8 + 1] != b1
92 || out2[i*8 + 2] != b4
93 || out2[i*8 + 3] != b5
94 || out2[i*8 + 4] != b6
95 || out2[i*8 + 5] != b2
96 || out2[i*8 + 6] != b7
97 || out2[i*8 + 7] != b8)
98 abort ();
102 return 0;
105 int main (void)
107 check_vect ();
109 main1 (8,7,6,5,4,3,2,1,0);
111 return 0;
114 /* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */
115 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 4 "vect" } } */