2018-02-09 Sebastian Perta <sebastian.perta@renesas.com>
[official-gcc.git] / gcc / testsuite / gcc.target / sh / pr50751-8.c
blob07bbee4fe8f64110fc5fcd90d600480c8a2c4c5c
1 /* Check that on SH2A the 4 byte movu.b and movu.w displacement insns are
2 generated. This has to be checked with -O2 because some of the patterns
3 rely on peepholes. */
4 /* { dg-do compile { target { sh2a } } } */
5 /* { dg-options "-O2" } */
6 /* { dg-final { scan-assembler-times "movu.b" 4 } } */
7 /* { dg-final { scan-assembler-times "movu.w" 3 } } */
9 int
10 test_00 (unsigned char* x)
12 /* 1x movu.b */
13 return x[0];
16 int
17 test_01 (unsigned short* x)
19 /* 1x movu.w */
20 return x[0];
23 int
24 test_02 (unsigned char* x)
26 /* 1x movu.b */
27 return x[1];
30 int
31 test_03 (unsigned char* x)
33 /* 1x movu.b */
34 return x[32];
37 int
38 test_04 (unsigned char* x)
40 /* 1x movu.b */
41 return x[9000];
44 int
45 test_05 (unsigned short* x)
47 /* 1x movu.w */
48 return x[9000];
51 int
52 test_06 (unsigned char* x, int i)
54 /* No movu.b expected here. Should use mov.b (r0,r4) + extu.b instead. */
55 return x[i];
58 int
59 test_07 (unsigned short* x, int i)
61 /* No movu.w expected here. Should use mov.w (r0,r4) + extu.w instead. */
62 return x[i];
65 int
66 test_08 (unsigned char* x, int c)
68 /* No movu.b expected here. Should use post-inc addressing instead. */
69 int s = 0;
70 int i;
71 for (i = 0; i < c; ++i)
72 s += x[i];
73 return s;
76 void
77 test_09 (unsigned char* x, unsigned char* y)
79 /* No movu.b expected here, since the zero-extension is irrelevant. */
80 x[1] = y[1];
81 x[2] = y[2];
84 void
85 test_10 (unsigned char* x, unsigned short* y)
87 /* No movu.w expected here, since the zero-extension is irrelevant. */
88 x[1] = y[1];
89 x[2] = y[2];
92 int
93 test_11 (unsigned char* x, unsigned short* y)
95 /* 1x movu.w */
96 int yy = y[1];
97 x[1] = yy;
98 return yy;