summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/riscv/rvv/base/scalar_move-7.c
blob: b218f2d0ba4a3d1254c97c1a8566590c80fe1204 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/* { dg-do compile } */
/* { dg-options "-march=rv64gcv -mabi=lp64d -fno-schedule-insns -fno-schedule-insns2 -O3" } */
/* { dg-final { check-function-bodies "**" "" } } */

#include "riscv_vector.h"

/*
** foo:
** addi\t[a-x0-9]+,\s*[a-x0-9]+,100
** vsetvli\tzero,a2,e64,m2,t[au],m[au]
** vlse64.v\tv[0-9]+,0\([a-x0-9]+\),zero
** vs2r.v\tv[0-9]+,0\([a-x0-9]+\)
** ret
*/
void foo (void *base, void *out, size_t vl)
{
    int64_t scalar = *(int64_t*)(base + 100);
    vint64m2_t v = __riscv_vmv_v_x_i64m2 (scalar, vl);
    *(vint64m2_t*)out = v;
}

/*
** foo2:
** addi\t[a-x0-9]+,\s*[a-x0-9]+,100
** vsetvli\tzero,a2,e64,m2,t[au],m[au]
** vlse64.v\tv[0-9]+,0\([a-x0-9]+\),zero
** vs2r.v\tv[0-9]+,0\([a-x0-9]+\)
** ret
*/
void foo2 (void *base, void *out, size_t vl)
{
    double scalar = *(double*)(base + 100);
    vfloat64m2_t v = __riscv_vfmv_v_f_f64m2 (scalar, vl);
    *(vfloat64m2_t*)out = v;
}

/*
** foo3:
** ...
** vlse64.v\tv[0-9]+,0\([a-x0-9]+\),zero
** ...
** ret
*/
void foo3 (void *base, void *out, size_t vl)
{
    int64_t scalar = *(int64_t*)(base + 100);
    vint64m2_t merge = *(vint64m2_t*) (base + 200);
    vint64m2_t v = __riscv_vmv_v_x_i64m2_tu (merge, scalar, vl);
    *(vint64m2_t*)out = v;
}

/*
** foo4:
** ...
** vlse64.v\tv[0-9]+,0\([a-x0-9]+\),zero
** ...
** ret
*/
void foo4 (void *base, void *out, size_t vl)
{
    double scalar = *(double*)(base + 100);
    vfloat64m2_t merge = *(vfloat64m2_t*) (base + 200);
    vfloat64m2_t v = __riscv_vfmv_v_f_f64m2_tu (merge, scalar, vl);
    *(vfloat64m2_t*)out = v;
}

/*
** foo5:
** ...
** vmv.v.x\tv[0-9]+,\s*[a-x0-9]+
** ...
** ret
*/
void foo5 (void *base, void *out, size_t vl, int64_t x)
{
    vint64m2_t v = __riscv_vmv_v_x_i64m2 (x, vl);
    *(vint64m2_t*)out = v;
}

/*
** foo6:
** ...
** vfmv.v.f\tv[0-9]+,\s*[a-x0-9]+
** ...
** ret
*/
void foo6 (void *base, void *out, size_t vl, double x)
{
    vfloat64m2_t v = __riscv_vfmv_v_f_f64m2 (x, vl);
    *(vfloat64m2_t*)out = v;
}

/*
** foo7:
** ...
** vmv.v.x\tv[0-9]+,\s*[a-x0-9]+
** ...
** ret
*/
void foo7 (void *base, void *out, size_t vl, int64_t x)
{
    vint64m2_t merge = *(vint64m2_t*) (base + 200);
    vint64m2_t v = __riscv_vmv_v_x_i64m2_tu (merge, x, vl);
    *(vint64m2_t*)out = v;
}

/*
** foo8:
** ...
** vfmv.v.f\tv[0-9]+,\s*[a-x0-9]+
** ...
** ret
*/
void foo8 (void *base, void *out, size_t vl, double x)
{
    vfloat64m2_t merge = *(vfloat64m2_t*) (base + 200);
    vfloat64m2_t v = __riscv_vfmv_v_f_f64m2_tu (merge, x, vl);
    *(vfloat64m2_t*)out = v;
}

/*
** foo9:
** ...
** vmv.v.i\tv[0-9]+,\s*-15
** ...
** ret
*/
void foo9 (void *base, void *out, size_t vl)
{
    int64_t scalar = *(int64_t*)(base + 100);
    vint64m2_t v = __riscv_vmv_v_x_i64m2 (-15, vl);
    *(vint64m2_t*)out = v;
}

/*
** foo10:
** ...
** vmv.v.i\tv[0-9]+,\s*-15
** ...
** ret
*/
void foo10 (void *base, void *out, size_t vl)
{
    int64_t scalar = *(int64_t*)(base + 100);
    vint64m2_t merge = *(vint64m2_t*) (base + 200);
    vint64m2_t v = __riscv_vmv_v_x_i64m2_tu (merge, -15, vl);
    *(vint64m2_t*)out = v;
}

/*
** foo11:
** ...
** vmv.v.i\tv[0-9]+,\s*0
** ...
** ret
*/
void foo11 (void *base, void *out, size_t vl)
{
    double scalar = *(double*)(base + 100);
    vfloat64m2_t v = __riscv_vfmv_v_f_f64m2 (0, vl);
    *(vfloat64m2_t*)out = v;
}

/*
** foo12:
** ...
** vmv.v.i\tv[0-9]+,\s*0
** ...
** ret
*/
void foo12 (void *base, void *out, size_t vl)
{
    vfloat64m2_t merge = *(vfloat64m2_t*) (base + 200);
    vfloat64m2_t v = __riscv_vfmv_v_f_f64m2_tu (merge, 0, vl);
    *(vfloat64m2_t*)out = v;
}