1 /* Check that displacement addressing is used for indexed addresses with a
2    small offset, instead of re-calculating the index.  */
3 /* { dg-do compile }  */
4 /* { dg-options "-O2" } */
5 /* { dg-final { scan-assembler-not "add\t#1" } } */
6 
7 int
test_00(int tab[],int index)8 test_00 (int tab[], int index)
9 {
10   return tab[index + 1];
11 }
12 
13 int
test_01(short tab[],int index)14 test_01 (short tab[], int index)
15 {
16   return tab[index + 1];
17 }
18 
19 int
test_02(unsigned short tab[],int index)20 test_02 (unsigned short tab[], int index)
21 {
22   return tab[index + 1];
23 }
24 
25 int
test_03(long long tab[],int index)26 test_03 (long long tab[], int index)
27 {
28   return (int)tab[index + 1];
29 }
30 
31 void
test_04(int tab[],int index,int val)32 test_04 (int tab[], int index, int val)
33 {
34   tab[index + 1] = val;
35 }
36 
37 void
test_05(short tab[],int index,int val)38 test_05 (short tab[], int index, int val)
39 {
40   tab[index + 1] = (short)val;
41 }
42 
43 void
test_06(unsigned short tab[],int index,int val)44 test_06 (unsigned short tab[], int index, int val)
45 {
46   tab[index + 1] = (unsigned short)val;
47 }
48