1 /* { dg-do compile } */
2 /* { dg-options "-O2 -march=r2 -mcdx" } */
3 
4 /* Check generation of R2 CDX load/store instructions.  */
5 
ldb(unsigned char * p)6 unsigned char ldb (unsigned char *p)
7 {
8   return p[7];
9 }
10 
ldh(unsigned short * p)11 unsigned short ldh (unsigned short *p)
12 {
13   return p[7];
14 }
15 
ldw(unsigned int * p)16 unsigned int ldw (unsigned int *p)
17 {
18   return p[7];
19 }
20 
stb(unsigned char * p,unsigned char x)21 void stb (unsigned char *p, unsigned char x)
22 {
23   p[15] = x;
24 }
25 
sth(unsigned short * p,unsigned short x)26 void sth (unsigned short *p, unsigned short x)
27 {
28   p[15] = x;
29 }
30 
stw(unsigned int * p,unsigned int x)31 void stw (unsigned int *p, unsigned int x)
32 {
33   p[15] = x;
34 }
35 
no_cdx_stb(unsigned char * p,unsigned char x)36 void no_cdx_stb (unsigned char *p, unsigned char x)
37 {
38   p[16] = x;
39 }
40 
no_cdx_sth(unsigned short * p,unsigned short x)41 void no_cdx_sth (unsigned short *p, unsigned short x)
42 {
43   p[16] = x;
44 }
45 
no_cdx_stw(unsigned int * p,unsigned int x)46 void no_cdx_stw (unsigned int *p, unsigned int x)
47 {
48   p[16] = x;
49 }
50 
51 /* { dg-final { scan-assembler "\tldbu\\.n\t.*, 7\\(.*\\)" } } */
52 /* { dg-final { scan-assembler "\tldhu\\.n\t.*, 14\\(.*\\)" } } */
53 /* { dg-final { scan-assembler "\tldw\\.n\t.*, 28\\(.*\\)" } } */
54 
55 /* { dg-final { scan-assembler "\tstb\\.n\t.*, 15\\(.*\\)" } } */
56 /* { dg-final { scan-assembler "\tsth\\.n\t.*, 30\\(.*\\)" } } */
57 /* { dg-final { scan-assembler "\tstw\\.n\t.*, 60\\(.*\\)" } } */
58 
59 /* { dg-final { scan-assembler "\tstb\t.*, 16\\(.*\\)" } } */
60 /* { dg-final { scan-assembler "\tsth\t.*, 32\\(.*\\)" } } */
61 /* { dg-final { scan-assembler "\tstw\t.*, 64\\(.*\\)" } } */
62