Debian Codegraph @

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

raw
1 /* { dg-do compile } */
2 /* { dg-options "-mlsx -O3" } */
3
4 #include <lsxintrin.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 /* No change for V2DI mode. */
14 v2i64
15 vec_construct_v2i64 ()
16 {
17 v2i64 res =
18 { x_di[1], x_di[0]}
19 ;
20 return res;
21 }
22
23 /* Only load the lowest 2 elements and directly copy them to high half-part,
24 reducing more vinsgr2vr.w. */
25 /* { dg-final { scan-assembler-times "v4i32:.*\tvreplvei\\.d.*v4i32" 1 } } */
26 v4i32
27 vec_construct_v4i32 ()
28 {
29 v4i32 res =
30 { x_si[0], x_si[1], x_si[0], x_si[1]}
31 ;
32 return res;
33 }
34
35 /* Only load the lowest 4 elements and directly copy them to high half-part,
36 reducing more vinsgr2vr.h. */
37 /* { dg-final { scan-assembler-times "v8i16:.*\tvreplvei\\.d.*v8i16" 1 } } */
38 v8i16
39 vec_construct_v8i16 ()
40 {
41 v8i16 res =
42 { x_hi[0], x_hi[0], x_hi[0], x_hi[1],
43 x_hi[0], x_hi[0], x_hi[0], x_hi[1] }
44 ;
45 return res;
46 }
47
48 /* Only load the lowest 8 elements and directly copy them to high half-part,
49 reducing more vinsgr2vr.b. */
50 /* { dg-final { scan-assembler-times "v16i8:.*\tvreplvei\\.d.*v16i8" 1 } } */
51 v16i8
52 vec_construct_v16i8 ()
53 {
54 v16i8 res =
55 { x_qi[0], x_qi[1], x_qi[0], x_qi[2],
56 x_qi[0], x_qi[0], x_qi[0], x_qi[3],
57 x_qi[0], x_qi[1], x_qi[0], x_qi[2],
58 x_qi[0], x_qi[0], x_qi[0], x_qi[3] }
59 ;
60 return res;
61 }
62
63 /* Set 2 elements of a vector simultaneously by vilvl.d. */
64 /* { dg-final { scan-assembler-not "v2f64:.*\tvextrins\\.d.*v2f64" } } */
65 /* { dg-final { scan-assembler-times "v2f64:.*\tvilvl\\.d.*v2f64" 1 } } */
66 v2f64
67 vec_construct_v2f64 ()
68 {
69 v2f64 res =
70 { y_df[0], y_df[2] }
71 ;
72 return res;
73 }
74
75 /* Set 2 elements of a vector simultaneously by vilvl.w
76 and reducing more vextrins.w. */
77 /* { dg-final { scan-assembler-times "v4f32:.*\tvilvl\\.w.*v4f32" 1 } } */
78 v4f32
79 vec_construct_v4f32 ()
80 {
81 v4f32 res =
82 { y_sf[0], y_sf[1], y_sf[0], y_sf[0] }
83 ;
84 return res;
85 }