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 "sh*-*-*" } } */
5 /* { dg-options "-O2" } */
6 /* { dg-skip-if "" { "sh*-*-*" } { "*" } { "-m2a*" } } */
7 /* { dg-final { scan-assembler-times "movu.b" 4 } } */
8 /* { dg-final { scan-assembler-times "movu.w" 3 } } */
9 
10 int
test_00(unsigned char * x)11 test_00 (unsigned char* x)
12 {
13   /* 1x movu.b  */
14   return x[0];
15 }
16 
17 int
test_01(unsigned short * x)18 test_01 (unsigned short* x)
19 {
20   /* 1x movu.w  */
21   return x[0];
22 }
23 
24 int
test_02(unsigned char * x)25 test_02 (unsigned char* x)
26 {
27   /* 1x movu.b  */
28   return x[1];
29 }
30 
31 int
test_03(unsigned char * x)32 test_03 (unsigned char* x)
33 {
34   /* 1x movu.b  */
35   return x[32];
36 }
37 
38 int
test_04(unsigned char * x)39 test_04 (unsigned char* x)
40 {
41   /* 1x movu.b  */
42   return x[9000];
43 }
44 
45 int
test_05(unsigned short * x)46 test_05 (unsigned short* x)
47 {
48   /* 1x movu.w  */
49   return x[9000];
50 }
51 
52 int
test_06(unsigned char * x,int i)53 test_06 (unsigned char* x, int i)
54 {
55   /* No movu.b expected here.  Should use mov.b (r0,r4) + extu.b instead.  */
56   return x[i];
57 }
58 
59 int
test_07(unsigned short * x,int i)60 test_07 (unsigned short* x, int i)
61 {
62   /* No movu.w expected here.  Should use mov.w (r0,r4) + extu.w instead.  */
63   return x[i];
64 }
65 
66 int
test_08(unsigned char * x,int c)67 test_08 (unsigned char* x, int c)
68 {
69   /* No movu.b expected here.  Should use post-inc addressing instead.  */
70   int s = 0;
71   int i;
72   for (i = 0; i < c; ++i)
73     s += x[i];
74   return s;
75 }
76 
77 void
test_09(unsigned char * x,unsigned char * y)78 test_09 (unsigned char* x, unsigned char* y)
79 {
80   /* No movu.b expected here, since the zero-extension is irrelevant.  */
81   x[1] = y[1];
82   x[2] = y[2];
83 }
84 
85 void
test_10(unsigned char * x,unsigned short * y)86 test_10 (unsigned char* x, unsigned short* y)
87 {
88   /* No movu.w expected here, since the zero-extension is irrelevant.  */
89   x[1] = y[1];
90   x[2] = y[2];
91 }
92 
93 int
test_11(unsigned char * x,unsigned short * y)94 test_11 (unsigned char* x, unsigned short* y)
95 {
96   /* 1x movu.w  */
97   int yy = y[1];
98   x[1] = yy;
99   return yy;
100 }
101