Debian Codegraph @

gcc/testsuite/gcc.target/loongarch/vector/lasx/lasx-vec-construct-opt.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-mlasx -O3" } */
3
4 #include <lasxintrin.h>
5
6 extern long long *x_di;
7 extern int *x_si;
8 extern short int *x_hi;
9 extern char *x_qi;
10 extern double *y_df;
11 extern float *y_sf;
12
13 /* Remove some unnecessary vinsgr2vr.d as the corresponding elements
14 have already been set. */
15 /* { dg-final { scan-assembler-not "v4i64:.*\tvinsgr2vr\\.d.*v4i64" } } */
16 /* { dg-final { scan-assembler-times "v4i64:.*\txvldrepl\\.d.*v4i64" 1 } } */
17 v4i64
18 vec_construct_v4i64 ()
19 {
20 v4i64 res =
21 { x_di[0], x_di[0], x_di[1], x_di[1] }
22 ;
23 return res;
24 }
25
26 /* Remove some unnecessary vinsgr2vr.w as the corresponding elements
27 have already been set. */
28 /* { dg-final { scan-assembler-not "v8i32:.*\tvinsgr2vr\\.w.*v8i32" } } */
29 /* { dg-final { scan-assembler-times "v8i32:.*\txvreplgr2vr\\.w.*v8i32" 1 } } */
30 v8i32
31 vec_construct_v8i32 ()
32 {
33 v8i32 res =
34 { x_si[0], x_si[0], x_si[0], x_si[0],
35 x_si[0], x_si[2], x_si[0], x_si[0] }
36 ;
37 return res;
38 }
39
40 /* Remove some unnecessary vinsgr2vr.h as the corresponding elements
41 have already been set. */
42 /* { dg-final { scan-assembler-not "v16i16:.*\tvori\\.b.*v16i16" } } */
43 /* { dg-final { scan-assembler-times "v16i16:.*\txvreplgr2vr\\.h.*v16i1" 1 } } */
44 v16i16
45 vec_construct_v16i16 ()
46 {
47 v16i16 res =
48 { x_hi[1], x_hi[2], x_hi[1], x_hi[1],
49 x_hi[1], x_hi[1], x_hi[1], x_hi[1],
50 x_hi[1], x_hi[1], x_hi[1], x_hi[1],
51 x_hi[1], x_hi[1], x_hi[1], x_hi[2] }
52 ;
53 return res;
54 }
55
56 /* Remove some unnecessary vinsgr2vr.b as the corresponding elements
57 have already been set. */
58 /* { dg-final { scan-assembler-not "v32i8:.*\tvori\\.b.*v32i8" } } */
59 /* { dg-final { scan-assembler-times "v32i8:.*\txvreplgr2vr\\.b.*v32i8" 1 } } */
60 v32i8
61 vec_construct_v32i8 ()
62 {
63 v32i8 res =
64 { x_qi[0], x_qi[0], x_qi[0], x_qi[0],
65 x_qi[0], x_qi[0], x_qi[0], x_qi[0],
66 x_qi[0], x_qi[0], x_qi[0], x_qi[0],
67 x_qi[0], x_qi[0], x_qi[0], x_qi[2],
68 x_qi[0], x_qi[0], x_qi[0], x_qi[0],
69 x_qi[0], x_qi[0], x_qi[0], x_qi[0],
70 x_qi[0], x_qi[0], x_qi[0], x_qi[0],
71 x_qi[0], x_qi[0], x_qi[0], x_qi[3] }
72 ;
73 return res;
74 }
75
76 /* Set 2 elements of a vector simultaneously by vilvl.d
77 and reducing more vextrins.d. */
78 /* { dg-final { scan-assembler-not "v4f64:.*\tvori\\.b.*v4f64" } } */
79 /* { dg-final { scan-assembler-not "v4f64:.*\tvextrins\\.d.*v4f64" } } */
80 /* { dg-final { scan-assembler-times "v4f64:.*\tvilvl\\.d.*v4f64" 1 } } */
81 v4f64
82 vec_construct_v4f64 ()
83 {
84 v4f64 res =
85 { y_df[0], y_df[2], y_df[0], y_df[0]}
86 ;
87 return res;
88 }
89
90 /* Set 2 elements of a vector simultaneously by vilvl.w
91 and reducing more vextrins.w. */
92 /* { dg-final { scan-assembler-not "v8f32:.*\tvextrins\\.w.*v8f32" } } */
93 /* { dg-final { scan-assembler-times "v8f32:.*\txvilvl\\.w.*v8f32" 1 } } */
94 v8f32
95 vec_construct_v8f32 ()
96 {
97 v8f32 res =
98 { y_sf[2], y_sf[1], y_sf[2], y_sf[3],
99 y_sf[2], y_sf[1], y_sf[2], y_sf[3] }
100 ;
101 return res;
102 }