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
|
/* { dg-do assemble } */
/* { dg-options "-O3 -fomit-frame-pointer -funroll-loops -march=r2 -mcdx -w" } */
/* Based on gcc.c-torture/execute/20021120-1.c.
This test used to result in assembler errors with R2 CDX because of
a bug in regrename; it wasn't re-validating insns after renaming, so
ldwm/stwm instructions with incorrect registers were being emitted. */
/* Macros to emit "L Nxx R" for each octal number xx between 000 and 037. */
#define OP1(L, N, R, I, J) L N##I##J R
#define OP2(L, N, R, I) \
OP1(L, N, R, 0, I), OP1(L, N, R, 1, I), \
OP1(L, N, R, 2, I), OP1(L, N, R, 3, I)
#define OP(L, N, R) \
OP2(L, N, R, 0), OP2(L, N, R, 1), OP2(L, N, R, 2), OP2(L, N, R, 3), \
OP2(L, N, R, 4), OP2(L, N, R, 5), OP2(L, N, R, 6), OP2(L, N, R, 7)
/* Declare 32 unique variables with prefix N. */
#define DECLARE(N) OP (, N,)
/* Copy 32 variables with prefix N from the array at ADDR.
Leave ADDR pointing to the end of the array. */
#define COPYIN(N, ADDR) OP (, N, = *(ADDR++))
/* Likewise, but copy the other way. */
#define COPYOUT(N, ADDR) OP (*(ADDR++) =, N,)
/* Add the contents of the array at ADDR to 32 variables with prefix N.
Leave ADDR pointing to the end of the array. */
#define ADD(N, ADDR) OP (, N, += *(ADDR++))
volatile double gd[32];
volatile float gf[32];
void foo (int n)
{
double DECLARE(d);
float DECLARE(f);
volatile double *pd;
volatile float *pf;
int i;
pd = gd; COPYIN (d, pd);
for (i = 0; i < n; i++)
{
pf = gf; COPYIN (f, pf);
pd = gd; ADD (d, pd);
pd = gd; ADD (d, pd);
pd = gd; ADD (d, pd);
pf = gf; COPYOUT (f, pf);
}
pd = gd; COPYOUT (d, pd);
}
int main ()
{
int i;
for (i = 0; i < 32; i++)
gd[i] = i, gf[i] = i;
foo (1);
for (i = 0; i < 32; i++)
if (gd[i] != i * 4 || gf[i] != i)
abort ();
exit (0);
}
|